Makefile revision 45767
157429Smarkm#
257429Smarkm# $Id: Makefile,v 1.27 1999/04/11 04:32:42 bde Exp $
357429Smarkm#
457429Smarkm
557429Smarkm#
660573Skris# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
765668Skris# is such a !@#!*#% nightmare because of how it reprograms the dependencies,
865668Skris# suffix rules, SRCS, etc.  It's easiest to cheat by using bsd.prog.mk and
965668Skris# SRCS to get dependencies.
1065668Skris#
1165668Skris
1257429Smarkm# ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
1357429Smarkm# Prevent mkdep from using it, so that we don't have to give rules for
1457429Smarkm# aliases of generated headers.
1565668Skris#
1657429SmarkmCFLAGS+=	-I.
1757429Smarkm
1857429Smarkm.include "../Makefile.inc"
1957429Smarkm
2057429Smarkm.PATH: ${GCCDIR} ${GCCDIR}/cp
2157429Smarkm
2257429SmarkmCFLAGS+=	-I${GCCDIR}/objc
2360573Skris
2457429Smarkm#-----------------------------------------------------------------------
2557429Smarkm# insn-* gunk
2657429Smarkm
2757429Smarkm.for i in attr codes config flags
2857429Smarkminsn-$i.h: gen$i ${MD_FILE}
2957429Smarkm	./gen$i ${MD_FILE} > insn-$i.h
3057429SmarkmGENSRCS+=	insn-$i.h
3157429Smarkm.endfor
3257429Smarkm
3357429Smarkm.for i in attrtab emit extract opinit output peep recog
3460573Skrisinsn-$i.c: gen$i ${MD_FILE}
3557429Smarkm	./gen$i ${MD_FILE} > insn-$i.c
3657429SmarkmGENSRCS+=	insn-$i.c
3757429Smarkm.endfor
3857429Smarkm
3957429Smarkm.for i in attr codes config emit extract flags opinit output peep recog
4057429Smarkmbuild-tools: gen$i
4157429Smarkm
4257429Smarkmgen$i: gen$i.o rtl.o obstack.o bitmap.o
4357429Smarkm	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
4457429Smarkm
4557429SmarkmGENSRCS+=	gen$i.c
4660573SkrisCLEANFILES+=	gen$i
4757429Smarkm.endfor
4857429Smarkm
4957429Smarkm.for i in attrtab
5057429Smarkmbuild-tools: gen$i
5157429Smarkm
5257429Smarkmgen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
5357429Smarkm	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
5457429Smarkm
5560573SkrisGENSRCS+=	gen$i.c
5657429SmarkmCLEANFILES+=	gen$i
5757429Smarkm.endfor
5857429Smarkm
5957429SmarkmSRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
6057429Smarkm
6157429Smarkm.for i in check genrtl
6257429Smarkmbuild-tools: gen$i
6357429Smarkm
6457429Smarkmgen$i: gen$i.o
6557429Smarkm	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
6657429Smarkm
6757429SmarkmGENSRCS+=	gen$i.c
6857429SmarkmCLEANFILES+=	gen$i
6960573Skris.endfor
7057429Smarkm
7157429Smarkm.ORDER: genrtl.c genrtl.h
7257429Smarkmgenrtl.c genrtl.h: gengenrtl
7357429Smarkm	./gengenrtl genrtl.h genrtl.c
7457429Smarkm
7557429SmarkmGENSRCS+=	genrtl.c genrtl.h
7657429Smarkm
7757429Smarkm#-----------------------------------------------------------------------
7857429Smarkm# C hash codes
7957429Smarkmc-gperf.h: c-parse.gperf
8057429Smarkm	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
8157429Smarkm		${GCCDIR}/c-parse.gperf > ${.TARGET}
8257429SmarkmGENSRCS+=	c-gperf.h
8357429Smarkm
8457429Smarkm#-----------------------------------------------------------------------
8557429Smarkm# C++ hash codes
8657429Smarkmhash.h: gxx.gperf
8757429Smarkm	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
8857429Smarkm		${GCCDIR}/cp/gxx.gperf >hash.h
8957429SmarkmGENSRCS+=	hash.h
9057429Smarkm
9157429Smarkm#-----------------------------------------------------------------------
9257429Smarkm# Common parser stuff.
9357429Smarkm
9457429Smarkmtree-check.h: gencheck
9557429Smarkm	./gencheck > ${.TARGET}
9657429SmarkmGENSRCS+=	tree-check.h
9757429Smarkm
9857429Smarkm#-----------------------------------------------------------------------
9957429Smarkm# C parser
10057429Smarkm.ORDER: c-parse.c c-parse.h
10157429Smarkmc-parse.c c-parse.h: c-parse.in
10257429Smarkm	sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
10360573Skris	    -e "/^ifc$$/d" -e "/^end ifc$$/d" \
10457429Smarkm	    ${GCCDIR}/c-parse.in > c-parse.y
10557429Smarkm	${BISON} -d c-parse.y -o c-parse.c 
10657429Smarkm	rm -f c-parse.y
10757429Smarkm
10857429SmarkmGENSRCS+=	c-parse.c c-parse.h
10957429SmarkmCLEANFILES+=	c-parse.y		# insurance
11057429Smarkm
11160573Skris#-----------------------------------------------------------------------
11257429Smarkm# objc parser
11357429Smarkm.ORDER: objc-parse.c objc-parse.h
11457429Smarkmobjc-parse.c objc-parse.h: c-parse.in
11560573Skris	sed -e "/^ifc$$/,/^end ifc$$/d" \
11657429Smarkm	    -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
11757429Smarkm	    ${GCCDIR}/c-parse.in > objc-parse.y
11857429Smarkm	${BISON} -d objc-parse.y -o objc-parse.c 
11957429Smarkm	rm -f objc-parse.y
12057429Smarkm
12157429SmarkmGENSRCS+=	objc-parse.c objc-parse.h
12260573SkrisCLEANFILES+=	objc-parse.y		# insurance
12357429Smarkm
12457429Smarkm#-----------------------------------------------------------------------
12557429Smarkm# C++ parser done in its own makefile
12660573Skris#-----------------------------------------------------------------------
12757429Smarkm# CPP parser done in its own makefile
12857429Smarkm#-----------------------------------------------------------------------
12957429Smarkm# the host/target compiler config.
13057429Smarkm
13157429SmarkmCOMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
13260573SkrisGENSRCS+=	${COMMONHDRS}
13357429Smarkm
13457429Smarkmconfig.h hconfig.h:
13557429Smarkm	echo '#include "auto-host.h"' > ${.TARGET}
13660573Skris	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' >> ${.TARGET}
13757429Smarkm
13857429Smarkmmultilib.h:
13957429Smarkm	echo 'static char *multilib_raw[] = { \
14057429Smarkm	    "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
14157429Smarkm	echo 'static char *multilib_matches_raw[] = { \
14257429Smarkm	    "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
14357429Smarkm	echo 'static char *multilib_extra = "";' >> ${.TARGET}
14457429Smarkm
14557429Smarkmoptions.h:
14657429Smarkm	echo '#include "cp/lang-options.h"' > ${.TARGET}
14757429Smarkm	echo '#include "f/lang-options.h"' >> ${.TARGET}
14857429Smarkm
14957429Smarkmspecs.h:
15060573Skris	echo '#include "cp/lang-specs.h"' > ${.TARGET}
15157429Smarkm	echo '#include "f/lang-specs.h"'    >> ${.TARGET}
15257429Smarkm
15357429Smarkmtconfig.h:
15457429Smarkm	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' > ${.TARGET}
15557429Smarkm
15657429Smarkmtm.h:
15757429Smarkm	echo '#include "${MACHINE_ARCH}/${MACHINE_ARCH}.h"' > ${.TARGET}
15857429Smarkm.if ${MACHINE_ARCH} == "i386"
15957429Smarkm	echo '#include "${MACHINE_ARCH}/att.h"' >> ${.TARGET}
160.endif
161	echo '#include "${MACHINE_ARCH}/freebsd.h"' >> ${.TARGET}
162.if ${MACHINE_ARCH} == "i386"
163	echo '#include "${MACHINE_ARCH}/perform.h"' >> ${.TARGET}
164.endif
165
166#-----------------------------------------------------------------------
167# General things.
168
169SRCS+=		${GENSRCS}
170CLEANFILES+=	${GENSRCS}
171
172all: ${SRCS}
173
174.include <bsd.prog.mk>
175
176#-----------------------------------------------------------------------
177# Fixups.
178
179# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
180# define PROG because we have multiple programs.
181#
182OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
183
184.if !exists(${DEPENDFILE})
185# Fudge pre-dependfile dependencies of objects in much the same way as
186# bsd.prog.mk would do if we defined PROG.  There are complications to
187# avoid circular dependencies.  First, only make most objects depend on
188# all headers.  Filter out the objects that would cause problems (i.e.,
189# objects that will be used to create programs that will generate headers).
190#
191${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nrtl.o}: ${SRCS:M*.h}
192
193# Next, make each of the problematic objects depend on only most headers.
194# Filter out the headers that would cause problems (and a few more when it
195# is inconvenient to filter precisely).
196#
197bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o rtl.o: \
198    ${SRCS:M*.h:Ninsn-*.h}
199gencheck.o: ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
200gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
201.endif
202