Conditional directives allow you to define
multiple versions of a command based on
preexisting conditions.
example, say you have a set of
libraries you want included in your
binary only if the compiler used is gcc:
libs_for_gcc = -lgnu normal_libs =
foo: $(objects) ifeq ($(CC),gcc) $(CC) -o foo $(objects) $(libs_for_gcc) else $(CC) -o foo $(objects) $(normal_libs) endif
In this example, you use ifeq to
check if CC equals gcc and if it does,
use the gcc libraries; otherwise, use
the generic libraries.
This is just a small, basic sampling
of the things you can do with make
and makefiles. There are so many more
complex and interesting things you
can do, you just have to dig around
to find them!;
Adrian Hannah has spent the past 15 years bashing keyboards to
make computers do what he tells them. He currently is working
as a system administrator for the federal government. He is a jack
of all trades and a master of none. He spends all his waking hours
on the Linux Journal IRC channel, on Twitter (@codemoney2841)
and talking to random chat bots on the Internet.
Resources
GNU make comes with most Linux distributions by default,
but it can be found on the main GNU FTP server:
ftp.gnu.org/gnu/make (via HTTP) and
ftp.gnu.org/gnu/make (via FTP). It also can be found
on the GNU mirrors at www.gnu.org/prep/ftp.html.
Documentation for make is available on-line at
www.gnu.org/software/make/manual, as is
documentation for most GNU software. You also can
find more information about make by running info make
or man make, or by looking at /usr/doc/make/,
/usr/local/doc/make/ or similar directories on your system.
A brief summary is available by running make --help.