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