Makefile revision 91559
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 91559 2002-03-02 08:53:36Z obrien $
2
3#
4# This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
5# is such a !@#!*#% nightmare because of how it reprograms the dependencies,
6# suffix rules, SRCS, etc.  It's easiest to cheat by using bsd.prog.mk and
7# SRCS to get dependencies.
8#
9
10# ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
11# Prevent mkdep from using it, so that we don't have to give rules for
12# aliases of generated headers.
13
14CFLAGS+=	-I.
15
16.include "../Makefile.inc"
17
18.PATH: ${GCCDIR} ${GCCDIR}/cp
19
20#-----------------------------------------------------------------------
21# insn-* gunk
22
23.for F in attr codes config flags
24insn-$F.h: gen$F ${MD_FILE}
25	./gen$F ${MD_FILE} > insn-$F.h
26GENSRCS+=	insn-$F.h
27.endfor
28
29GENSRCS+=	gen-time-stamp
30gen-time-stamp: genattrtab genemit genextract genopinit genoutput genpeep genrecog
31	touch ${.TARGET}
32
33.for F in attr codes config emit extract flags opinit output peep recog
34build-tools: gen$F
35
36gen$F: gen$F.o rtl.o obstack.o print-rtl.o bitmap.o
37	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
38
39GENSRCS+=	gen$F.c
40CLEANFILES+=	gen$F
41.endfor
42
43.for F in attrtab
44build-tools: gen$F
45
46gen$F: gen$F.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
47	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
48
49GENSRCS+=	gen$F.c
50CLEANFILES+=	gen$F
51.endfor
52
53SRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
54
55.for F in check genrtl
56build-tools: gen$F
57
58gen$F: gen$F.o
59	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
60
61GENSRCS+=	gen$F.c
62CLEANFILES+=	gen$F
63.endfor
64
65.ORDER: genrtl.c genrtl.h
66genrtl.c genrtl.h: gengenrtl
67	./gengenrtl genrtl.h genrtl.c
68
69GENSRCS+=	genrtl.c genrtl.h
70
71#-----------------------------------------------------------------------
72# C hash codes
73c-gperf.h: c-parse.gperf
74	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
75	    ${GCCDIR}/c-parse.gperf > ${.TARGET}
76GENSRCS+=	c-gperf.h
77
78#-----------------------------------------------------------------------
79# C++ hash codes
80gxx-hash.h: gxx.gperf
81	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
82	    ${GCCDIR}/cp/gxx.gperf >gxx-hash.h
83GENSRCS+=	gxx-hash.h
84
85# make a link the the Cygnus used name for now -- hopes are they will change it
86hash.h: gxx-hash.h
87	ln -sf ${.ALLSRC} ${.TARGET}
88GENSRCS+=	hash.h
89
90#-----------------------------------------------------------------------
91# Common parser stuff.
92
93tree-check.h: gencheck
94	./gencheck > ${.TARGET}
95GENSRCS+=	tree-check.h
96
97#-----------------------------------------------------------------------
98# the host/target compiler config.
99
100COMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
101GENSRCS+=	${COMMONHDRS} gencheck.h
102
103config.h hconfig.h:
104	echo '#include "auto-host.h"'			> ${.TARGET}
105	echo '#include "gansidecl.h"'			>> ${.TARGET}
106	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
107	echo '#include "hwint.h"'			>> ${.TARGET}
108
109gencheck.h:
110	echo '#include "cp/cp-tree.def"'		> ${.TARGET}
111	echo '#include "objc/objc-tree.def"'		>> ${.TARGET}
112
113multilib.h:
114	echo 'static char *multilib_raw[] = { \
115	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
116	echo 'static char *multilib_matches_raw[] = { \
117	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
118	echo 'static char *multilib_extra = "";'	>> ${.TARGET}
119
120options.h:
121	echo '#include "cp/lang-options.h"'		> ${.TARGET}
122	echo '#include "f/lang-options.h"'		>> ${.TARGET}
123
124specs.h:
125	echo '#include "cp/lang-specs.h"'		> ${.TARGET}
126	echo '#include "f/lang-specs.h"'		>> ${.TARGET}
127	echo '#include "objc/lang-specs.h"'		>> ${.TARGET}
128
129tconfig.h:
130	echo '#include "gansidecl.h"'			> ${.TARGET}
131	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
132
133# KEEP THIS IN SYNC with src/gcc/lib/libgcc/Makefile !!
134tm.h:
135	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"'	> ${.TARGET}
136.if ${GCC_ARCH} == "i386"
137	echo '#include "${GCC_ARCH}/att.h"'		>> ${.TARGET}
138.endif
139	echo '#include <freebsd.h>'			>> ${.TARGET}
140	echo '#include "dbxelf.h"'			>> ${.TARGET}
141.if exists(${GCCDIR}/config/${GCC_ARCH}/elf.h)
142	echo '#include "${GCC_ARCH}/elf.h"'		>> ${.TARGET}
143.endif
144	echo '#include "${GCC_ARCH}/freebsd.h"'		>> ${.TARGET}
145.if ${GCC_ARCH} == "i386"
146	echo '#include "${GCC_ARCH}/perform.h"'		>> ${.TARGET}
147.endif
148	echo '#include <freebsd-native.h>'		>> ${.TARGET}
149
150#-----------------------------------------------------------------------
151# General things.
152
153SRCS+=		${GENSRCS}
154CLEANFILES+=	${GENSRCS}
155
156all: ${SRCS}
157
158build-tools: depend
159
160.include <bsd.prog.mk>
161
162#-----------------------------------------------------------------------
163# Fixups.
164
165# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
166# define PROG because we have multiple programs.
167#
168OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
169
170.if !exists(${DEPENDFILE})
171# Fudge pre-dependfile dependencies of objects in much the same way as
172# bsd.prog.mk would do if we defined PROG.  There are complications to
173# avoid circular dependencies.  First, only make most objects depend on
174# all headers.  Filter out the objects that would cause problems (i.e.,
175# objects that will be used to create programs that will generate headers).
176#
177${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}
178
179# Next, make each of the problematic objects depend on only most headers.
180# Filter out the headers that would cause problems (and a few more when it
181# is inconvenient to filter precisely).
182#
183bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o print-rtl.o \
184    rtl.o: ${SRCS:M*.h:Ninsn-*.h}
185gencheck.o: gencheck.h ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
186gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
187.endif
188