Makefile revision 298218
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 298218 2016-04-18 18:13:58Z bdrewery $ 2 3.include <src.opts.mk> 4 5CFLAGS+= -I. 6 7.include "../Makefile.inc" 8# Some of the logic needed in here is defined in Makefile.hdrs as it is shared 9# with gnu/lib. 10.include "Makefile.hdrs" 11 12CFLAGS+= -g 13CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H 14 15# Override LIBIBERTY set by Makefile.inc, We use our own for 16# build tools. 17LIBIBERTY= libiberty.a 18 19.PATH: ${GCCDIR} ${GCCLIB}/libiberty 20 21#----------------------------------------------------------------------- 22# Determine content of variables used by the target/host config files 23 24# 25# The list of headers to go into tm.h 26# 27.for H in ${TARGET_INC} 28.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} 29.if exists($D/$H) 30TARGET_INC_FILES+= $D/$H 31.endif 32.endfor 33.endfor 34 35# 36# gtyp includes. 37# 38srcdir= ${GCCDIR} 39CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \ 40 ${GCCLIB}/libcpp/include/cpplib.h 41SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h 42CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h 43HASHTAB_H= ${GCCLIB}/include/hashtab.h 44SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h 45out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c 46tm_file_list= ${TARGET_INC_FILES} 47host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h 48GTFILES_SRCDIR= ${srcdir} 49 50# Copied unchanged from gcc/Makefile.in 51GTFILES = $(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) \ 84 85# The list of frontend directories to look into 86GTFILES_LANG_DIR_NAMES= 87 88.if ${MK_CXX} != "no" 89GTFILES_LANG_DIR_NAMES+= cp 90.endif 91 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 96L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' 97.else 98L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' 99.endif 100.for F in ${L_GTFILES} 101GTFILES_FILES+= $F 102GTFILES_LANGS+= $L 103.endfor 104.endfor 105GTFILES+= ${GTFILES_FILES} 106 107# 108# Tree definition files. 109# 110TREE_DEF_FILES= 111 112.if ${MK_CXX} != "no" 113TREE_DEF_FILES+= cp/cp-tree.def 114.endif 115 116#----------------------------------------------------------------------- 117# Build rules for header files and generator tools 118 119# Host config 120config.h: 121 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 122 HEADERS="auto-host.h ansidecl.h" \ 123 DEFINES="" \ 124 /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} 125 126GENSRCS+= config.h 127CLEANFILES+= cs-config.h 128 129# Build config 130bconfig.h: 131 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 132 HEADERS="auto-host.h ansidecl.h" \ 133 DEFINES="" \ 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} 137.endif 138 139GENSRCS+= bconfig.h 140CLEANFILES+= cs-bconfig.h 141 142# tconfig.h 143GENSRCS+= tconfig.h 144CLEANFILES+= cs-tconfig.h 145 146# Options 147GENONLY+= optionlist options.h options.c 148 149# Target machine config 150GENSRCS+= tm.h 151CLEANFILES+= cs-tm.h 152 153# Target machine protos/preds. 154tm_p.h: 155 TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ 156 HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \ 157 DEFINES="" \ 158 /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h 159 160GENSRCS+= tm_p.h 161CLEANFILES+= cs-tm_p.h 162 163# gencheck 164gencheck.h: ${TREE_DEF_FILES} 165.for F in ${TREE_DEF_FILES} 166 echo "#include \"$F\"" >> ${.TARGET} 167.endfor 168 touch ${.TARGET} 169 170GENSRCS+= gencheck.h 171 172 173# Source header for gtyp generator. 174gtyp-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} 181.endfor 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} 186.endfor 187 echo "NULL};" >> ${.TARGET} 188 echo "static const char * const all_files[] = {" >> ${.TARGET} 189.for F in ${GTFILES} 190 echo "\"$F\", " >> ${.TARGET} 191.endfor 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} 196.endfor 197 echo "NULL};" >> ${.TARGET} 198 199GENSRCS+= gtyp-gen.h 200 201# Version header for gcov 202GENSRCS+= gcov-iov.h 203 204# Multilib config file 205multilib.h: 206.if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64" 207 echo 'static const char *const multilib_raw[] = { \ 208 ". !m64 !m32;", \ 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} 214.else 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} 220.endif 221 echo 'static const char *multilib_extra = "";' >> ${.TARGET} 222 echo 'static const char *const multilib_exclusions_raw[] = { \ 223 NULL };' >> ${.TARGET} 224 225GENSRCS+= multilib.h 226 227configargs.h: 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} 235 236GENSRCS+= configargs.h 237 238# Language spec files 239specs.h: 240 echo '#include "cp/lang-specs.h"' > ${.TARGET} 241 242GENSRCS+= specs.h 243 244gstdint.h: 245 echo '#include "sys/types.h"' > ${.TARGET} 246 echo '#include "sys/stdint.h"' >> ${.TARGET} 247 248GENSRCS+= gstdint.h 249 250# Linked headers 251GENSRCS+= gthr-default.h 252 253GENSRCS+= unwind.h 254 255# 256# gtype gunk 257# 258gengtype-lex.c: gengtype-lex.l 259 flex -ogengtype-lex.c ${.ALLSRC} 260 261gengtype-yacc.h: gengtype-yacc.y 262 yacc -d -o gengtype-yacc.c ${.ALLSRC} 263 264gengtype-yacc.c: gengtype-yacc.h 265 266gengtype-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} 273 274GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c 275CLEANFILES+= gengtype-yacc.c 276 277gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \ 278 ${LIBIBERTY} 279 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 280 281gtype-desc.h: gengtype 282 ./gengtype 283 touch ${.TARGET} 284 285gtype-desc.c: gtype-desc.h 286 287GENONLY+= gtype-desc.c gtype-desc.h 288CLEANFILES+= gt-*.h gtype-*.h 289 290# 291# Generator tools. 292# 293.for F in check checksum genrtl modes 294gen$F: gen$F.o errors.o ${LIBIBERTY} 295 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 296.endfor 297 298.for F in attr attrtab automata codes conditions config constants emit \ 299 extract flags opinit output peep preds recog 300gen$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} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm 303.endfor 304 305gencondmd: gencondmd.o 306 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 307 308# 309# Generated .md files. 310# 311insn-conditions.md: gencondmd 312 ./gencondmd > ${.TARGET} 313GENSRCS+= insn-conditions.md 314 315# 316# Generated header files. 317# 318 319.for F in constants 320insn-$F.h: gen$F ${MD_FILE} 321 ./gen$F ${MD_FILE} > ${.TARGET} 322GENSRCS+= insn-$F.h 323.endfor 324 325.for F in attr codes config flags 326insn-$F.h: gen$F ${MD_FILE} insn-conditions.md 327 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} 328GENSRCS+= insn-$F.h 329.endfor 330 331# Header files with irregular names. 332genrtl.h: gengenrtl 333 ./gengenrtl -h > ${.TARGET} 334GENSRCS+= genrtl.h 335 336tm-preds.h: genpreds 337 ./genpreds -h ${MD_FILE} > ${.TARGET} 338GENSRCS+= tm-preds.h 339 340tm-constrs.h: genpreds 341 ./genpreds -c ${MD_FILE} > ${.TARGET} 342GENSRCS+= tm-constrs.h 343 344tree-check.h: gencheck 345 ./gencheck > ${.TARGET} 346GENSRCS+= tree-check.h 347 348insn-modes.h: genmodes 349 ./genmodes -h > ${.TARGET} 350GENSRCS+= insn-modes.h 351 352# 353# Generated source files. 354# 355.for F in attrtab automata emit extract opinit output peep preds recog 356insn-$F.c: gen$F ${MD_FILE} insn-conditions.md 357 ./gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} 358GENONLY+= insn-$F.c 359.endfor 360 361.for F in conditions 362insn-$F.c: gen$F ${MD_FILE} 363 ./gen$F ${MD_FILE} > ${.TARGET} 364GENSRCS+= insn-$F.c 365.endfor 366 367# Source files with irregular names. 368insn-modes.c: genmodes 369 ./genmodes > ${.TARGET} 370GENONLY+= insn-modes.c 371 372min-insn-modes.c: genmodes 373 ./genmodes -m > ${.TARGET} 374GENSRCS+= min-insn-modes.c 375 376genrtl.c: gengenrtl 377 ./gengenrtl > ${.TARGET} 378GENONLY+= genrtl.c 379 380gencondmd.c: genconditions ${MD_FILE} 381 ./genconditions ${MD_FILE} > ${.TARGET} 382GENSRCS+= gencondmd.c 383 384#----------------------------------------------------------------------- 385# Build tools. 386 387GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \ 388 genconditions gencondmd genconfig genconstants genemit \ 389 genextract genflags gengenrtl gengtype genmodes genopinit \ 390 genoutput genpeep genpreds genrecog 391 392all: ${GNTOOLS} ${GENSRCS} ${GENONLY} 393beforedepend: ${GENONLY} 394 395# 396#----------------------------------------------------------------------- 397# Build 'pocket' libiberty exclusively for build tools use. 398 399LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ 400 dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ 401 hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ 402 partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ 403 xmalloc.c xmemdup.c xstrdup.c xstrerror.c 404LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} 405 406.for _src in ${LIBIBERTY_SRCS} 407${_src:R:S/$/.o/}: ${_src} 408 ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC} 409.endfor 410 411${LIBIBERTY}: ${LIBIBERTY_OBJS} 412 @rm -f ${.TARGET} 413 @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` 414 ${RANLIB} ${.TARGET} 415CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS} 416 417 418#----------------------------------------------------------------------- 419# Fixups. 420 421# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 422# define PROG because we have multiple programs. 423# 424SRCS= errors.c genattr.c genattrtab.c \ 425 genautomata.c gencheck.c genchecksum.c gencodes.c \ 426 genconditions.c genconfig.c genconstants.c genemit.c \ 427 genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \ 428 genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \ 429 gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \ 430 vec.c 431 432SRCS+= ${GENSRCS} 433OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 434GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g} 435CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS} 436 437#----------------------------------------------------------------------- 438# Manual dependencies. 439.if !exists(${DEPENDFILE}) 440.include "Makefile.dep" 441.endif 442 443.include <bsd.prog.mk> 444# DO NOT DELETE 445