1.include "../Makefile.inc"
2.include "../../Makefile.langs"
3
4NXCFLAGS+=	-DGENERATOR_FILE -I${.OBJDIR}
5NXLDLIBS+=	-lm
6
7MIC= sh ${GCCDIR}/move-if-change
8
9BUILD_LIBS=	../libiberty/libiberty.na
10BUILD_RTL= 	rtl.no \
11		read-rtl.no \
12		ggc-none.no \
13		vec.no \
14		min-insn-modes.no \
15		gensupport.no \
16		print-rtl.no
17BUILD_MD=	read-md.no
18BUILD_ERRORS=	errors.no
19
20
21${BUILD_RTL}: tm.h insn-modes.h gtype-desc.h insn-constants.h
22
23genprogrtl = attr attr-common attrtab automata codes conditions config emit \
24	     extract flags opinit output peep preds recog
25genprogmd  = $(genprogrtl) mddeps constants enums
26genprogerr = $(genprogmd) genrtl modes gtype hooks
27
28# All these programs use the RTL reader ($(BUILD_RTL)).
29${genprogrtl:S/^/gen/g:S/$/.no/g}: ${BUILD_RTL}
30# All these programs use the MD reader
31${genprogmd:S/^/gen/g:S/$/.no/g}: ${BUILD_MD}
32# All these programs need to report errors.
33${genprogerr:S/^/gen/g:S/$/.no/g}: ${BUILD_ERRORS}
34
35.for f in ${genprogrtl}
36gen${f}.nx: ${BUILD_RTL}
37.endfor
38
39.for f in ${genprogmd}
40gen${f}.nx: ${BUILD_MD}
41.endfor
42
43.for f in ${genprogerr}
44gen${f}.nx: ${BUILD_ERRORS}
45GENTOOLS+= gen${f}.nx
46.endfor
47
48gengtype.nx: gengtype-lex.no gengtype-parse.no gengtype-state.no version.no
49
50genattrtab.o ggc-none.no vec.no: gtype-desc.h
51
52GENTOOLS+= gencheck.nx gencondmd.nx gcov-iov.nx genchecksum.nx
53
54.for f in ${GENTOOLS}
55$f: ${f:.nx=.no} ${BUILD_LIBS}
56	${NXCC} ${NXCFLAGS} ${NXLDFLAGS} ${.ALLSRC:M*.n[oa]} ${NXLDLIBS} -o ${.TARGET}
57.endfor
58
59gencheck.no: tm.h insn-constants.h
60gencondmd.no: tree-check.h insn-constants.h
61
62CLEANFILES+=	${GENTOOLS} ${GENTOOLS:.nx=.no}
63CLEANFILES+=	gengtype-lex.c gengtype-lex.no gengtype-parse.no
64CLEANFILES+=	gengtype-state.no version.no
65CLEANFILES+=	${BUILD_RTL} ${BUILD_MD} ${BUILD_ERRORS}
66
67
68MD_DEPS=	${md_file}
69
70_MIC: .USE
71	${MIC} ${.TARGET}.tmp ${.TARGET}
72_PL: .USE
73	${.OBJDIR}/${.ALLSRC:M*.nx} > ${.TARGET}.tmp
74	${MIC} ${.TARGET}.tmp ${.TARGET}
75_MD: .USE
76	${.OBJDIR}/${.ALLSRC:M*.nx} ${md_file} > ${.TARGET}.tmp
77	${MIC} ${.TARGET}.tmp ${.TARGET}
78
79simple_generated_h = insn-attr.h insn-codes.h insn-config.h insn-flags.h \
80		     insn-attr-common.h
81
82simple_generated_c = insn-attrtab.c insn-automata.c insn-emit.c \
83		     insn-extract.c insn-opinit.c insn-output.c \
84		     insn-peep.c insn-recog.c
85
86.for f in ${simple_generated_h} ${simple_generated_c}
87.for p in gen${f:R:S/^insn-//}.nx
88$f: $p ${MD_DEPS} insn-conditions.md _MIC
89	${.OBJDIR}/$p ${md_file} insn-conditions.md > ${.TARGET}.tmp
90.endfor
91.endfor
92
93insn-constants.h: genconstants.nx ${MD_DEPS} _MD
94tree-check.h: gencheck.nx _PL
95gencondmd.c: genconditions.nx ${MD_DEPS} tm-preds.h tm-constrs.h _MD
96insn-conditions.md: gencondmd.nx _PL
97genrtl.c: gengenrtl.nx _PL
98genrtl.h: gengenrtl.nx _MIC
99	${.OBJDIR}/${.ALLSRC:M*.nx} -h > ${.TARGET}.tmp
100insn-modes.c: genmodes.nx _PL
101insn-modes.h: genmodes.nx _MIC
102	${.OBJDIR}/${.ALLSRC:M*.nx} -h > ${.TARGET}.tmp
103min-insn-modes.c: genmodes.nx _MIC
104	${.OBJDIR}/${.ALLSRC:M*.nx} -m > ${.TARGET}.tmp
105insn-preds.c: genpreds.nx _MD
106insn-enums.c: genenums.nx _MD
107tm-preds.h: genpreds.nx _MIC
108	${.OBJDIR}/${.ALLSRC:M*.nx} -h ${md_file} > ${.TARGET}.tmp
109tm-constrs.h: genpreds.nx _MIC
110	${.OBJDIR}/${.ALLSRC:M*.nx} -c ${md_file} > ${.TARGET}.tmp
111gtype.state: gengtype.nx gtyp-input.list ${GTFILES:N[*]} _MIC
112	${.OBJDIR}/${.ALLSRC:M*.nx} -S ${GCCDIR}/gcc -I ${.ALLSRC:M*.list} \
113	  -w gtype.state.tmp
114gtype-desc.c gtype-desc.h: gengtype.nx gtype.state
115	${.OBJDIR}/${.ALLSRC:M*.nx} -r gtype.state
116gcov-iov.h: gcov-iov.nx BASE-VER _MIC
117	${.OBJDIR}/${.ALLSRC:M*.nx} "$$(cat ${.ALLSRC:M*BASE-VER})" "" > ${.TARGET}.tmp
118target-hooks-def.h: genhooks.nx _MIC
119	${.OBJDIR}/${.ALLSRC:M*.nx} "Target Hook" > ${.TARGET}.tmp
120c-family/c-target-hooks-def.h: genhooks.nx _MIC
121	${.OBJDIR}/${.ALLSRC:M*.nx} "C Target Hook" > ${.TARGET}.tmp
122common/common-target-hooks-def.h: genhooks.nx _MIC
123	${.OBJDIR}/${.ALLSRC:M*.nx} "Common Target Hook" > ${.TARGET}.tmp
124
125gtyp-input.list: _MIC
126	rm -f ${.TARGET}.tmp
127	for f in ${GTFILES}; do \
128		echo "$$f" >> ${.TARGET}.tmp; \
129	done
130
131GENFILES= \
132	${simple_generated_h} ${simple_generated_c} \
133	insn-constants.h tree-check.h gencondmd.c insn-conditions.md \
134	genrtl.c genrtl.h insn-modes.c insn-modes.h min-insn-modes.c \
135	insn-preds.c tm-preds.h tm-constrs.h gtype-desc.c gtype-desc.h \
136	gcov-iov.h insn-enums.c target-hooks-def.h \
137	c-family/c-target-hooks-def.h \
138	common/common-target-hooks-def.h
139
140CLEANFILES+=	${GENFILES} gtyp-input.list gtype.state
141CLEANFILES+=	gt-* gtype-*.h
142CLEANDIRS+=	common c-family
143
144dossier:
145	mkdir -p common c-family
146
147genfiles: ${GENTOOLS} ${GENFILES}
148depend all: dossier genfiles
149
150.include <bsd.obj.mk>
151.include <bsd.dep.mk>
152