Makefile revision 58478
112315Sasami# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 58478 2000-03-23 10:18:26Z obrien $
212315Sasami
312315Sasami#
412315Sasami# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
512315Sasami# is such a !@#!*#% nightmare because of how it reprograms the dependencies,
612315Sasami# suffix rules, SRCS, etc.  It's easiest to cheat by using bsd.prog.mk and
760107Sobrien# SRCS to get dependencies.
860107Sobrien#
912315Sasami
1012315Sasami# ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
1112315Sasami# Prevent mkdep from using it, so that we don't have to give rules for
1212315Sasami# aliases of generated headers.
1312315Sasami
1412315SasamiCFLAGS+=	-I.
1512315Sasami
1612315Sasami.include "../Makefile.inc"
1712315Sasami
1812315Sasami.PATH: ${GCCDIR} ${GCCDIR}/cp
1912315Sasami
2012315Sasami#-----------------------------------------------------------------------
2112315Sasami# insn-* gunk
2212315Sasami
2312315Sasami.for F in attr codes config flags
2412315Sasamiinsn-$F.h: gen$F ${MD_FILE}
2512315Sasami	./gen$F ${MD_FILE} > insn-$F.h
2612315SasamiGENSRCS+=	insn-$F.h
2712315Sasami.endfor
2812315Sasami
2912315Sasami.for F in attrtab emit extract opinit output peep recog
3012315Sasamiinsn-$F.c: gen$F ${MD_FILE}
3112315Sasami	./gen$F ${MD_FILE} > insn-$F.c
3212315SasamiGENSRCS+=	insn-$F.c
3312315Sasami.endfor
3412315Sasami
3512315Sasami.for F in attr codes config emit extract flags opinit output peep recog
3612315Sasamibuild-tools: gen$F
3712315Sasami
3812315Sasamigen$F: gen$F.o rtl.o obstack.o print-rtl.o bitmap.o
3912315Sasami	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
4012315Sasami
4112315SasamiGENSRCS+=	gen$F.c
4212315SasamiCLEANFILES+=	gen$F
4312315Sasami.endfor
4412315Sasami
4512315Sasami.for F in attrtab
4612315Sasamibuild-tools: gen$F
4712315Sasami
4812315Sasamigen$F: gen$F.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
4912315Sasami	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
5012315Sasami
5112315SasamiGENSRCS+=	gen$F.c
5212315SasamiCLEANFILES+=	gen$F
5338140Syokota.endfor
5432822Syokota
5512315SasamiSRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
5612315Sasami
5712315Sasami.for F in check genrtl
5812315Sasamibuild-tools: gen$F
5912315Sasami
6012315Sasamigen$F: gen$F.o
6112315Sasami	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
6212315Sasami
6312315SasamiGENSRCS+=	gen$F.c
6412315SasamiCLEANFILES+=	gen$F
6512315Sasami.endfor
6612315Sasami
6712315Sasami.ORDER: genrtl.c genrtl.h
6843334Syokotagenrtl.c genrtl.h: gengenrtl
6912315Sasami	./gengenrtl genrtl.h genrtl.c
7032822Syokota
7112315SasamiGENSRCS+=	genrtl.c genrtl.h
7212315Sasami
7312315Sasami#-----------------------------------------------------------------------
7412315Sasami# C hash codes
7512315Sasamic-gperf.h: c-parse.gperf
7612315Sasami	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
7712315Sasami	    ${GCCDIR}/c-parse.gperf > ${.TARGET}
7812315SasamiGENSRCS+=	c-gperf.h
7912315Sasami
8012315Sasami#-----------------------------------------------------------------------
8112315Sasami# C++ hash codes
8212315Sasamigxx-hash.h: gxx.gperf
8312315Sasami	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
8412315Sasami	    ${GCCDIR}/cp/gxx.gperf >gxx-hash.h
8512315SasamiGENSRCS+=	gxx-hash.h
8612315Sasami
8712315Sasami# make a link the the Cygnus used name for now -- hopes are they will change it
8812315Sasamihash.h: gxx-hash.h
8912315Sasami	ln -sf ${.ALLSRC} ${.TARGET}
9012315SasamiGENSRCS+=	hash.h
9112315Sasami
9212315Sasami#-----------------------------------------------------------------------
9312315Sasami# Common parser stuff.
9412315Sasami
9512315Sasamitree-check.h: gencheck
9612315Sasami	./gencheck > ${.TARGET}
9743334SyokotaGENSRCS+=	tree-check.h
9812315Sasami
9912315Sasami#-----------------------------------------------------------------------
10012315Sasami# the host/target compiler config.
10112315Sasami
10218194SsosCOMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
10312315SasamiGENSRCS+=	${COMMONHDRS} gencheck.h
10412315Sasami
10574119Sacheconfig.h hconfig.h:
10612315Sasami	echo '#include "auto-host.h"'			> ${.TARGET}
10712315Sasami	echo '#include "gansidecl.h"'			>> ${.TARGET}
10812315Sasami	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
10912315Sasami	echo '#include "hwint.h"'			>> ${.TARGET}
11012315Sasami
11112315Sasamigencheck.h:
11212315Sasami	echo '#include "cp/cp-tree.def"'		> ${.TARGET}
11312315Sasami	echo '#include "objc/objc-tree.def"'		>> ${.TARGET}
11412315Sasami
11574119Sachemultilib.h:
11612315Sasami	echo 'static char *multilib_raw[] = { \
11743334Syokota	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
11843334Syokota	echo 'static char *multilib_matches_raw[] = { \
11943334Syokota	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
12043334Syokota	echo 'static char *multilib_extra = "";'	>> ${.TARGET}
12143334Syokota
122options.h:
123	echo '#include "cp/lang-options.h"'		> ${.TARGET}
124	echo '#include "f/lang-options.h"'		>> ${.TARGET}
125
126specs.h:
127	echo '#include "cp/lang-specs.h"'		> ${.TARGET}
128	echo '#include "f/lang-specs.h"'		>> ${.TARGET}
129	echo '#include "objc/lang-specs.h"'		>> ${.TARGET}
130
131tconfig.h:
132	echo '#include "gansidecl.h"'			> ${.TARGET}
133	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
134
135#	KEEP THIS IN SYNC with src/gcc/lib/libgcc/Makefile !!
136tm.h:
137	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"'	> ${.TARGET}
138.if ${GCC_ARCH} == "i386"
139	echo '#include "${GCC_ARCH}/att.h"'		>> ${.TARGET}
140.endif
141	echo '#include <freebsd.h>'			>> ${.TARGET}
142	echo '#include "${GCC_ARCH}/freebsd.h"'		>> ${.TARGET}
143.if ${GCC_ARCH} == "i386"
144	echo '#include "${GCC_ARCH}/perform.h"'		>> ${.TARGET}
145.endif
146	echo '#include <freebsd-native.h>'		>> ${.TARGET}
147
148#-----------------------------------------------------------------------
149# General things.
150
151SRCS+=		${GENSRCS}
152CLEANFILES+=	${GENSRCS}
153
154all: ${SRCS}
155
156.include <bsd.prog.mk>
157
158#-----------------------------------------------------------------------
159# Fixups.
160
161# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
162# define PROG because we have multiple programs.
163#
164OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
165
166.if !exists(${DEPENDFILE})
167# Fudge pre-dependfile dependencies of objects in much the same way as
168# bsd.prog.mk would do if we defined PROG.  There are complications to
169# avoid circular dependencies.  First, only make most objects depend on
170# all headers.  Filter out the objects that would cause problems (i.e.,
171# objects that will be used to create programs that will generate headers).
172#
173${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nprint-rtl.o:Nrtl.o}: ${SRCS:M*.h}
174
175# Next, make each of the problematic objects depend on only most headers.
176# Filter out the headers that would cause problems (and a few more when it
177# is inconvenient to filter precisely).
178#
179bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o print-rtl.o \
180    rtl.o: ${SRCS:M*.h:Ninsn-*.h}
181gencheck.o: gencheck.h ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
182gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
183.endif
184