[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make, make, make. . .
Ishpeck wrote:
>
> Where might I find a good resource for documentation on wrighting
> makefiles? I don't know jack diddly about Make (having come from a
> DOS/Borland world where we have projects instead of makefiles).
*basic* Makefiles are really simple, basically three kinds of
thing in the file:
Comments:
# blah blah blah
Setting variables:
FRED = blah blah blah
Defining rules:
thing_you_want : things_it_depends_on
command_you_use_to_build_it
another_command_you_need
more_commands
Notice that the start of each command line should begin with a TAB
character. Some 'make' varients will allow a bunch of spaces - but
if you want maximum portability - it's gotta be a TAB...yes, that
does *REALLY* suck...but modern make's don't need it.
Using a variable is done like this: ${FRED}
There are more things like generic rules and stuff like that.
So, once you have your Makefile, you can either just run 'make thing_you_want'
and it'll go and find the rule to make that file - make sure that all the
'things_it_depends_on' are up to date (possibly evaluating other rules to
make that happen) - and if necessary run all the commands you gave.
Running 'make' without parameters simply defaults to making the first
thing in the file.
You can make the 'thing_you_want' be something that doesn't exist to
make 'virtual' targets. Commonly used virtual targets are:
all -- Make everything in this directory...that's usually the
first rule - so 'make all' is the same as just 'make'.
install -- Make everything and install it wherever it's supposed to be.
clean -- Erase all the '.o' files and other trash that isn't needed
after the build.
By default, 'make' will pick up a file called either 'makefile' or
'Makefile' (the latter is more conventional under UNIX/Linux). You
can name the Makefile something else - but please don't!
That'll get you going with makefile's - but there is LOTS more to learn
and RTFM is the answer.
Once you know a little 'make' - check out the 'automake' package that
can write makefiles for you automagically from a much simpler starting
point ('Makefile.am').
--
Steve Baker http://web2.airmail.net/sjbaker1
sjbaker1@airmail.net (home) http://www.woodsoup.org/~sbaker
sjbaker@hti.com (work)
---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: linuxgames-help@sunsite.auc.dk