7 .include "../Makefile.inc"
8 # Some of the logic needed in here is defined in Makefile.hdrs as it is shared
10 .include "Makefile.hdrs"
13 CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H
15 # Override LIBIBERTY set by Makefile.inc, We use our own for
17 LIBIBERTY= libiberty.a
19 .PATH: ${GCCDIR} ${GCCLIB}/libiberty
21 #-----------------------------------------------------------------------
22 # Determine content of variables used by the target/host config files
25 # The list of headers to go into tm.h
27 .for H in ${TARGET_INC}
28 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
30 TARGET_INC_FILES+= $D/$H
39 CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \
40 ${GCCLIB}/libcpp/include/cpplib.h
41 SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h
42 CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h
43 HASHTAB_H= ${GCCLIB}/include/hashtab.h
44 SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h
45 out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c
46 tm_file_list= ${TARGET_INC_FILES}
47 host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h
48 GTFILES_SRCDIR= ${srcdir}
50 # Copied unchanged from gcc/Makefile.in
51 GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
52 $(CPP_ID_DATA_H) $(host_xm_file_list) \
53 $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
54 $(srcdir)/coverage.c $(srcdir)/rtl.h \
55 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
56 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
57 $(srcdir)/ipa-reference.h $(srcdir)/output.h \
58 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \
59 $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \
60 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
61 $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \
62 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
63 $(srcdir)/dojump.c $(srcdir)/tree-profile.c \
64 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
65 $(srcdir)/function.c $(srcdir)/except.h \
66 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
67 $(srcdir)/profile.c $(srcdir)/regclass.c \
68 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \
69 $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \
70 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
71 $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \
72 $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \
73 $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \
74 $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
75 $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
76 $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
77 $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
78 $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
79 $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
80 $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
81 $(srcdir)/tree-ssa-structalias.c \
82 $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \
83 $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \
85 # The list of frontend directories to look into
86 GTFILES_LANG_DIR_NAMES=
89 GTFILES_LANG_DIR_NAMES+= cp
92 # The list of language specific files for gengtype
93 .for L in ${GTFILES_LANG_DIR_NAMES} c
94 .if exists(${GCCDIR}/$L-config-lang.in)
95 # Source the language config file
96 L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
98 L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
100 .for F in ${L_GTFILES}
105 GTFILES+= ${GTFILES_FILES}
108 # Tree definition files.
112 .if ${MK_CXX} != "no"
113 TREE_DEF_FILES+= cp/cp-tree.def
116 #-----------------------------------------------------------------------
117 # Build rules for header files and generator tools
121 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
122 HEADERS="auto-host.h ansidecl.h" \
124 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
127 CLEANFILES+= cs-config.h
131 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
132 HEADERS="auto-host.h ansidecl.h" \
134 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET}
135 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
136 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
140 CLEANFILES+= cs-bconfig.h
144 CLEANFILES+= cs-tconfig.h
147 GENONLY+= optionlist options.h options.c
149 # Target machine config
153 # Target machine protos/preds.
155 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \
156 HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \
158 /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h
161 CLEANFILES+= cs-tm_p.h
164 gencheck.h: ${TREE_DEF_FILES}
165 .for F in ${TREE_DEF_FILES}
166 echo "#include \"$F\"" >> ${.TARGET}
173 # Source header for gtyp generator.
174 gtyp-gen.h: ${GTFILES}
175 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
176 echo "static const char * const srcdir = " >> ${.TARGET}
177 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
178 echo "static const char * const lang_files[] = {" >> ${.TARGET}
179 .for F in ${GTFILES_FILES}
180 echo "\"$F\", " >> ${.TARGET}
182 echo "NULL};" >> ${.TARGET}
183 echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET}
184 .for F in ${GTFILES_LANGS}
185 echo "\"$F\", " >> ${.TARGET}
187 echo "NULL};" >> ${.TARGET}
188 echo "static const char * const all_files[] = {" >> ${.TARGET}
190 echo "\"$F\", " >> ${.TARGET}
192 echo "NULL};" >> ${.TARGET}
193 echo "static const char * const lang_dir_names[] = {" >> ${.TARGET}
194 .for F in c ${GTFILES_LANG_DIR_NAMES}
195 echo "\"$F\", " >> ${.TARGET}
197 echo "NULL};" >> ${.TARGET}
201 # Version header for gcov
204 # Multilib config file
206 .if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64"
207 echo 'static const char *const multilib_raw[] = { \
209 "64:../lib m64 !m32;", \
210 "32:../lib32 !m64 m32;", NULL };' > ${.TARGET}
211 echo 'static const char *multilib_options = "m64/m32";' >> ${.TARGET}
212 echo 'static const char *const multilib_matches_raw[] = { \
213 "m64 m64;", "m32 m32;", NULL };' >> ${.TARGET}
215 echo 'static const char *const multilib_raw[] = { \
216 ". ;", NULL };' > ${.TARGET}
217 echo 'static const char *multilib_options = "";' >> ${.TARGET}
218 echo 'static const char *const multilib_matches_raw[] = { \
219 NULL };' >> ${.TARGET}
221 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
222 echo 'static const char *const multilib_exclusions_raw[] = { \
223 NULL };' >> ${.TARGET}
228 echo 'static const char configuration_arguments[] =' > ${.TARGET}
229 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET}
230 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
231 echo 'static const struct {' >> ${.TARGET}
232 echo ' const char *name, *value;' >> ${.TARGET}
233 echo '} configure_default_options[] = {' >> ${.TARGET}
234 echo ' { "NULL", "NULL" } };' >> ${.TARGET}
236 GENSRCS+= configargs.h
238 # Language spec files
240 echo '#include "cp/lang-specs.h"' > ${.TARGET}
245 echo '#include "sys/types.h"' > ${.TARGET}
246 echo '#include "sys/stdint.h"' >> ${.TARGET}
251 GENSRCS+= gthr-default.h
258 gengtype-lex.c: gengtype-lex.l
259 flex -ogengtype-lex.c ${.ALLSRC}
261 gengtype-yacc.h: gengtype-yacc.y
262 yacc -d -o gengtype-yacc.c ${.ALLSRC}
264 gengtype-yacc.c: gengtype-yacc.h .NOMETA
266 gengtype-yacc+%DIKED.c: gengtype-yacc.c
267 cat ${.ALLSRC} > ${.TARGET}
268 sed -e "s/xmalloc/malloc/g" \
269 -e "s/xrealloc/realloc/g" \
270 -e "s/malloc/xmalloc/g" \
271 -e "s/realloc/xrealloc/g" \
272 ${.ALLSRC} > ${.TARGET}
274 GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c
275 CLEANFILES+= gengtype-yacc.c
277 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \
279 ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
281 gtype-desc.h: gengtype
282 ${BTOOLSPATH:U.}/gengtype
285 gtype-desc.c: gtype-desc.h
287 GENONLY+= gtype-desc.c gtype-desc.h
288 CLEANFILES+= gt-*.h gtype-*.h
293 .for F in check checksum genrtl modes
294 gen$F: gen$F.o errors.o ${LIBIBERTY}
295 ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
298 .for F in attr attrtab automata codes conditions config constants emit \
299 extract flags opinit output peep preds recog
300 gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \
301 gensupport.o print-rtl.o errors.o ${LIBIBERTY}
302 ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
305 gencondmd: gencondmd.o
306 ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
309 # Generated .md files.
311 insn-conditions.md: gencondmd
312 ${BTOOLSPATH:U.}/gencondmd > ${.TARGET}
313 GENSRCS+= insn-conditions.md
316 # Generated header files.
320 insn-$F.h: gen$F ${MD_FILE}
321 ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET}
325 .for F in attr codes config flags
326 insn-$F.h: gen$F ${MD_FILE} insn-conditions.md
327 ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
331 # Header files with irregular names.
333 ${BTOOLSPATH:U.}/gengenrtl -h > ${.TARGET}
337 ${BTOOLSPATH:U.}/genpreds -h ${MD_FILE} > ${.TARGET}
340 tm-constrs.h: genpreds
341 ${BTOOLSPATH:U.}/genpreds -c ${MD_FILE} > ${.TARGET}
342 GENSRCS+= tm-constrs.h
344 tree-check.h: gencheck
345 ${BTOOLSPATH:U.}/gencheck > ${.TARGET}
346 GENSRCS+= tree-check.h
348 insn-modes.h: genmodes
349 ${BTOOLSPATH:U.}/genmodes -h > ${.TARGET}
350 GENSRCS+= insn-modes.h
353 # Generated source files.
355 .for F in attrtab automata emit extract opinit output peep preds recog
356 insn-$F.c: gen$F ${MD_FILE} insn-conditions.md
357 ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET}
362 insn-$F.c: gen$F ${MD_FILE}
363 ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET}
367 # Source files with irregular names.
368 insn-modes.c: genmodes
369 ${BTOOLSPATH:U.}/genmodes > ${.TARGET}
370 GENONLY+= insn-modes.c
372 min-insn-modes.c: genmodes
373 ${BTOOLSPATH:U.}/genmodes -m > ${.TARGET}
374 GENSRCS+= min-insn-modes.c
377 ${BTOOLSPATH:U.}/gengenrtl > ${.TARGET}
380 gencondmd.c: genconditions ${MD_FILE}
381 ${BTOOLSPATH:U.}/genconditions ${MD_FILE} > ${.TARGET}
382 GENSRCS+= gencondmd.c
384 #-----------------------------------------------------------------------
387 GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \
388 genconditions gencondmd genconfig genconstants genemit \
389 genextract genflags gengenrtl gengtype genmodes genopinit \
390 genoutput genpeep genpreds genrecog
392 ${GNTOOLS:C,$,.o,} ${GNTOOLS}: ${BUILD_TOOLS_META}
393 all: ${GNTOOLS} ${GENSRCS} ${GENONLY}
395 beforedepend: ${GENONLY}
398 #-----------------------------------------------------------------------
399 # Build 'pocket' libiberty exclusively for build tools use.
401 LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \
402 dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \
403 hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \
404 partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \
405 xmalloc.c xmemdup.c xstrdup.c xstrerror.c
406 LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g}
408 .for _src in ${LIBIBERTY_SRCS}
409 ${_src:R:S/$/.o/}: ${_src} ${BUILD_TOOLS_META}
410 ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC}
413 ${LIBIBERTY}: ${LIBIBERTY_OBJS} ${BUILD_TOOLS_META}
415 @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q`
417 CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS}
420 #-----------------------------------------------------------------------
423 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
424 # define PROG because we have multiple programs.
426 SRCS= errors.c genattr.c genattrtab.c \
427 genautomata.c gencheck.c genchecksum.c gencodes.c \
428 genconditions.c genconfig.c genconstants.c genemit.c \
429 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \
430 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \
431 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \
435 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
436 GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g}
437 ${OBJS} ${GENOBJS}: ${BUILD_TOOLS_META}
438 CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS}
440 #-----------------------------------------------------------------------
441 # Manual dependencies.
442 .include "Makefile.dep"
444 .include <bsd.prog.mk>