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