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

Internal rules

The standard set of internal rules used by make is reproduced in the examples shown on the following pages.

make internal rules (Page 1 of 5)

   #
   #	SUFFIXES RECOGNIZED BY MAKE
   #
   .SUFFIXES: .o .c .c~ .y .y~ .l .l~ .s .s~ .h .h~ .sh .sh~ .f .f~
   #
   #	PREDEFINED MACROS
   #
   AR=ar
   ARFLAGS=rv
   AS=as
   ASFLAGS=
   BUILD=build
   CC=cc
   CFLAGS=-O
   C++C=CC
   C++FLAGS=-O
   F77=f77
   FFLAGS=-O
   GET=get
   GFLAGS=
   LEX=lex
   LFLAGS=
   LD=ld
   LDFLAGS=
   MAKE=make
   YACC=yacc
   YFLAGS=
   #
   #       SPECIAL RULES
   #
   markfile.o : markfile
   	A=@; echo "static char _sccsid[]=\042`grep $$A'(#)' markfile`\042;" \
   	> markfile.c
   	$(CC) -c markfile.c
   	-rm -f markfile.c

make internal rules (Page 2 of 5)

   #
   #	SINGLE SUFFIX RULES
   #
   

.c: $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@

.c~: $(GET) $(GFLAGS) $< $(CC) $(CFLAGS) $*.c $(LDFLAGS) -o $* -rm -f $*.c

.f: $(F77) $(F77FLAGS) $< $(LDFLAGS) -o $@

.f~: $(GET) $(GFLAGS) $< $(F77) $(F77FLAGS) $< $(LDFLAGS) -o $* -rm -f $*.f

.sh: cp $< $@; chmod 0777 $@

.sh~: $(GET) $(GFLAGS) $< cp $*.sh $*; chmod 0777 $@ -rm -f $*.sh

make internal rules (Page 3 of 5)

   #
   #	DOUBLE SUFFIX RULES
   #
   

.c~.c .f~.f .s~.s .sh~.sh .y~.y .l~.l .h~.h: $(GET) $(GFLAGS) $<

.c.a: $(CC) -c $(CFLAGS) $< $(AR) $(ARFLAGS) $@ $*.o rm -f $*.o

.c~.a: $(GET) $(GFLAGS) $< $(CC) -c $(CFLAGS) $*.c $(AR) $(ARFLAGS) $@ $*.o rm -f $*.[co]

.c.o: $(CC) $(CFLAGS) -c $<

.c~.o: $(GET) $(GFLAGS) $< $(CC) $(CFLAGS) -c $*.c -rm -f $*.c

.f.a: $(F77) $(F77FLAGS) -c $*.f $(LDFLAGS) $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.o

.f~.a: $(GET) $(GFLAGS) $< $(F77) $(F77FLAGS) c $*.f $(LDFLAGS) $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.[fo]

make internal rules (Page 4 of 5)

   .f.o:
   	$(F77) $(F77FLAGS) -c $*.f $(LDFLAGS)
   

.f~.o: $(GET) $(GFLAGS) $< $(F77) $(F77FLAGS) -c $*.f $(LDFLAGS) -rm -f $*.f

.s~.a: $(GET) $(GFLAGS) $< $(AS) $(ASFLAGS) -o $*.o $*.s $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.[so]

.s.o: $(AS) $(ASFLAGS) -o $@ $<

.s~.o: $(GET) $(GFLAGS) $< $(AS) $(ASFLAGS) -o $*.o $*.s -rm -f $*.s

.l.c : $(LEX) $(LFLAGS) $< mv lex.yy.c $@

.l~.c: $(GET) $(GFLAGS) $< $(LEX) $(LFLAGS) $*.l mv lex.yy.c $@

make internal rules (Page 5 of 5)

   .l.o:
   	$(LEX) $(LFLAGS) $<
   	$(CC) $(CFLAGS) -c lex.yy.c
   	rm lex.yy.c
   	mv lex.yy.o $@
   	-rm -f $*.l
   

.l~.o: $(GET) $(GFLAGS) $< $(LEX) $(LFLAGS) $*.l $(CC) $(CFLAGS) -c lex.yy.c rm -f lex.yy.c $*.l mv lex.yy.o $*.o

.y.c : $(YACC) $(YFLAGS) $< mv y.tab.c $@

.y~.c : $(GET) $(GFLAGS) $< $(YACC) $(YFLAGS) $*.y mv y.tab.c $*.c -rm -f $*.y

.y.o: $(YACC) $(YFLAGS) $< $(CC) $(CFLAGS) -c y.tab.c rm y.tab.c mv y.tab.o $@

.y~.o: $(GET) $(GFLAGS) $< $(YACC) $(YFLAGS) $*.y $(CC) $(CFLAGS) -c y.tab.c rm -f y.tab.c $*.y mv y.tab.o $*.o


Previous topic: Makefile example

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