Makefile revision 49864
11541Srgrimes#	$Id: Makefile,v 1.35 1999/08/14 22:40:01 obrien Exp $
21541Srgrimes
31541Srgrimes#
41541Srgrimes# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
51541Srgrimes# is such a !@#!*#% nightmare because of how it reprograms the dependencies,
61541Srgrimes# suffix rules, SRCS, etc.  It's easiest to cheat by using bsd.prog.mk and
71541Srgrimes# SRCS to get dependencies.
81541Srgrimes#
91541Srgrimes
101541Srgrimes# ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
111541Srgrimes# Prevent mkdep from using it, so that we don't have to give rules for
121541Srgrimes# aliases of generated headers.
131541Srgrimes
141541SrgrimesCFLAGS+=	-I.
151541Srgrimes
161541Srgrimes.include "../Makefile.inc"
171541Srgrimes
181541Srgrimes.PATH: ${GCCDIR} ${GCCDIR}/cp
191541Srgrimes
201541SrgrimesCFLAGS+=	-I${GCCDIR}/objc
211541Srgrimes
221541Srgrimes#-----------------------------------------------------------------------
231541Srgrimes# insn-* gunk
241541Srgrimes
251541Srgrimes.for i in attr codes config flags
261541Srgrimesinsn-$i.h: gen$i ${MD_FILE}
271541Srgrimes	./gen$i ${MD_FILE} > insn-$i.h
281541SrgrimesGENSRCS+=	insn-$i.h
291541Srgrimes.endfor
301541Srgrimes
311541Srgrimes.for i in attrtab emit extract opinit output peep recog
321541Srgrimesinsn-$i.c: gen$i ${MD_FILE}
331541Srgrimes	./gen$i ${MD_FILE} > insn-$i.c
341541SrgrimesGENSRCS+=	insn-$i.c
351541Srgrimes.endfor
361541Srgrimes
371541Srgrimes.for i in attr codes config emit extract flags opinit output peep recog
381541Srgrimesbuild-tools: gen$i
3950477Speter
401541Srgrimesgen$i: gen$i.o rtl.o obstack.o bitmap.o
411541Srgrimes	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
4213203Swollman
43101127SrwatsonGENSRCS+=	gen$i.c
4413203SwollmanCLEANFILES+=	gen$i
451541Srgrimes.endfor
462112Swollman
4769664Speter.for i in attrtab
4876166Smarkmbuild-tools: gen$i
49101127Srwatson
5089316Salfredgen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
511541Srgrimes	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
521541Srgrimes
531541SrgrimesGENSRCS+=	gen$i.c
541541SrgrimesCLEANFILES+=	gen$i
551541Srgrimes.endfor
561541Srgrimes
571541SrgrimesSRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
581541Srgrimes
591541Srgrimes.for i in check genrtl
6092751Sjeffbuild-tools: gen$i
6132011Sbde
621541Srgrimesgen$i: gen$i.o
6369664Speter	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
6469664Speter
6592751SjeffGENSRCS+=	gen$i.c
6669664SpeterCLEANFILES+=	gen$i
6769664Speter.endfor
6869664Speter
6969664Speter.ORDER: genrtl.c genrtl.h
7092654Sjeffgenrtl.c genrtl.h: gengenrtl
7192654Sjeff	./gengenrtl genrtl.h genrtl.c
7269664Speter
7369664SpeterGENSRCS+=	genrtl.c genrtl.h
7469664Speter
7569664Speter#-----------------------------------------------------------------------
7669664Speter# C hash codes
771541Srgrimesc-gperf.h: c-parse.gperf
781541Srgrimes	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
791541Srgrimes	    ${GCCDIR}/c-parse.gperf > ${.TARGET}
801541SrgrimesGENSRCS+=	c-gperf.h
811541Srgrimes
821541Srgrimes#-----------------------------------------------------------------------
831541Srgrimes# C++ hash codes
841541Srgrimeshash.h: gxx.gperf
851541Srgrimes	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
861541Srgrimes	    ${GCCDIR}/cp/gxx.gperf >hash.h
871541SrgrimesGENSRCS+=	hash.h
881541Srgrimes
891541Srgrimes#-----------------------------------------------------------------------
901541Srgrimes# Common parser stuff.
911541Srgrimes
921541Srgrimestree-check.h: gencheck
931541Srgrimes	./gencheck > ${.TARGET}
941541SrgrimesGENSRCS+=	tree-check.h
951541Srgrimes
961541Srgrimes#-----------------------------------------------------------------------
971541Srgrimes# C parser
981541Srgrimes.ORDER: c-parse.c c-parse.h
991541Srgrimesc-parse.c c-parse.h: c-parse.in
1001541Srgrimes	sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
1011541Srgrimes	    -e "/^ifc$$/d" -e "/^end ifc$$/d" \
1021541Srgrimes	    ${GCCDIR}/c-parse.in > c-parse.y
1031541Srgrimes	${YACC} -d -o c-parse.c c-parse.y
1041541Srgrimes	mv c-parse.y c-parse.y.out
1051541Srgrimes
1061541SrgrimesGENSRCS+=	c-parse.c c-parse.h
10783366SjulianCLEANFILES+=	c-parse.y c-parse.y.out		# insurance
10883366Sjulian
1091541Srgrimes#-----------------------------------------------------------------------
11091419Sjhb# objc parser
11183366Sjulian.ORDER: objc-parse.c objc-parse.h
11242408Seivindobjc-parse.c objc-parse.h: c-parse.in
11342453Seivind	sed -e "/^ifc$$/,/^end ifc$$/d" \
11442408Seivind	    -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
11542453Seivind	    ${GCCDIR}/c-parse.in > objc-parse.y
11683366Sjulian	${YACC} -d -o objc-parse.c objc-parse.y
1171541Srgrimes	mv objc-parse.y objc-parse.y.out
1181541Srgrimes
1191541SrgrimesGENSRCS+=	objc-parse.c objc-parse.h
1201541SrgrimesCLEANFILES+=	objc-parse.y objc-parse.y.out	# insurance
1211541Srgrimes
1221541Srgrimes#-----------------------------------------------------------------------
123111119Simp# C++ parser done in its own makefile
1241541Srgrimes#-----------------------------------------------------------------------
1251541Srgrimes# CPP parser done in its own makefile
12636735Sdfr#-----------------------------------------------------------------------
1271541Srgrimes# the host/target compiler config.
1281541Srgrimes
12936735SdfrCOMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
13020069SbdeGENSRCS+=	${COMMONHDRS}
13120069Sbde
13220069Sbdeconfig.h hconfig.h:
13320069Sbde	echo '#include "auto-host.h"' > ${.TARGET}
13420069Sbde	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' >> ${.TARGET}
13520069Sbde
13620069Sbdemultilib.h:
1371541Srgrimes	echo 'static char *multilib_raw[] = { \
13892751Sjeff	    "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
139100613Srwatson	echo 'static char *multilib_matches_raw[] = { \
140100613Srwatson	    "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
141100613Srwatson	echo 'static char *multilib_extra = "";' >> ${.TARGET}
142100613Srwatson
1431541Srgrimesoptions.h:
1441541Srgrimes	echo '#include "cp/lang-options.h"' > ${.TARGET}
1451541Srgrimes	echo '#include "f/lang-options.h"' >> ${.TARGET}
1461541Srgrimes
1471541Srgrimesspecs.h:
14897994Sjhb	echo '#include "cp/lang-specs.h"' > ${.TARGET}
14997994Sjhb	echo '#include "f/lang-specs.h"'    >> ${.TARGET}
15097994Sjhb
15197994Sjhbtconfig.h:
15297994Sjhb	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' > ${.TARGET}
1531541Srgrimes
1541541Srgrimestm.h:
1551541Srgrimes	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"' > ${.TARGET}
1561541Srgrimes.if ${GCC_ARCH} == "i386"
1571541Srgrimes	echo '#include "${GCC_ARCH}/att.h"' >> ${.TARGET}
15889306Salfred.endif
15933360Sdyson	echo '#include "svr4.h"' >> ${.TARGET}
16051649Sphk	echo '#include "${GCC_ARCH}/freebsd.h"' >> ${.TARGET}
16133360Sdyson.if ${GCC_ARCH} == "i386"
1621541Srgrimes	echo '#include "${GCC_ARCH}/perform.h"' >> ${.TARGET}
1631541Srgrimes.endif
16489306Salfred	echo '#include <freebsd-native.h>' >> ${.TARGET}
1651541Srgrimes
1661541Srgrimes#-----------------------------------------------------------------------
1671541Srgrimes# General things.
1681541Srgrimes
1691541SrgrimesSRCS+=		${GENSRCS}
1701541SrgrimesCLEANFILES+=	${GENSRCS}
1711541Srgrimes
1721541Srgrimesall: ${SRCS}
1731541Srgrimes
1741541Srgrimes.include <bsd.prog.mk>
1751541Srgrimes
1761541Srgrimes#-----------------------------------------------------------------------
1771541Srgrimes# Fixups.
1781541Srgrimes
1791541Srgrimes# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
1801541Srgrimes# define PROG because we have multiple programs.
1813148Sphk#
1823148SphkOBJS+=		${SRCS:N*.h:R:S/$/.o/g}
18392751Sjeff
184100613Srwatson.if !exists(${DEPENDFILE})
185100613Srwatson# Fudge pre-dependfile dependencies of objects in much the same way as
186100613Srwatson# bsd.prog.mk would do if we defined PROG.  There are complications to
187100613Srwatson# avoid circular dependencies.  First, only make most objects depend on
1881541Srgrimes# all headers.  Filter out the objects that would cause problems (i.e.,
1891541Srgrimes# objects that will be used to create programs that will generate headers).
1901541Srgrimes#
1911541Srgrimes${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nrtl.o}: ${SRCS:M*.h}
1921541Srgrimes
1931541Srgrimes# Next, make each of the problematic objects depend on only most headers.
194100613Srwatson# Filter out the headers that would cause problems (and a few more when it
19592751Sjeff# is inconvenient to filter precisely).
196100613Srwatson#
197100613Srwatsonbitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o rtl.o: \
198100613Srwatson    ${SRCS:M*.h:Ninsn-*.h}
199100613Srwatsongencheck.o: ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
200100613Srwatsongengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
2011541Srgrimes.endif
20232286Sdyson