Makefile revision 52171
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 52171 1999-10-12 20:25:11Z 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
20CFLAGS+=	-I${GCCDIR}/objc
21
22#-----------------------------------------------------------------------
23# insn-* gunk
24
25.for i in attr codes config flags
26insn-$i.h: gen$i ${MD_FILE}
27	./gen$i ${MD_FILE} > insn-$i.h
28GENSRCS+=	insn-$i.h
29.endfor
30
31.for i in attrtab emit extract opinit output peep recog
32insn-$i.c: gen$i ${MD_FILE}
33	./gen$i ${MD_FILE} > insn-$i.c
34GENSRCS+=	insn-$i.c
35.endfor
36
37.for i in attr codes config emit extract flags opinit output peep recog
38build-tools: gen$i
39
40gen$i: gen$i.o rtl.o obstack.o bitmap.o
41	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
42
43GENSRCS+=	gen$i.c
44CLEANFILES+=	gen$i
45.endfor
46
47.for i in attrtab
48build-tools: gen$i
49
50gen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
51	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
52
53GENSRCS+=	gen$i.c
54CLEANFILES+=	gen$i
55.endfor
56
57SRCS+=		bitmap.c obstack.c print-rtl.c rtl.c rtlanal.c
58
59.for i in check genrtl
60build-tools: gen$i
61
62gen$i: gen$i.o
63	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
64
65GENSRCS+=	gen$i.c
66CLEANFILES+=	gen$i
67.endfor
68
69.ORDER: genrtl.c genrtl.h
70genrtl.c genrtl.h: gengenrtl
71	./gengenrtl genrtl.h genrtl.c
72
73GENSRCS+=	genrtl.c genrtl.h
74
75#-----------------------------------------------------------------------
76# C hash codes
77c-gperf.h: c-parse.gperf
78	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
79	    ${GCCDIR}/c-parse.gperf > ${.TARGET}
80GENSRCS+=	c-gperf.h
81
82#-----------------------------------------------------------------------
83# C++ hash codes
84gxx-hash.h: gxx.gperf
85	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
86	    ${GCCDIR}/cp/gxx.gperf >gxx-hash.h
87
88hash.h: gxx-hash.h
89	ln -s ${.ALLSRC} ${.TARGET}
90GENSRCS+=	gxx-hash.h hash.h
91
92#-----------------------------------------------------------------------
93# Common parser stuff.
94
95tree-check.h: gencheck
96	./gencheck > ${.TARGET}
97GENSRCS+=	tree-check.h
98
99#-----------------------------------------------------------------------
100# C parser
101.ORDER: c-parse.c c-parse.h
102c-parse.c c-parse.h: c-parse.in
103	sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
104	    -e "/^ifc$$/d" -e "/^end ifc$$/d" \
105	    ${GCCDIR}/c-parse.in > c-parse.y
106	${YACC} -d -o c-parse.c c-parse.y
107	mv c-parse.y c-parse.y.out
108
109GENSRCS+=	c-parse.c c-parse.h
110CLEANFILES+=	c-parse.y c-parse.y.out		# insurance
111
112#-----------------------------------------------------------------------
113# objc parser
114.ORDER: objc-parse.c objc-parse.h
115objc-parse.c objc-parse.h: c-parse.in
116	sed -e "/^ifc$$/,/^end ifc$$/d" \
117	    -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
118	    ${GCCDIR}/c-parse.in > objc-parse.y
119	${YACC} -d -o objc-parse.c objc-parse.y
120	mv objc-parse.y objc-parse.y.out
121
122GENSRCS+=	objc-parse.c objc-parse.h
123CLEANFILES+=	objc-parse.y objc-parse.y.out	# insurance
124
125#-----------------------------------------------------------------------
126# C++ parser done in its own makefile
127#-----------------------------------------------------------------------
128# CPP parser done in its own makefile
129#-----------------------------------------------------------------------
130# the host/target compiler config.
131
132COMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
133GENSRCS+=	${COMMONHDRS}
134
135config.h hconfig.h:
136	echo '#include "auto-host.h"' > ${.TARGET}
137	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' >> ${.TARGET}
138
139multilib.h:
140	echo 'static char *multilib_raw[] = { \
141	    "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
142	echo 'static char *multilib_matches_raw[] = { \
143	    "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
144	echo 'static char *multilib_extra = "";' >> ${.TARGET}
145
146options.h:
147	echo '#include "cp/lang-options.h"' > ${.TARGET}
148	echo '#include "f/lang-options.h"' >> ${.TARGET}
149
150specs.h:
151	echo '#include "cp/lang-specs.h"' > ${.TARGET}
152	echo '#include "f/lang-specs.h"'    >> ${.TARGET}
153
154tconfig.h:
155	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"' > ${.TARGET}
156
157tm.h:
158	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"' > ${.TARGET}
159.if ${GCC_ARCH} == "i386"
160	echo '#include "${GCC_ARCH}/att.h"' >> ${.TARGET}
161	echo '#include "svr4.h"' >> ${.TARGET}
162.endif
163	echo '#include "${GCC_ARCH}/freebsd.h"' >> ${.TARGET}
164.if ${GCC_ARCH} == "i386"
165	echo '#include "${GCC_ARCH}/perform.h"' >> ${.TARGET}
166.endif
167	echo '#include <freebsd-native.h>' >> ${.TARGET}
168
169#-----------------------------------------------------------------------
170# General things.
171
172SRCS+=		${GENSRCS}
173CLEANFILES+=	${GENSRCS}
174
175all: ${SRCS}
176
177.include <bsd.prog.mk>
178
179#-----------------------------------------------------------------------
180# Fixups.
181
182# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
183# define PROG because we have multiple programs.
184#
185OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
186
187.if !exists(${DEPENDFILE})
188# Fudge pre-dependfile dependencies of objects in much the same way as
189# bsd.prog.mk would do if we defined PROG.  There are complications to
190# avoid circular dependencies.  First, only make most objects depend on
191# all headers.  Filter out the objects that would cause problems (i.e.,
192# objects that will be used to create programs that will generate headers).
193#
194${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nrtl.o}: ${SRCS:M*.h}
195
196# Next, make each of the problematic objects depend on only most headers.
197# Filter out the headers that would cause problems (and a few more when it
198# is inconvenient to filter precisely).
199#
200bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o rtl.o: \
201    ${SRCS:M*.h:Ninsn-*.h}
202gencheck.o: ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
203gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
204.endif
205