Two make questions
Posted in 2003
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi;
Two questions on make:-
1.
How can I get the name of the makefile into a usable variable?
IE $MK = makefile if I use makefile
= Makefile if I am using Makefile
= whatever if I run `make 'f whatever`.
===========
2.
I am compiling Informix .ec files and ask how can I force 'make' to
compile the .ec file rather than the .c left over from a previous
erroneous compile.
Eg:-
$ make
cgi_env.ec: In function `dl_our_tag':
cgi_env.ec:2695: `n' undeclared (first use in this function)cgi_env.ec:2695: (Each undeclared identifier is reported only once
cgi_env.ec:2695: for each function it appears in.)
cgi_env.ec:2695: parse error before "strcpy"
*** Error code 1
make: Fatal error: Command failed for target `cgi_env.o'
I have now corrected the cgi_env.ec file.
$ make
cgi_env.ec: In function `dl_our_tag':
cgi_env.ec:2695: `n' undeclared (first use in this function) etc.
My make file fragment is:-
.SUFFIXES : .o .4gl .ec .c
.4gl.o :
@$(ESQL) $(ESQLFLAGS) $(CFLAGS) $<
.ec.o :
@$(ESQL) $(ESQLFLAGS) $(CFLAGS) $<
.c.o :
@$(ESQL) $(ESQLFLAGS) $(CFLAGS) $<
If I `rm cgi_env.c` 'make' works OK.
Regards
Ian
Ian: The make utility looks for a file named Makefile or makefile in the current working director when you execute it. If your Makefile is named something else; e.g., "stuff.mk" you execute the make utility with "make -f stuff.mk." You can export the name of the Makefile into the environment; e.g., "export stuff.mk," but you do not have to do that if the Makefile is named either "Makefile" (the desirable name) or "makefile" (the less desirable name). The following is a "make.rules" file for compiling Informix programs. Save it as "make.rules" in your local include directory (don't merge it with make.rules file on the system) and put a line in your Makefile like this: MAKEFILE = Makefile BASDIR = ${INSTALL_BASE} # These are the rules for making Informix targets: include $(BASDIR)/include/make.rules # Mess with them at your peril INSTALL_BASE is wherever your include directory is; e.g., "/usr/local." Note that the make utility will also use the default make.rules. Note that you can change the definition of CFLAGS, ECFLAGS, or C4FLAGS in the make.rules file below (that becomes the default) or in the Makefile you create for a given program -- whatever is in the Makefile will override whatever is in make.rules. The make.rules file: #ident "$Id$" .SUFFIXES: .arc .arc~ .ace .ace~ .cbl .cbl~ .frm .frm~ .per .per~ .o .4gl .4gl~ .4go .ec .ec~ .c .c~ .y .y~ .l .l~ .s .s~ .sh .sh~ .h .h~ # C optimization flag CFLAGS = -O # ace section .ace~.arc: $(GET) $(GFLAGS) $< ${INFORMIXDIR}/bin/saceprep $< rm -f $*.ace .ace.arc: ${INFORMIXDIR}/bin/saceprep $< # perform section FORM = ${INFORMIXDIR}/bin/sformbld .per~.frm: $(GET) $(GFLAGS) $< ${FORM} $< rm -f $*.per .per.frm: ${FORM} $< # cobol language section COBOL = cob CBFLAGS = -O -x .cbl~: $(GET) $(GFLAGS) $< $(COBOL) $(CBFLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.cbl $*.lst $*.int .cbl: $(COBOL) $(CBFLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.lst $*.int $*.o .cbl~.o: $(GET) $(GFLAGS) $< $(COBOL) $(CBFLAGS) -c $< .cbl.o: $(COBOL) $(CBFLAGS) -c $< # 4gl language section C4GL = c4gl C4FLAGS = FGL = fglpc .4gl~: $(GET) $(GFLAGS) $< $(C4GL) $(C4FLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.4gl $*.4ec $*.ec $*.[co] .4gl: $(C4GL) $(C4FLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.4ec $*.[co] .4gl~.4go: $(GET) $(GFLAGS) $< $(FGL) $*.4gl -rm -f $*.4gl .4gl.4go: $(FGL) $*.4gl .4gl~.o: $(GET) $(GFLAGS) $< $(C4GL) $(C4FLAGS) -e $< $(CC) $(C4FLAGS) -I${INFORMIXDIR}/incl/tools -c $*.c -rm -f $*.4gl $*.4ec $*.ec $*.c .4gl.o: $(C4GL) $(C4FLAGS) -e $< $(CC) $(C4FLAGS) -I${INFORMIXDIR}/incl/tools -c $*.c -rm -f $*.4ec $*.ec $*.c .4gl~.a: $(GET) $(GFLAGS) $< $(C4GL) $(C4FLAGS) -e $< $(CC) $(C4FLAGS) -I${INFORMIXDIR}/incl/tools -c $*.c $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.4gl $*.4ec $*.ec $*.[co] .4gl.a: $(C4GL) $(C4FLAGS) -e $< $(CC) $(C4FLAGS) -I${INFORMIXDIR}/incl/tools -c $*.c $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.4ec $*.ec $*.[co] # esql/c language section ESQL = esql ECFLAGS = .ec~: $(GET) $(GFLAGS) $< $(ESQL) $(ECFLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.ec $*.[co] .ec: $(ESQL) $(ECFLAGS) -s -o $@ $< $(LDFLAGS) -rm -f $*.[co] .ec~.o: $(GET) $(GFLAGS) $< $(ESQL) $(ECFLAGS) -e $< $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c -rm -f $*.ec $*.c .ec.o: $(ESQL) $(ECFLAGS) -e $< $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c -rm -f $*.c .ec~.a: $(GET) $(GFLAGS) $< $(ESQL) $(ECFLAGS) -e $< $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.ec $*.[co] .ec.a: $(ESQL) $(ECFLAGS) -e $< $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c $(AR) $(ARFLAGS) $@ $*.o -rm -f $*.[co] .c~.c: $(GET) $(GFLAGS) $< .c~.o: $(GET) $(GFLAGS) $< $(CC) $(CFLAGS) -c $*.c -rm -f $*.c # RCS section CO = co .ace,v.arc: $(CO) $< $(INFORMIXDIR)/bin/saceprep $< .per,v.frm: $(CO) $< $(INFORMIXDIR)/bin/sformbld $< .ec,v.o: $(CO) $< $(ESQL) $(ECFLAGS) -c $*.o -rm -f $*.c .4gl,v.o: $(CO) $< $(C4GL) $(C4FLAGS) -c $*.o -rm -f $*.c .c,v.o: $(CO) $< $(CC) $(CFLAGS) -c $*.o -rm -f $*.c .ec,v.ec: $(CO) $< .4gl,v.4gl: $(CO) $< .c,v.c: $(CO) $<