05-04-2012, 11:56 AM
Miracle technologies
1_Linux_Makefile_Writing.ppt (Size: 382.5 KB / Downloads: 29)
Makefiles
Script file to automate program compilation and linking (making)
1. Write the "makefile"
2. Write your programs
3. Run "make" or "make -f makefile"
Makefile is a list of rules and commands
Dependencies
Sometimes one file depends on another file
e.g. a C file depends on its header files
If a header file changes, the C files that #include that header file should be recompiled to take into account the changes to the header
Generic form of a rule
Target is the output file
Prerequisites are the files that are needed by target (and that can cause target to be recompiled if they change)
Command is the actual command to turn the prerequisites into the target
Multiple Targets (4)
If interface.h is changed and saved, Make will discern that both main.o and interface.o need to be recompiled, followed by a build of MyProject from the new main.o and interface.o