only for RuBoard - do not distribute or recompile |
Make is a command line utility for rebuilding project files. In this case, it will be applied to the WCA project, but you should find it relatively simple to port it to your own project.
Make provides the following benefits:
It minimizes rebuilds by not recompiling or relinking more than is necessary; it does this by examining the file timestamps and deciding what has changed since the last build.
It breaks the compile and link process down into discrete steps so that problems can be isolated.
It becomes easier to change the compile and link process when the source code structure of the project changes, such as when a new *.c file needs to be included in the project.
It examines and checks dependencies among the various project files.
Listing 10.2 is a simple makefile . From within its directory, type make at the command line; make will automatically find Makefile .
INCLUDES = -I/usr/include/mysql LIBS = -L/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lz GTK-CONFIG = `gtk-config --cflags --libs` # For the second line, below, it is ABSOLUTELY ESSENTIAL # that it begin with a Tab character. Executed commands # like that are indicated to make by a tab character as # the first character on the line. WCA : main.o interface.o support.o callbacks.o comm_utils.o ddc.o gcc -o WCA *.o $(GTK-CONFIG) $(INCLUDES) $(LIBS) main.o : main.c gcc -c main.c $(GTK-CONFIG) interface.o : interface.c gcc -c interface.c $(GTK-CONFIG) support.o : support.c gcc -c support.c $(GTK-CONFIG) callbacks.o : callbacks.c gcc -c callbacks.c $(GTK-CONFIG) comm_utils.o : comm_utils.c gcc -c comm_utils.c $(GTK-CONFIG) $(INCLUDES) ddc.o : ddc.c gcc -c ddc.c $(GTK-CONFIG) $(INCLUDES) clean:: rm -f $(PROG).o $(PROG)
Recall that:
A pound sign (#) designates a comment.
The equals signs (=) mark lines that create variables .
The $() notation expands the variables.
The makefile breaks demonstrate the dependencies among the program; that is, each .o file is dependent on its .c file, and the WCA executable is dependent on all the .o files.
only for RuBoard - do not distribute or recompile |