Re: makefile for esqlc source
Posted in 1995
Please note that just as you use CC (or $(CC) or ${CC}) to denote the C compiler, so too you should use a macro to denote the ESQL/C compiler. Also, the ESQL/C compiler script compiles .c to .o quite happily, and it provides the -I options which are in general necessary (this is what Cosmo (simond@informix.com) said). And 'rm -f' should not return an error, (so the '-' is unnecessary), and should be echoed in my view (possibly controversial, but if you agree, the '@' is unnecessary). You should really use: ESQL = esql RM = rm -f .SUFFIXES : .ec ec.o : $(ESQL) -c $(CFLAGS) $< $(RM) $*.c Finally, if you want to guarantee that the .ec file will be used in preference to the .c file, then you have to rewrite the SUFFIXES rule more thoroughly. If you are lucky, your version of MAKE defines a macro SUFFIXES. You can then use the following and then your .ec file will be used in preference to the .c file, even if both exist: .SUFFIXES: # Clears current suffix list .SUFFIXES: .ec $(SUFFIXES) If you aren't lucky enough to have $(SUFFIXES) defined for you, you can use the following command to see what the .SUFFIXES rule is, and you can capture that in your own SUFFIXES macro. make -f /dev/null -p 2>/dev/null Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h> }From: Philip Walden <pwalden@rmy.emory.edu> }Date: 19 Dec 1995 14:36:52 GMT }X-Informix-List-Id: <news.19790> } }siva@hogpe.ho.att.com (-S.POTHIREDDY) wrote: }>I am having problem writing a makefile for an esqlc source program. }>The makefile I have written is like this }> }>prog1: src1.o src2.o src3.o }> $(CC) -o $(OBJ) src1.o src2.o src3.o }> }>src1.o: src1.ec def.h }> esql -e src1.ec; $(CC) -c src1.c }> }>src2.o: src2.ec def.h }> esql -e src2.ec; $(CC) -c src2.c }> }>src3.o: src3.ec def.h }> esql -e src3.ec; $(CC) -c src3.c } }Try this rule in your makefile: } }SUFFIXES : .ec } }ec.o : } esql -e $(CFLAGS) $< } $(CC) $(CFLAGS) -c $*.c } @-rm -f $*.c } }The makefile should then automatically handle esqlc files. The only problem }I have with this method is that when a compile error occurs the 'rm' does not }remove the intermediate .c. On a subsequent make the esqlc preprocessor is not }invoked. This can cause some confusion if you are not aware of the problem. } }-------------------------------------------------------------------------- }Philip Walden }Hewlett Packard }Product Generation Information Systems }1501 Page Mill Road, M/S 4U-6 }Palo Alto, CA 94304 }(415) 857-3899 FAX (415) 857-8234 }--------------------------------------------------------------------------