make with multiple executables from same source files

Paul Chamberlain tif at doorstop.austin.ibm.com
Tue Nov 13 02:42:17 AEST 1990


I'm not sure what happened the first time, I'll try again...

I have two executables that depend on the same source files but are
compiled with different CFLAGS.  Anybody have a good way to make a
makefile understand this?

Let's say I have source1.c, source2.c, and source3.c.  I want to
be able to say "make exe1", "make exe2", or "make all".  But I
want it to do the right thing if I say "make all; make all".  i.e.

	cc -DDEF1 -c source1.c
	cc -DDEF1 -c source2.c
	cc -DDEF1 -c source3.c
	cc -o exe1 source1.o source2.o source3.o
	cc -DDEF2 -c source1.c
	cc -DDEF2 -c source2.c
	cc -DDEF2 -c source3.c
	cc -o exe2 source1.o source2.o source3.o

and then

	`all' is up to date.

I don't mind having extra "touch", "test", or "rm" commands.  I
don't even mind having more than one makefile.

Paul Chamberlain | I do NOT represent IBM.     tif at doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmchs!auschs!doorstop.austin.ibm.com!tif



More information about the Comp.unix.programmer mailing list