4 # This could probably be merged with ../cc_int/Makefile, but bsd.lib.mk
5 # is such a !@#!*#% nightmare because of how it reprograms the dependencies,
6 # suffix rules, SRCS, etc. It's easiest to cheat by using bsd.prog.mk and
7 # SRCS to get dependencies.
11 # ../Makefile.inc will put an absolute path to our objdir in CFLAGS.
12 # Prevent mkdep from using it, so that we don't have to give rules for
13 # aliases of generated headers.
17 .include "../Makefile.inc"
19 .PATH: ${GCCDIR} ${GCCDIR}/f
21 CFLAGS+= -DGENERATOR_FILE
24 #-----------------------------------------------------------------------
25 # Build 'pocket' libiberty exclusively for build tools use.
27 LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \
28 dyn-string.c fibheap.c getpwd.c getruntime.c hashtab.c hex.c \
29 lbasename.c make-temp-file.c md5.c obstack.c partition.c pex-unix.c \
30 physmem.c splay-tree.c xexit.c xmalloc.c xmemdup.c xstrdup.c xstrerror.c
31 LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g}
33 SRCS+= ${LIBIBERTY_SRCS}
36 ${LIBIBERTY}: ${LIBIBERTY_OBJS}
38 @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q`
40 CLEANFILES+= ${LIBIBERTY}
43 #-----------------------------------------------------------------------
45 OPTION_FILES=${GCCDIR}/f/lang.opt ${GCCDIR}/c.opt ${GCCDIR}/common.opt
47 .ORDER: options.h options.c
48 options.h options.c: opts.sh ${OPTION_FILES}
49 /bin/sh ${GCCDIR}/opts.sh mv options.c options.h ${OPTION_FILES}
51 GENSRCS+= options.c options.h
52 CLEANFILES+= options.c options.h
54 #-----------------------------------------------------------------------
57 .for F in attr codes config flags constants
58 insn-$F.h: gen$F ${MD_FILE}
59 ./gen$F ${MD_FILE} > insn-$F.h
64 insn-$F.c: gen$F ${MD_FILE}
65 ./gen$F ${MD_FILE} > insn-$F.c
69 GENSRCS+= gen-time-stamp
70 gen-time-stamp: genattr genattrtab genconditions genconstants genemit \
71 genextract gengtype genopinit genoutput genpeep genrecog
74 .for F in attr codes config emit extract flags opinit output peep recog
75 gen$F: gen$F.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \
76 read-rtl.o insn-conditions.o min-insn-modes.o errors.o ${LIBIBERTY}
77 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
84 # genattrtab needs more complex build rule
86 genattrtab : genattrtab.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \
87 read-rtl.o insn-conditions.o genautomata.o varray.o min-insn-modes.o \
89 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm
91 GENSRCS+= genattrtab.c
92 CLEANFILES+= genattrtab
95 # genconstants and genconditions cannot depend on insn-conditions.o
96 # they should be liked with dummy-conditions.o stubs instead
98 .for F in constants conditions
99 gen$F: gen$F.o rtl.o bitmap.o gensupport.o ggc-none.o read-rtl.o dummy-conditions.o min-insn-modes.o errors.o ${LIBIBERTY}
100 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
106 .for F in modes check genrtl preds
107 gen$F: gen$F.o errors.o ${LIBIBERTY}
108 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
114 .ORDER: genrtl.c genrtl.h
115 genrtl.c genrtl.h: gengenrtl
116 ./gengenrtl > genrtl.c
117 ./gengenrtl -h > genrtl.h
119 GENSRCS+= genrtl.c genrtl.h
121 SRCS+= bitmap.c dummy-conditions.c errors.c genautomata.c gensupport.c \
122 ggc-none.c print-rtl.c read-rtl.c rtl.c varray.c
124 #-----------------------------------------------------------------------
127 .ORDER: insn-modes.c insn-modes.h
128 insn-modes.h: genmodes
129 ./genmodes -h > insn-modes.h
131 insn-modes.c: genmodes
132 ./genmodes > insn-modes.c
134 min-insn-modes.c: genmodes
135 ./genmodes -m > min-insn-modes.c
137 GENSRCS+= insn-modes.c min-insn-modes.c insn-modes.h
139 #-----------------------------------------------------------------------
140 # Common parser stuff.
142 tree-check.h: gencheck
143 ./gencheck > ${.TARGET}
144 GENSRCS+= tree-check.h
146 #-----------------------------------------------------------------------
150 ./genpreds > ${.TARGET}
153 #-----------------------------------------------------------------------
156 gengtype-lex.c : gengtype-lex.l
157 ${LEX} -t ${.ALLSRC} | \
158 sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET}
160 .ORDER: gengtype-yacc.c gengtype-yacc.h
161 gengtype-yacc.c gengtype-yacc.h: gengtype-yacc.y
162 ${YACC} -d -o gengtype-yacc.c ${.ALLSRC}
164 GENSRCS+= gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c
165 CLEANFILES+= gengtype-yacc.c
167 gengtype-yacc+%DIKED.c: gengtype-yacc.c
168 cat ${.ALLSRC} > ${.TARGET}
169 sed -e "s/xmalloc/malloc/g" \
170 -e "s/xrealloc/realloc/g" \
171 -e "s/malloc/xmalloc/g" \
172 -e "s/realloc/xrealloc/g" \
173 ${.ALLSRC} > ${.TARGET}
175 gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o ${LIBIBERTY}
176 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
179 CLEANFILES+= gengtype
181 gengtype-lex.o: gengtype-yacc.h
183 .ORDER: gtype-desc.c gtype-desc.h
184 gtype-desc.c gtype-desc.h: gtype-time-stamp
187 GENSRCS+= gtype-time-stamp
188 gtype-time-stamp: gengtype ${GTFILES}
192 GENSRCS+= gtype-desc.c gtype-desc.h
193 CLEANFILES+= gt-*.h gtype-*.h
196 #-----------------------------------------------------------------------
197 # Fortran build tools
199 .if !defined(NO_FORTRAN)
201 fini: fini.o ${LIBIBERTY}
202 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC}
207 #-----------------------------------------------------------------------
208 # Determine content of variables used by the target/host config files
211 # The list of headers to go into tm.h
213 .if ${TARGET_ARCH} == "amd64"
214 TARGET_INC= i386/biarch64.h
216 .if ${TARGET_ARCH} != "arm"
217 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
219 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
220 TARGET_INC+= ${GCC_CPU}/unix.h
221 TARGET_INC+= ${GCC_CPU}/att.h
223 .if ${TARGET_ARCH} != "alpha"
224 TARGET_INC+= dbxelf.h
227 TARGET_INC+= freebsd-native.h
228 TARGET_INC+= freebsd-spec.h
229 TARGET_INC+= freebsd.h
230 .if ${TARGET_ARCH} == "alpha"
231 TARGET_INC+= ${GCC_CPU}/elf.h
233 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
234 .if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h)
235 TARGET_INC+= ${GCC_CPU}/sysv4.h
238 .if ${TARGET_ARCH} == "arm"
239 TARGET_INC+= ${GCC_CPU}/elf.h
240 TARGET_INC+= ${GCC_CPU}/aout.h
241 TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h
242 . if defined(TARGET_BIG_ENDIAN)
243 CFLAGS+= -DTARGET_ENDIAN_DEFAULT=ARM_FLAG_BIG_END
246 TARGET_INC+= ${GCC_CPU}/freebsd.h
247 .if ${TARGET_ARCH} == "amd64"
248 TARGET_INC+= ${GCC_CPU}/x86-64.h
249 TARGET_INC+= ${GCC_CPU}/freebsd64.h
251 .if ${TARGET_ARCH} == "powepc"
252 TARGET_INC+= altivec-defs.h
254 TARGET_INC+= defaults.h
257 # Use TARGET_INC as a template and build a list of target specific
258 # include files for gengtype to scan
260 GCONFIG_H= ${.CURDIR}/auto-host.h
262 .for H in ${TARGET_INC}
263 .for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR}
271 # Define some variables to make blocks copied from Makefile.in happy
274 HASHTAB_H= ${GCCDIR}/hashtab.h
275 SPLAY_TREE_H= ${GCCDIR}/splay-tree.h
276 out_file= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.c
277 GTFILES_SRCDIR= ${GCCDIR}
280 # Copied unchanged from gcc/Makefile.in
282 GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \
283 $(GCONFIG_H) $(HASHTAB_H) $(SPLAY_TREE_H) \
284 $(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \
285 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \
286 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h \
287 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \
288 $(srcdir)/c-common.h $(srcdir)/c-tree.h \
289 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
290 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \
292 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \
293 $(srcdir)/fold-const.c $(srcdir)/function.c \
294 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \
295 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \
296 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \
297 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \
298 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \
302 # Build a list of frontend directories to look into
304 GTFILES_LANG_DIR_NAMES=
307 GTFILES_LANG_DIR_NAMES+= cp
310 .if !defined(NO_OBJC)
311 GTFILES_LANG_DIR_NAMES+= objc
314 .if !defined(NO_FORTRAN)
315 GTFILES_LANG_DIR_NAMES+= f
319 # Build a list of language specific files for gengtype
321 .for L in ${GTFILES_LANG_DIR_NAMES} c
322 .if exists(${GCCDIR}/$L-config-lang.in)
323 # Source the language config file
324 L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles'
326 L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles'
328 .for F in ${L_GTFILES}
333 GTFILES+= ${GTFILES_FILES}
335 #-----------------------------------------------------------------------
336 # the host/target compiler config.
338 COMMONHDRS= bconfig.h config.h configargs.h gencheck.h multilib.h \
339 specs.h safe-ctype.h tconfig.h tm.h tm_p.h gcov-iov.h \
341 GENSRCS+= ${COMMONHDRS}
343 MFILE?= ${.CURDIR}/Makefile
344 ${COMMONHDRS}: ${MFILE}
347 echo 'static const char configuration_arguments[] =' > ${.TARGET}
348 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET}
349 echo 'static const char thread_model[] = "posix";' >> ${.TARGET}
350 echo 'static const struct {' >> ${.TARGET}
351 echo ' const char *name, *value;' >> ${.TARGET}
352 echo '} configure_default_options[] = {' >> ${.TARGET}
353 echo ' { "NULL", "NULL" } };' >> ${.TARGET}
356 echo '#ifndef GCC_TCONFIG_H' > ${.TARGET}
357 echo '#define GCC_TCONFIG_H' >> ${.TARGET}
358 echo '#ifdef IN_GCC' >> ${.TARGET}
359 echo '# include "ansidecl.h"' >> ${.TARGET}
360 echo '#endif' >> ${.TARGET}
361 echo '#define USED_FOR_TARGET' >> ${.TARGET}
362 echo '#endif /* GCC_TCONFIG_H */' >> ${.TARGET}
365 echo '#ifndef GCC_BCONFIG_H' > ${.TARGET}
366 echo '#define GCC_BCONFIG_H' >> ${.TARGET}
367 echo '#include "auto-host.h"' >> ${.TARGET}
368 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
369 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
371 echo '#ifdef IN_GCC' >> ${.TARGET}
372 echo '# include "ansidecl.h"' >> ${.TARGET}
373 echo '#endif' >> ${.TARGET}
374 echo '#endif /* GCC_BCONFIG_H */' >> ${.TARGET}
377 echo '#include "cp/cp-tree.def"' > ${.TARGET}
378 echo '#include "objc/objc-tree.def"' >> ${.TARGET}
381 echo 'static const char *const multilib_raw[] = { \
382 "aout maout;", "elf !maout;", NULL };' > ${.TARGET}
383 echo 'static const char *const multilib_matches_raw[] = { \
384 "maout maout;", "melf melf;", NULL };' >> ${.TARGET}
385 echo 'static const char *multilib_extra = "";' >> ${.TARGET}
386 echo 'static const char *multilib_options = "";'>> ${.TARGET}
387 echo 'static const char *const multilib_exclusions_raw[] = { \
388 NULL };' >> ${.TARGET}
391 echo '#include "cp/lang-specs.h"' > ${.TARGET}
392 echo '#include "f/lang-specs.h"' >> ${.TARGET}
393 echo '#include "objc/lang-specs.h"' >> ${.TARGET}
396 echo '#include <bconfig.h>' > ${.TARGET}
399 echo '#ifndef GCC_TM_H' > ${.TARGET}
400 echo '#define GCC_TM_H' >> ${.TARGET}
401 .if defined(TARGET_CPU_DEFAULT)
402 echo "#define TARGET_CPU_DEFAULT (${TARGET_CPU_DEFAULT})" >> ${.TARGET}
404 echo '#ifdef IN_GCC' >> ${.TARGET}
405 .for H in ${TARGET_INC}
406 echo '#include "$H"' >> ${.TARGET}
408 echo '#if !defined GENERATOR_FILE && !defined USED_FOR_TARGET' >> ${.TARGET}
409 echo '# include "insn-constants.h"' >> ${.TARGET}
410 echo '# include "insn-flags.h"' >> ${.TARGET}
411 echo '#endif' >> ${.TARGET}
412 echo '#endif' >> ${.TARGET}
413 .if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def)
414 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET}
416 echo '#endif /* GCC_TM_H */' >> ${.TARGET}
419 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET}
420 echo '#include "tm-preds.h"' >> ${.TARGET}
423 echo '#include <ctype.h>' > ${.TARGET}
424 .for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \
425 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL
426 echo '#define ${Z} ${Z:L}' >> ${.TARGET}
428 echo "#define ISIDST(x) \
429 ((x) == '_' || isalpha(x))" >> ${.TARGET}
430 echo "#define ISIDNUM(x) \
431 (isdigit(x) || ISIDST(x))" >> ${.TARGET}
432 echo "#define IS_VSPACE(x) \
433 ((x) == '\n' || (x) == '\r')" >> ${.TARGET}
434 echo "#define IS_NVSPACE(x) \
435 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET}
436 echo "#define IS_SPACE_OR_NUL(x) \
437 (isspace(x) || (x) == '\0')" >> ${.TARGET}
440 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET}
441 echo "static const char *srcdir = " >> ${.TARGET}
442 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET}
443 echo "static const char *lang_files[] = {" >> ${.TARGET}
444 .for F in ${GTFILES_FILES}
445 echo "\"$F\", " >> ${.TARGET}
447 echo "NULL};" >> ${.TARGET}
448 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET}
449 .for F in ${GTFILES_LANGS}
450 echo "\"$F\", " >> ${.TARGET}
452 echo "NULL};" >> ${.TARGET}
453 echo "static const char *all_files[] = {" >> ${.TARGET}
455 echo "\"$F\", " >> ${.TARGET}
457 echo "NULL};" >> ${.TARGET}
458 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET}
459 .for F in ${GTFILES_LANG_DIR_NAMES}
460 echo "\"$F\", " >> ${.TARGET}
462 echo "NULL};" >> ${.TARGET}
465 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x33303470)" >> ${.TARGET}
467 #-----------------------------------------------------------------------
471 CLEANFILES+= ${GENSRCS}
475 .include <bsd.prog.mk>
477 #-----------------------------------------------------------------------
480 # Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't
481 # define PROG because we have multiple programs.
483 OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
486 .if !exists(${DEPENDFILE})
487 # Fudge pre-dependfile dependencies of objects in much the same way as
488 # bsd.prog.mk would do if we defined PROG.
490 ${OBJS}: ${COMMONHDRS}
496 genpreds.o: insn-modes.h
497 genconstants.o: insn-modes.h genrtl.h
498 gengtype.o: insn-modes.h genrtl.h gtyp-gen.h
499 rtl.o: insn-modes.h gtype-desc.h genrtl.h
500 bitmap.o: insn-modes.h gtype-desc.h genrtl.h
501 ggc-none.o: gtype-desc.h
502 gensupport.o: insn-modes.h genrtl.h
503 varray.o: gtype-desc.h
504 genautomata.o: insn-modes.h genrtl.h
505 genconditions.o: insn-modes.h genrtl.h
506 gencodes.o: insn-modes.h genrtl.h
507 genconfig.o: insn-modes.h genrtl.h
508 print-rtl.o: insn-modes.h genrtl.h tm-preds.h tree-check.h
509 read-rtl.o: insn-modes.h genrtl.h
510 genattr.o: insn-modes.h genrtl.h
511 genemit.o: insn-modes.h genrtl.h
512 genflags.o: insn-modes.h genrtl.h
513 genopinit.o: insn-modes.h genrtl.h
514 genoutput.o: insn-modes.h genrtl.h
515 genpeep.o: insn-modes.h genrtl.h
516 genrecog.o: insn-modes.h genrtl.h
517 genextract.o: genrtl.h insn-config.h
518 genattrtab.o: insn-modes.h gtype-desc.h genrtl.h
519 genrtl.o: insn-modes.h genrtl.h gtype-desc.h
521 insn-conditions.o: insn-constants.h tm-preds.h
522 insn-modes.o: insn-modes.h
523 min-insn-modes.o: insn-modes.h
524 gtype-desc.o: insn-modes.h insn-config.h insn-codes.h tree-check.h