Makefile revision 45500
1#
2# $Id: Makefile,v 1.23 1999/04/08 15:11:44 peter 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
60GENSRCS+=	genrtl.c genrtl.h
61
62.for i in attrtab
63build-tools: gen$i
64
65gen$i: gen$i.o rtl.o rtlanal.o print-rtl.o obstack.o bitmap.o
66	${CC} -static ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
67
68GENSRCS+=	gen$i.c
69CLEANFILES+=	gen$i
70.endfor
71
72SRCS+=		bitmap.c print-rtl.c rtl.c rtlanal.c obstack.c
73#-----------------------------------------------------------------------
74# C hash codes
75c-gperf.h: c-parse.gperf
76	gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$$ \
77		${GCCDIR}/c-parse.gperf > ${.TARGET}
78GENSRCS+=	c-gperf.h
79
80#-----------------------------------------------------------------------
81# C++ hash codes
82hash.h: gxx.gperf
83	gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
84		${GCCDIR}/cp/gxx.gperf >hash.h
85GENSRCS+=	hash.h
86
87#-----------------------------------------------------------------------
88# common parser stuff
89
90.for i in c objc
91$i-parse.c: tree-check.h
92.endfor
93
94tree-check.h: gencheck
95	./gencheck > ${.TARGET}
96
97CLEANFILES+=	tree-check.h
98
99#-----------------------------------------------------------------------
100# C parser
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	${BISON} -d c-parse.y -o c-parse.c 
106	rm -f c-parse.y
107
108GENSRCS+=	c-parse.c c-parse.h
109CLEANFILES+=	c-parse.y		# insurance
110
111#-----------------------------------------------------------------------
112# objc parser
113objc-parse.c objc-parse.h: c-parse.in
114	sed -e "/^ifc$$/,/^end ifc$$/d" \
115	    -e "/^ifobjc$$/d" -e "/^end ifobjc$$/d" \
116	    ${GCCDIR}/c-parse.in > objc-parse.y
117	${BISON} -d objc-parse.y -o objc-parse.c 
118	rm -f objc-parse.y
119
120GENSRCS+=	objc-parse.c objc-parse.h
121CLEANFILES+=	objc-parse.y		# insurance
122
123#-----------------------------------------------------------------------
124# C++ parser done in its own makefile
125#-----------------------------------------------------------------------
126# CPP parser done in its own makefile
127#-----------------------------------------------------------------------
128# the host/target compiler config.
129
130COMMONHDRS=	config.h hconfig.h options.h specs.h tconfig.h tm.h multilib.h
131GENSRCS+=	${COMMONHDRS}
132
133config.h hconfig.h:
134	echo '#include "auto-host.h"' > ${.TARGET}
135	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' >> ${.TARGET}
136
137tconfig.h:
138	echo '#include "${MACHINE_ARCH}/xm-${MACHINE_ARCH}.h"' > ${.TARGET}
139
140options.h:
141	echo '#include "cp/lang-options.h"' > ${.TARGET}
142	#echo '#include "f/lang-options.h"' >> ${.TARGET}
143
144specs.h:
145	echo '#include "cp/lang-specs.h"' > ${.TARGET}
146	#echo '#include "f/lang-specs.h"'    >> ${.TARGET}
147
148tm.h:
149	echo '#include "${MACHINE_ARCH}/${MACHINE_ARCH}.h"' > ${.TARGET}
150.if ${MACHINE_ARCH} == "i386"
151	echo '#include "${MACHINE_ARCH}/att.h"' >> ${.TARGET}
152.endif
153	echo '#include "${MACHINE_ARCH}/freebsd.h"' >> ${.TARGET}
154.if ${MACHINE_ARCH} == "i386"
155	echo '#include "${MACHINE_ARCH}/perform.h"' >> ${.TARGET}
156.endif
157
158multilib.h: genmultilib
159	echo 'static char *multilib_raw[] = {"aout maout;", "elf !maout;", NULL};' > multilib.h
160	echo 'static char *multilib_matches_raw[] = {"maout maout;", "melf melf;", NULL};' >> multilib.h
161	echo 'static char *multilib_extra = "";' >> multilib.h
162
163#-----------------------------------------------------------------------
164# General things.
165
166SRCS+=		${GENSRCS}
167CLEANFILES+=	${GENSRCS}
168
169all: ${SRCS}
170
171.include <bsd.prog.mk>
172
173#-----------------------------------------------------------------------
174# Fixups.
175
176# Set OBJS the same as bsd.prog.mk would do if we defined PROG.  We can't
177# define PROG because we have multiple programs.
178#
179OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
180
181.if !exists(${DEPENDFILE})
182# Fudge pre-dependfile dependencies of objects the same as bsd.prog.mk
183# would do if we defined PROG, except for leaving out dependencies on
184# insn-*.h because these dependencies would be circular.
185#
186${OBJS:Ngengenrtl.o}: ${SRCS:M*.h:Ninsn-*.h}
187
188# Give all dependencies on insn-*.h explicitly
189# This suffices for `make -j<any> depend', and after that all
190# the dependencies will be in .depend since all .c source files are in
191# SRCS.
192#
193genattrtab.o genextract.o: insn-config.h
194insn-attrtab.o: insn-attr.h insn-config.h
195insn-emit.o: insn-codes.h insn-config.h insn-flags.h
196insn-opinit.o: insn-codes.h insn-config.h insn-flags.h
197insn-output.o: insn-attr.h insn-codes.h insn-config.h insn-flags.h
198insn-recog.o: insn-config.h
199.endif
200