2233c95b |
1 | # Despite the source files ending in ".c", the c++ compiler needs to build |
2 | # everything. We have to roll our own targets to properly support this. |
3 | |
4 | .include "../Makefile.inc" |
5 | .include "../../Makefile.langs" |
6 | |
7 | NXCXXFLAGS+= -DGENERATOR_FILE -I${.OBJDIR} |
8 | BUILD_LIBS= ../libiberty/libiberty.na |
9 | BUILD_LIBS_genmatch= ../libcpp/libcpp.na |
10 | LEX_HEAD= ../../cc_prep/gengtype-lex.head |
11 | NXLD_genautomata= -lm |
12 | |
13 | MIC= sh ${GCCDIR}/move-if-change |
14 | |
15 | BUILD_RTL= rtl.no \ |
16 | read-rtl.no \ |
17 | ggc-none.no \ |
18 | vec.no \ |
19 | min-insn-modes.no \ |
20 | gensupport.no \ |
21 | print-rtl.no \ |
22 | hash-table.no |
23 | BUILD_MD= read-md.no |
24 | BUILD_ERRORS= errors.no |
25 | BUILD_GTYPE= gengtype-lex.no \ |
26 | gengtype-parse.no \ |
27 | gengtype-state.no \ |
28 | version.no |
29 | |
30 | genprogrtl= attr attr-common attrtab automata codes conditions config emit \ |
31 | extract flags opinit output peep preds recog mddump target-def |
32 | genprogmd= $(genprogrtl) mddeps constants enums |
33 | genprogerr= $(genprogmd) genrtl modes gtype hooks cfn-macros match |
34 | genprog= $(genprogerr) check checksum condmd |
35 | |
36 | NO_RTL= ${genprogrtl:S/^/gen/g:S/$/.no/g} |
37 | NO_MD= ${genprogmd:S/^/gen/g:S/$/.no/g} |
38 | NO_PROGERR= ${genprogerr:S/^/gen/g:S/$/.no/g} |
39 | NO_PROG= ${genprog:S/^/gen/g:S/$/.no/g} |
40 | NO_LIST= ${BUILD_RTL} ${BUILD_MD} ${BUILD_ERRORS} \ |
41 | ${BUILD_GTYPE} ${NO_PROG} |
42 | |
43 | # All these RTL objects needs common headers (tbc) |
44 | ${BUILD_RTL}: tm.h insn-modes.h insn-modes-inline.h gtype-desc.h insn-constants.h |
45 | # All these programs use the RTL reader ($(BUILD_RTL)). |
46 | ${NO_RTL}: ${BUILD_RTL} |
47 | # All these programs use the MD reader |
48 | ${NO_MD}: ${BUILD_MD} |
49 | # All these programs need to report errors. |
50 | ${NO_PROGERR}: ${BUILD_ERRORS} |
51 | |
52 | .for f in ${genprogrtl} |
53 | gen${f}.nx: ${BUILD_RTL} |
54 | .endfor |
55 | |
56 | .for f in ${genprogmd} |
57 | gen${f}.nx: ${BUILD_MD} |
58 | .endfor |
59 | |
60 | .for f in ${genprogerr} |
61 | gen${f}.nx: ${BUILD_ERRORS} |
62 | .endfor |
63 | |
64 | .for f in ${genprog} |
65 | GENTOOLS+= gen${f}.nx |
66 | .endfor |
67 | |
68 | # For some reason, gcov-iov is an oddball |
69 | GENTOOLS+= gcov-iov.nx |
70 | NO_LIST+= gcov-iov.no |
71 | |
72 | gengtype.nx: ${BUILD_GTYPE} |
73 | genmatch.nx: hash-table.no vec.no |
74 | gencfn-macros.nx: hash-table.no vec.no ggc-none.no |
75 | |
76 | .for f in ${GENTOOLS} |
77 | $f: ${f:.nx=.no} ${BUILD_LIBS_${f:R}} ${BUILD_LIBS} |
78 | ${NXCXX} ${NXCXXFLAGS:N-flto} ${NXLDFLAGS} ${.ALLSRC:M*.n[oa]} \ |
79 | ${NXLD_${f:R}} -o ${.TARGET} |
80 | .endfor |
81 | |
82 | .for nofile in ${NO_LIST} |
83 | ${nofile}: ${nofile:.no=.c} |
84 | ${NXCXX} ${NXCXXFLAGS:N-flto} -c ${.IMPSRC} -o ${.TARGET} |
85 | .endfor |
86 | |
87 | gencheck.no: tm.h insn-constants.h |
88 | gencondmd.no: insn-constants.h |
89 | read-md.no: insn-modes.h insn-modes-inline.h |
90 | gencfn-macros.no: insn-modes.h gtype-desc.h |
91 | |
92 | MD_DEPS= ${GCCDIR}/gcc/common.md ${md_file} |
93 | MD_DEPS_PLUS= ${MD_DEPS} insn-conditions.md |
94 | |
95 | _MIC: .USE |
96 | ${MIC} ${.TARGET}.tmp ${.TARGET} |
97 | _PL: .USE |
98 | ${.OBJDIR}/${.ALLSRC:M*.nx} > ${.TARGET}.tmp |
99 | ${MIC} ${.TARGET}.tmp ${.TARGET} |
100 | _MD: .USE |
101 | ${.OBJDIR}/${.ALLSRC:M*.nx} ${MD_DEPS} > ${.TARGET}.tmp |
102 | ${MIC} ${.TARGET}.tmp ${.TARGET} |
103 | |
104 | simple_rtl_generated_h= insn-attr.h insn-attr-common.h insn-codes.h \ |
105 | insn-config.h insn-flags.h insn-target-def.h |
106 | simple_rtl_generated_c= insn-automata.c insn-emit.c insn-extract.c \ |
107 | insn-output.c insn-peep.c insn-recog.c |
108 | |
109 | simple_generated_h= $(simple_rtl_generated_h) insn-constants.h |
110 | simple_generated_c= $(simple_rtl_generated_c) insn-enums.c insn-preds.c |
111 | |
112 | .for f in ${simple_rtl_generated_h} ${simple_rtl_generated_c} |
113 | . for generator in gen${f:R:S/^insn-//}.nx |
114 | $f: ${generator} ${MD_DEPS_PLUS} _MIC |
115 | ${.OBJDIR}/${generator} ${MD_DEPS_PLUS} > ${.TARGET}.tmp |
116 | . endfor |
117 | .endfor |
118 | |
119 | insn-modes.h: genmodes.nx _MIC |
120 | ${.OBJDIR}/${.ALLSRC:M*.nx} -h > ${.TARGET}.tmp |
121 | insn-modes-inline.h: genmodes.nx _MIC |
122 | ${.OBJDIR}/${.ALLSRC:M*.nx} -i > ${.TARGET}.tmp |
123 | gtyp-input.list: _MIC |
124 | rm -f ${.TARGET}.tmp |
125 | for f in ${GTFILES}; do \ |
126 | echo "$$f" >> ${.TARGET}.tmp; \ |
127 | done |
128 | gtype.state: gengtype.nx gtyp-input.list ${GTFILES:N[*]} _MIC |
129 | ${.OBJDIR}/${.ALLSRC:M*.nx} -S ${GCCDIR}/gcc -I ${.ALLSRC:M*.list} \ |
130 | -w gtype.state.tmp |
131 | gtype-desc.c gtype-desc.h: gengtype.nx gtype.state |
132 | ${.OBJDIR}/${.ALLSRC:M*.nx} -r gtype.state |
133 | genrtl.h: gengenrtl.nx _MIC |
134 | ${.OBJDIR}/${.ALLSRC:M*.nx} > ${.TARGET}.tmp |
135 | min-insn-modes.c: genmodes.nx _MIC |
136 | ${.OBJDIR}/${.ALLSRC:M*.nx} -m > ${.TARGET}.tmp |
137 | tm-preds.h: genpreds.nx ${MD_DEPS} _MIC |
138 | ${.OBJDIR}/${.ALLSRC:M*.nx} -h ${MD_DEPS} > ${.TARGET}.tmp |
139 | tm-constrs.h: genpreds.nx ${MD_DEPS} _MIC |
140 | ${.OBJDIR}/${.ALLSRC:M*.nx} -c ${MD_DEPS} > ${.TARGET}.tmp |
141 | case-cfn-macros.h: gencfn-macros.nx _MIC |
142 | ${.OBJDIR}/${.ALLSRC:M*.nx} -c > ${.TARGET}.tmp |
143 | cfn-operators.pd: gencfn-macros.nx _MIC |
144 | ${.OBJDIR}/${.ALLSRC:M*.nx} -o > ${.TARGET}.tmp |
145 | insn-constants.h: genconstants.nx ${MD_DEPS} _MD |
146 | insn-enums.c: genenums.nx ${MD_DEPS} _MD |
147 | insn-preds.c: genpreds.nx ${MD_DEPS} _MD |
148 | gencondmd.c: genconditions.nx ${MD_DEPS} tm-preds.h tm-constrs.h _MD |
149 | insn-conditions.md: gencondmd.nx _PL |
150 | insn-modes.c: genmodes.nx _PL |
151 | tree-check.h: gencheck.nx _PL |
152 | gcov-iov.h: gcov-iov.nx BASE-VER _MIC |
153 | ${.OBJDIR}/${.ALLSRC:M*.nx} '${GCCCOMPLETEVER}' '' > ${.TARGET}.tmp |
154 | target-hooks-def.h: genhooks.nx _MIC |
155 | ${.OBJDIR}/${.ALLSRC:M*.nx} "Target Hook" > ${.TARGET}.tmp |
156 | common/common-target-hooks-def.h: genhooks.nx _MIC |
157 | ${.OBJDIR}/${.ALLSRC:M*.nx} "Common Target Hook" > ${.TARGET}.tmp |
158 | c-family/c-target-hooks-def.h: genhooks.nx _MIC |
159 | ${.OBJDIR}/${.ALLSRC:M*.nx} "C Target Hook" > ${.TARGET}.tmp |
160 | stamp-opinit: genopinit.nx ${MD_DEPS_PLUS} |
161 | ${.OBJDIR}/${.ALLSRC:M*.nx} ${.ALLSRC:M*.md} \ |
162 | -hinsn-opinit.h.tmp -cinsn-opinit.c.tmp |
163 | ${MIC} insn-opinit.h.tmp insn-opinit.h |
164 | ${MIC} insn-opinit.c.tmp insn-opinit.c |
165 | touch stamp-opinit |
166 | stamp-tabs: genattrtab.nx ${MD_DEPS_PLUS} |
167 | ${.OBJDIR}/${.ALLSRC:M*.nx} ${.ALLSRC:M*.md} \ |
168 | -Ainsn-attrtab.c.tmp -Dinsn-dfatab.c.tmp \ |
169 | -Linsn-latencytab.c.tmp |
170 | ${MIC} insn-attrtab.c.tmp insn-attrtab.c |
171 | ${MIC} insn-dfatab.c.tmp insn-dfatab.c |
172 | ${MIC} insn-latencytab.c.tmp insn-latencytab.c |
173 | touch stamp-tabs |
174 | gimple-match.c: genmatch.nx match.pd cfn-operators.pd gimple-match-head.c _MIC |
175 | ${.OBJDIR}/${.ALLSRC:M*.nx} --gimple ${GCCDIR}/gcc/match.pd \ |
176 | > ${.TARGET}.tmp |
177 | generic-match.c: genmatch.nx match.pd cfn-operators.pd generic-match-head.c _MIC |
178 | ${.OBJDIR}/${.ALLSRC:M*.nx} --generic ${GCCDIR}/gcc/match.pd \ |
179 | > ${.TARGET}.tmp |
180 | genmatch.c hash-table.c: gtype-desc.h |
181 | |
182 | pass-instances.def: ${GCCDIR}/gcc/passes.def $(PASSES_EXTRA) |
183 | /usr/bin/awk -f ${GCCDIR}/gcc/gen-pass-instances.awk \ |
184 | ${.ALLSRC} > ${.TARGET} |
185 | |
186 | # XXX plain cpp(1) safe? also /usr/bin/awk? |
b1eee65c |
187 | # XXX^2 cpp(1) as clang-cpp in traditional-cpp mode does not expand "FOO (blah)" |
188 | NXCCCPP?= ${NXCC} -E -P |
2233c95b |
189 | params.list: ${GCCDIR}/gcc/params-list.h ${GCCDIR}/gcc/params.def |
b1eee65c |
190 | ${NXCCCPP} ${GCCDIR}/gcc/params-list.h | sed 's/^#.*//;/^$$/d' \ |
2233c95b |
191 | > tmp-params.list |
192 | ${MIC} tmp-params.list params.list |
193 | |
194 | params.options: ${GCCDIR}/gcc/params-options.h ${GCCDIR}/gcc/params.def |
b1eee65c |
195 | ${NXCCCPP} ${GCCDIR}/gcc/params-options.h | sed 's/^#.*//;/^$$/d' \ |
2233c95b |
196 | > tmp-params.options |
197 | ${MIC} tmp-params.options params.options |
198 | |
199 | # This is gold, don't ask. |
200 | gengtype-lex.c: gengtype-lex.l ${LEX_HEAD} |
201 | ${LEX} ${LFLAGS} -o${.TARGET}.tmp ${.IMPSRC} |
202 | cat ${LEX_HEAD} ${.TARGET}.tmp > ${.TARGET} |
203 | |
204 | GENFILES= ${simple_generated_h} ${simple_generated_c} \ |
205 | tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \ |
206 | tm-preds.h tm-constrs.h \ |
207 | gtype-desc.c gtype-desc.h gcov-iov.h target-hooks-def.h \ |
208 | common/common-target-hooks-def.h pass-instances.def \ |
209 | c-family/c-target-hooks-def.h min-insn-modes.c \ |
210 | insn-modes.c insn-constants.h insn-conditions.md \ |
211 | gencondmd.c gimple-match.c generic-match.c \ |
212 | case-cfn-macros.h cfn-operators.pd \ |
213 | params.list params.options \ |
214 | stamp-opinit stamp-tabs |
215 | |
216 | CLEANFILES+= ${GENTOOLS} ${NO_LIST} |
217 | CLEANFILES+= gengtype-lex.c gengtype-lex.c.tmp |
218 | CLEANFILES+= ${GENFILES} gtyp-input.list gtype.state |
219 | CLEANFILES+= gt-* gtype-*.h pass-instances.def |
220 | CLEANFILES+= insn-opinit.[ch] insn-*tab.c |
221 | CLEANFILES+= params.list params.options tmp-params.list tmp-params.options |
222 | CLEANDIRS+= common c-family |
223 | |
224 | dossier: |
225 | mkdir -p common c-family |
226 | |
11900578 |
227 | .if defined(LIBGCC_ONLY) |
228 | GENLIBGCC= ${GENTOOLS:Mgenconstants*} ${GENTOOLS:Mgenmodes*} \ |
229 | ${GENTOOLS:Mgcov-iov*} \ |
230 | ${GENFILES:Minsn-constants.h} ${GENFILES:Minsn-modes.h} \ |
231 | ${GENFILES:Mgcov-iov.h} |
232 | genfiles: dossier ${GENLIBGCC} |
233 | .else |
2233c95b |
234 | genfiles: dossier ${GENTOOLS} ${GENFILES} |
11900578 |
235 | .endif |
2233c95b |
236 | depend all: genfiles |
237 | |
238 | .include <bsd.obj.mk> |
239 | .include <bsd.dep.mk> |
4d637376 |
240 | .include <bsd.sys.mk> |