Makefile revision 45307
1#
2# $Id: Makefile,v 1.16 1999/04/04 20:40:45 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${GCCDIR}/objc
17
18.include "../Makefile.inc"
19
20.PATH: ${GCCDIR} ${GCCDIR}/cp
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 check genrtl
48build-tools: gen$i
49
50gen$i: gen$i.o
51	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
52
53GENSRCS+=	gen$i.c
54CLEANFILES+=	gen$i
55.endfor
56
57genrtl.h genrtl.c: gengenrtl
58	./gengenrtl genrtl.h genrtl.c
59
60#GENSRCS+=	genrtl.c genrtl.h
61CLEANFILES+=	genrtl.c genrtl.h
62
63.for i in attrtab
64build-tools: gen$i
65
66gen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
67	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
68
69GENSRCS+=	gen$i.c
70CLEANFILES+=	gen$i
71.endfor
72
73SRCS+=		bitmap.c print-rtl.c rtl.c rtlanal.c obstack.c
74#-----------------------------------------------------------------------
75# C hash codes
76c-gperf.h: c-parse.gperf
77	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
78		${GCCDIR}/c-parse.gperf > ${.TARGET}
79GENSRCS+=	c-gperf.h
80
81#-----------------------------------------------------------------------
82# C++ hash codes
83hash.h: gxx.gperf
84	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
85		${GCCDIR}/cp/gxx.gperf >hash.h
86GENSRCS+=	hash.h
87
88#-----------------------------------------------------------------------
89# common parser stuff
90
91.for i in c objc
92$i-parse.c: tree-check.h
93.endfor
94
95tree-check.h: gencheck
96	./gencheck > ${.TARGET}
97
98##GENSRCS+=	tree-check.h
99CLEANFILES+=	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	${BISON} -d c-parse.y -o c-parse.c 
109	rm -f c-parse.y
110
111GENSRCS+=	c-parse.c c-parse.h
112CLEANFILES+=	c-parse.y		# 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	${BISON} -d objc-parse.y -o objc-parse.c 
122	rm -f objc-parse.y
123
124GENSRCS+=	objc-parse.c objc-parse.h
125CLEANFILES+=	objc-parse.y		# 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 options.h specs.h tconfig.h tm.h multilib.h
135GENSRCS+=	${COMMONHDRS}
136
137config.h hconfig.h:
138	echo '#include "auto-host.h"' > ${.TARGET}
139	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' >> ${.TARGET}
140
141tconfig.h:
142	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' > ${.TARGET}
143
144options.h:
145	echo '#include "cp/lang-options.h"' > ${.TARGET}
146	#echo '#include "f/lang-options.h"' >> ${.TARGET}
147
148specs.h:
149	echo '#include "cp/lang-specs.h"' > ${.TARGET}
150	#echo '#include "f/lang-specs.h"'    >> ${.TARGET}
151
152tm.h:
153	echo '#include "${MACHINE_ARCH}/${MACHINE_ARCH}.h"' > ${.TARGET}
154.if ${MACHINE_ARCH} == "i386"
155	echo '#include "${MACHINE_ARCH}/att.h"' >> ${.TARGET}
156.endif
157	echo '#include "${MACHINE_ARCH}/freebsd.h"' >> ${.TARGET}
158.if ${MACHINE_ARCH} == "i386"
159	echo '#include "${MACHINE_ARCH}/perform.h"' >> ${.TARGET}
160.elif ${MACHINE_ARCH} == "alpha"
161	echo '#include "${MACHINE_ARCH}/freebsd-elf.h"' >> ${.TARGET}
162.endif
163
164multilib.h: genmultilib
165	echo 'static char *multilib_raw[] = {"aout maout;elf !maout;", NULL};' > multilib.h
166	echo 'static char *orig_port_multilib_raw[] = {".;", NULL};' >> multilib.h
167	echo 'static char *multilib_matches_raw[] = {NULL};' >> multilib.h
168	echo 'static char **multilib_extra = "";' >> multilib.h
169
170#-----------------------------------------------------------------------
171# General things.
172
173SRCS+=		${GENSRCS}
174CLEANFILES+=	${GENSRCS}
175
176all: ${SRCS}
177
178.include <bsd.prog.mk>
179
180#-----------------------------------------------------------------------
181# Fixups.
182
183# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
184# define PROG because we have multiple programs.
185#
186OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
187
188.if !exists(${DEPENDFILE})
189# Fudge pre-dependfile dependencies of objects the same as bsd.prog.mk
190# would do if we defined PROG, except for leaving out dependencies on
191# insn-*.h because these dependencies would be circular.
192#
193${OBJS}: ${SRCS:M*.h:Ninsn-*.h}
194
195# Give all dependencies on insn-*.h explicitly
196# This suffices for `make -j<any> depend', and after that all
197# the dependencies will be in .depend since all .c source files are in
198# SRCS.
199#
200genattrtab.o genextract.o: insn-config.h
201insn-attrtab.o: insn-attr.h insn-config.h
202insn-emit.o: insn-codes.h insn-config.h insn-flags.h
203insn-opinit.o: insn-codes.h insn-config.h insn-flags.h
204insn-output.o: insn-attr.h insn-codes.h insn-config.h insn-flags.h
205insn-recog.o: insn-config.h
206
207genattr.o gencodes.o genconfig.o genemit.o genextract.o genflags.o genopinit.o genoutput.o genpeep.o genrecog.o: genrtl.h
208.endif
209