Makefiles
make is a powerful utility which allows programs to be broken down into
small pieces, and based on the date of modification, the pieces not up-to-date are
recompiled and/or linked. A basic makefile is shown
below.
<program> : <objectfiles> <libraries>
cc -o <program> <objectfiles> <libraries> -lm
.c.o :
cc -c $*.c
Where:
- <program>
- is the name of the program being compiled.
- <objectfiles>
- are the object files needed to create the executable.
- <libraries>
- are the HyperMesh libraries needed by the object files.
In this example, the program being compiled is called mytrans. The
object file needed is mytrans.o and the two libraries are
hminlib.a and hmlib.a. The object files are
created by compiling the source code files, mytrans.c, which are not
explicitly listed in the makefile. After the substitutions are made, the
makefile needed to create the program mytrans looks
like this:
mytrans : mytrans.o hminlib.a hmlib.a
cc -o mytrans mytrans.o hminlib.a hmlib.a -lm
.c.o :
cc -c $*.c