Makefiles -- .c and .h
Eric C. Olson
ericco at ssl.berkeley.edu
Tue Nov 20 06:23:08 AEST 1990
Why not compile the object files directly into a compilation dependent
library. Like:
lib1.a : $(SRC)
cc $(CFLAGS1) $? | exit
ar a $@ $(?:.c=.o)
/bin/rm $(?:.c=.o)
lib2.a : $(SRC)
cc $(CFLAGS2) $? | exit
ar a $@ $(?:.c=.o)
/bin/rm $(?:.c=.o)
exe1 : main.c lib1.a
cc $(LFLAGS) -o $@ main.c lib1.a
exe2 : main.c lib2.a
cc $(LFLAGS) -o $@ main.c lib2.a
If the compilation fails, you may get into trouble, i think the exit
will take care of this. In general, in Sun make, this could be:
all : exeDEF1 exeDEF2 exeDEF3
lib%.a : $(SRC)
cc -c -D% $? | exit
ar a $@ $(?:.c=.o)
/bin/rm $(?:.c=.o)
exe% : main.c lib%.a
cc -o $@ main.c lib%.a
--
Eric
ericco at ssl.berkeley.edu
More information about the Comp.unix.programmer
mailing list