Makefile revision 53161
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 53161 1999-11-15 00:29:00Z 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
87GENSRCS+=	gxx-hash.h
88
89# make a link the the Cygnus used name for now -- hopes are they will change it
90hash.h: gxx-hash.h
91	ln -sf ${.ALLSRC} ${.TARGET}
92GENSRCS+=	hash.h
93
94#-----------------------------------------------------------------------
95# Common parser stuff.
96
97tree-check.h: gencheck
98	./gencheck > ${.TARGET}
99GENSRCS+=	tree-check.h
100
101#-----------------------------------------------------------------------
102# C parser
103.ORDER: c-parse.c c-parse.h
104c-parse.c c-parse.h: c-parse.in
105	sed -e "/^ifobjc$$/,/^end ifobjc$$/d" \
106	    -e "/^ifc$$/d" -e "/^end ifc$$/d" \
107	    ${GCCDIR}/c-parse.in > c-parse.y
108	${YACC} -d -o c-parse.c c-parse.y
109	mv c-parse.y c-parse.y.out
110
111GENSRCS+=	c-parse.c c-parse.h
112CLEANFILES+=	c-parse.y c-parse.y.out		# insurance
113
114#-----------------------------------------------------------------------
115# objc parser
116.ORDER: objc-parse.c objc-parse.h
117objc-parse.c objc-parse.h: c-parse.in
118	sed -e "/^ifc$$/,/^end ifc$$/d" \
119	    -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
120	    ${GCCDIR}/c-parse.in > objc-parse.y
121	${YACC} -d -o objc-parse.c objc-parse.y
122	mv objc-parse.y objc-parse.y.out
123
124GENSRCS+=	objc-parse.c objc-parse.h
125CLEANFILES+=	objc-parse.y objc-parse.y.out	# insurance
126
127#-----------------------------------------------------------------------
128# C++ parser done in its own makefile
129#-----------------------------------------------------------------------
130# CPP parser done in its own makefile
131#-----------------------------------------------------------------------
132# the host/target compiler config.
133
134COMMONHDRS=	config.h hconfig.h multilib.h options.h specs.h tconfig.h tm.h
135GENSRCS+=	${COMMONHDRS}
136
137config.h hconfig.h:
138	echo '#include "auto-host.h"'			> ${.TARGET}
139	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	>> ${.TARGET}
140
141multilib.h:
142	echo 'static char *multilib_raw[] = { \
143	    "aout maout;", "elf !maout;", NULL };'	> ${.TARGET}
144	echo 'static char *multilib_matches_raw[] = { \
145	    "maout maout;", "melf melf;", NULL };'	>> ${.TARGET}
146	echo 'static char *multilib_extra = "";'	>> ${.TARGET}
147
148options.h:
149	echo '#include "cp/lang-options.h"'		> ${.TARGET}
150	echo '#include "f/lang-options.h"'		>> ${.TARGET}
151
152specs.h:
153	echo '#include "cp/lang-specs.h"'		> ${.TARGET}
154	echo '#include "f/lang-specs.h"'		>> ${.TARGET}
155
156tconfig.h:
157	echo '#include "${GCC_ARCH}/xm-${GCC_ARCH}.h"'	> ${.TARGET}
158
159tm.h:
160	echo '#include "${GCC_ARCH}/${GCC_ARCH}.h"'	> ${.TARGET}
161.if ${GCC_ARCH} == "i386"
162	echo '#include "${GCC_ARCH}/att.h"'		>> ${.TARGET}
163	echo '#include "svr4.h"'			>> ${.TARGET}
164.endif
165	echo '#include "${GCC_ARCH}/freebsd.h"'		>> ${.TARGET}
166.if ${GCC_ARCH} == "i386"
167	echo '#include "${GCC_ARCH}/perform.h"'		>> ${.TARGET}
168.endif
169	echo '#include <freebsd-native.h>'		>> ${.TARGET}
170
171#-----------------------------------------------------------------------
172# General things.
173
174SRCS+=		${GENSRCS}
175CLEANFILES+=	${GENSRCS}
176
177all: ${SRCS}
178
179.include <bsd.prog.mk>
180
181#-----------------------------------------------------------------------
182# Fixups.
183
184# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
185# define PROG because we have multiple programs.
186#
187OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
188
189.if !exists(${DEPENDFILE})
190# Fudge pre-dependfile dependencies of objects in much the same way as
191# bsd.prog.mk would do if we defined PROG.  There are complications to
192# avoid circular dependencies.  First, only make most objects depend on
193# all headers.  Filter out the objects that would cause problems (i.e.,
194# objects that will be used to create programs that will generate headers).
195#
196${OBJS:Nbitmap.o:Ngenattr.o:Ngencheck.o:Ngencodes.o:Ngenconfig.o:Ngenflags.o:Ngengenrtl.o:Nobstack.o:Nrtl.o}: ${SRCS:M*.h}
197
198# Next, make each of the problematic objects depend on only most headers.
199# Filter out the headers that would cause problems (and a few more when it
200# is inconvenient to filter precisely).
201#
202bitmap.o genattr.o gencodes.o genconfig.o genflags.o obstack.o rtl.o: \
203    ${SRCS:M*.h:Ninsn-*.h}
204gencheck.o: ${SRCS:M*.h:Ngenrtl.h:Ntree-check.h:Ninsn-*.h}
205gengenrtl.o: ${SRCS:M*.h:Ngenrtl.h:Ninsn-*.h}
206.endif
207