|
|
For example, consider a makefile to maintain the make command itself. The code for make is spread over a number of C language source files and has a yacc grammar. An example of the makefile follows:
# makefile for the make commandThe make program prints out each command before issuing it.FILES = Makefile defs.h main.c doname.c misc.c files.c dosys.c gram.y OBJECTS = main.o doname.o misc.o files.o dosys.o gram.o LIBES= -lld LINT = lint -p CFLAGS = -O LP = /usr/bin/lp
make: $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) $(LIBES) -o make @size make
$(OBJECTS): defs.h
clean: -rm *.o gram.c
install: @size make /usr/bin/make cp make /usr/bin/make && rm make
lint : dosys.c doname.c files.c main.c misc.c gram.c $(LINT) dosys.c doname.c files.c main.c misc.c \ gram.c
The following output results from typing make in a directory containing only the source and makefiles:
cc -O -c main.c cc -O -c doname.c cc -O -c misc.c cc -O -c files.c cc -O -c dosys.c yacc gram.y mv y.tab.c gram.c cc -O -c gram.c cc main.o doname.o misc.o files.o dosys.o gram.o -lld -o make 13188 + 3348 + 3044 = 19580The string of digits results from the size make command. The printing of the command line itself was suppressed by an "at" (@) sign in the makefile.