gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > makefile noob

#116498 - wiz - Fri Jan 26, 2007 11:31 am

Hi,

(post edited)

In a makefile can you change the directory to make files in subfolders?


Last edited by wiz on Fri Jan 26, 2007 1:00 pm; edited 1 time in total

#116500 - keldon - Fri Jan 26, 2007 11:52 am

A bat file is not a makefile. Here is a makefile tutorial

#116501 - wiz - Fri Jan 26, 2007 11:56 am

((inital post edited))

#116509 - keldon - Fri Jan 26, 2007 1:48 pm

Sometimes editing a post in that nature is unnecessary and far less helpful to yourself. Edit changes, not the entire content!

Do you mean to run a makefile from within a makefile? What are you trying to achieve first?

#116517 - kusma - Fri Jan 26, 2007 3:18 pm

GNU Make can call "make -C some_dir" to enter some_dir and make there. Or, if you simply want it to look for source-files in multiple folders, try the VPATH-directive.

http://www.gnu.org/software/make/manual/make.html is your friend.

#116584 - wiz - Sat Jan 27, 2007 3:26 am

Hi and thanks for your replies, sorry I wasnt very clear in what I am trying to acheive. I hope this will make more sense.

I have a subfolder, called GFX in my project folder. Inside GFX I have a simple BMP file that when I update it I would like my makefile to process it.

To manually update the BMP file I would normally use a command line command GFX2GBA.EXE with flags

Below is some of my makefile contents:
Code:

gfx/IMAGE.raw.c : gfx/IMAGE.bmp
   gfx/gfx2gba -fsrc -x -t8 gfx/IMAGE.BMP

This works but the problem I have is the output from "GFX2GBA" is put in to my project folder, and I would like it to be in my GFX folder with the actual BMP file.

Also doing it this way requires me to add the path gfx/ to everything - even the command parameters.

I have read quite a few tutorials but I can't figure this out.

I appreciate the help I get from you guys. thank you.

#116593 - tepples - Sat Jan 27, 2007 5:51 am

wiz wrote:
I have a subfolder, called GFX in my project folder. Inside GFX I have a simple BMP file that when I update it I would like my makefile to process it.

To manually update the BMP file I would normally use a command line command GFX2GBA.EXE with flags

Below is some of my makefile contents:
Code:

gfx/IMAGE.raw.c : gfx/IMAGE.bmp
   gfx/gfx2gba -fsrc -x -t8 gfx/IMAGE.BMP

This works but the problem I have is the output from "GFX2GBA" is put in to my project folder, and I would like it to be in my GFX folder with the actual BMP file.

Have you considered the -o option of gfx2gba to put the output in a given folder?

Quote:
Also doing it this way requires me to add the path gfx/ to everything - even the command parameters.

Make provides a shortcut $@ meaning the output file, a shortcut $^ meaning the input files, and a shortcut $< meaning the first input file. This should reduce the typing somewhat.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#116662 - wiz - Sun Jan 28, 2007 12:44 am

Cheers I will try that :)

I didnt even think to look at gfx2gba options! The shortcuts will come in very handy too.

#116664 - tepples - Sun Jan 28, 2007 1:02 am

There are also pattern rules using the % character, which make the shortcuts even more powerful:
Code:
%.raw.c : %.bmp
   gfx/gfx2gba -fsrc -x -t8 $< -o$(<D)

where $(<D) refers to the folder containing the .bmp file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.