DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
make

Makefile example

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 command
   

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 make program prints out each command before issuing it.

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 = 19580
The 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.

Next topic: Internal rules
Previous topic: Suggestions and warnings

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003