Makefile revision 146910
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 146910 2005-06-03 04:21:04Z kan $ 2 3# 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. 8# 9 10# 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. 14# 15CFLAGS+= -I. 16 17.include "../Makefile.inc" 18 19.PATH: ${GCCDIR} ${GCCDIR}/f 20 21CFLAGS+= -DGENERATOR_FILE 22 23# 24#----------------------------------------------------------------------- 25# Build 'pocket' libiberty exclusively for build tools use. 26 27LIBIBERTY_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 31LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} 32 33SRCS+= ${LIBIBERTY_SRCS} 34 35LIBIBERTY=libiberty.a 36${LIBIBERTY}: ${LIBIBERTY_OBJS} 37 @rm -f ${.TARGET} 38 @${AR} cq ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` 39 ${RANLIB} ${.TARGET} 40CLEANFILES+= ${LIBIBERTY} 41 42# 43#----------------------------------------------------------------------- 44# options 45OPTION_FILES=${GCCDIR}/f/lang.opt ${GCCDIR}/c.opt ${GCCDIR}/common.opt 46 47.ORDER: options.h options.c 48options.h options.c: opts.sh ${OPTION_FILES} 49 /bin/sh ${GCCDIR}/opts.sh mv options.c options.h ${OPTION_FILES} 50 51 52GENSRCS+= options.c options.h 53CLEANFILES+= options.c options.h 54 55#----------------------------------------------------------------------- 56# insn-* gunk 57 58.for F in attr codes config flags constants 59insn-$F.h: gen$F ${MD_FILE} 60 ./gen$F ${MD_FILE} > insn-$F.h 61GENSRCS+= insn-$F.h 62.endfor 63 64.for F in conditions 65insn-$F.c: gen$F ${MD_FILE} 66 ./gen$F ${MD_FILE} > insn-$F.c 67GENSRCS+= insn-$F.c 68.endfor 69 70GENSRCS+= gen-time-stamp 71gen-time-stamp: genattr genattrtab genconditions genconstants genemit \ 72 genextract gengtype genopinit genoutput genpeep genrecog 73 touch ${.TARGET} 74 75.for F in attr codes config emit extract flags opinit output peep recog 76gen$F: gen$F.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \ 77 read-rtl.o insn-conditions.o min-insn-modes.o errors.o ${LIBIBERTY} 78 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 79 80GENSRCS+= gen$F.c 81CLEANFILES+= gen$F 82.endfor 83 84# 85# genattrtab needs more complex build rule 86# 87genattrtab : genattrtab.o rtl.o print-rtl.o bitmap.o gensupport.o ggc-none.o \ 88 read-rtl.o insn-conditions.o genautomata.o varray.o min-insn-modes.o \ 89 errors.o ${LIBIBERTY} 90 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm 91 92GENSRCS+= genattrtab.c 93CLEANFILES+= genattrtab 94 95# 96# genconstants and genconditions cannot depend on insn-conditions.o 97# they should be liked with dummy-conditions.o stubs instead 98# 99.for F in constants conditions 100gen$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} 101 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 102 103GENSRCS+= gen$F.c 104CLEANFILES+= gen$F 105.endfor 106 107.for F in modes check genrtl preds 108gen$F: gen$F.o errors.o ${LIBIBERTY} 109 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 110 111GENSRCS+= gen$F.c 112CLEANFILES+= gen$F 113.endfor 114 115.ORDER: genrtl.c genrtl.h 116genrtl.c genrtl.h: gengenrtl 117 ./gengenrtl > genrtl.c 118 ./gengenrtl -h > genrtl.h 119 120GENSRCS+= genrtl.c genrtl.h 121 122SRCS+= bitmap.c dummy-conditions.c errors.c genautomata.c gensupport.c \ 123 ggc-none.c print-rtl.c read-rtl.c rtl.c varray.c 124 125#----------------------------------------------------------------------- 126# insn modes stuff. 127 128.ORDER: insn-modes.c insn-modes.h 129insn-modes.h: genmodes 130 ./genmodes -h > insn-modes.h 131 132insn-modes.c: genmodes 133 ./genmodes > insn-modes.c 134 135min-insn-modes.c: genmodes 136 ./genmodes -m > min-insn-modes.c 137 138GENSRCS+= insn-modes.c min-insn-modes.c insn-modes.h 139 140#----------------------------------------------------------------------- 141# Common parser stuff. 142 143tree-check.h: gencheck 144 ./gencheck > ${.TARGET} 145GENSRCS+= tree-check.h 146 147#----------------------------------------------------------------------- 148# Predicates stuff. 149 150tm-preds.h: genpreds 151 ./genpreds > ${.TARGET} 152GENSRCS+= tm-preds.h 153 154#----------------------------------------------------------------------- 155# Gengtype 156 157gengtype-lex.c : gengtype-lex.l 158 ${LEX} -t ${.ALLSRC} | \ 159 sed 's/^\(char msg\[\];\)/yyconst \1/' > ${.TARGET} 160 161.ORDER: gengtype-yacc.c gengtype-yacc.h 162gengtype-yacc.c gengtype-yacc.h: gengtype-yacc.y 163 ${YACC} -d -o gengtype-yacc.c ${.ALLSRC} 164 165GENSRCS+= gengtype-yacc+%DIKED.c gengtype-yacc.h gengtype-lex.c 166CLEANFILES+= gengtype-yacc.c 167 168gengtype-yacc+%DIKED.c: gengtype-yacc.c 169 cat ${.ALLSRC} > ${.TARGET} 170 sed -e "s/xmalloc/malloc/g" \ 171 -e "s/xrealloc/realloc/g" \ 172 -e "s/malloc/xmalloc/g" \ 173 -e "s/realloc/xrealloc/g" \ 174 ${.ALLSRC} > ${.TARGET} 175 176gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o ${LIBIBERTY} 177 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 178 179GENSRCS+= gengtype.c 180CLEANFILES+= gengtype 181 182gengtype-lex.o: gengtype-yacc.h 183 184.ORDER: gtype-desc.c gtype-desc.h 185gtype-desc.c gtype-desc.h: gtype-time-stamp 186 @true 187 188GENSRCS+= gtype-time-stamp 189gtype-time-stamp: gengtype ${GTFILES} 190 ./gengtype 191 touch ${.TARGET} 192 193GENSRCS+= gtype-desc.c gtype-desc.h 194CLEANFILES+= gt-*.h gtype-*.h 195 196# 197#----------------------------------------------------------------------- 198# Fortran build tools 199 200.if !defined(NO_FORTRAN) 201gen-time-stamp: fini 202fini: fini.o ${LIBIBERTY} 203 ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} 204SRCS+= fini.c 205CLEANFILES+= fini 206.endif 207 208#----------------------------------------------------------------------- 209# Determine content of variables used by the target/host config files 210 211# 212# The list of headers to go into tm.h 213# 214.if ${TARGET_ARCH} == "amd64" 215TARGET_INC= i386/biarch64.h 216.endif 217TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h 218.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64" 219TARGET_INC+= ${GCC_CPU}/unix.h 220TARGET_INC+= ${GCC_CPU}/att.h 221.endif 222.if ${TARGET_ARCH} != "alpha" 223TARGET_INC+= dbxelf.h 224TARGET_INC+= elfos.h 225.endif 226TARGET_INC+= freebsd-native.h 227TARGET_INC+= freebsd-spec.h 228TARGET_INC+= freebsd.h 229.if ${TARGET_ARCH} == "alpha" 230TARGET_INC+= ${GCC_CPU}/elf.h 231.endif 232.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64" 233.if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h) 234TARGET_INC+= ${GCC_CPU}/sysv4.h 235.endif 236.endif 237TARGET_INC+= ${GCC_CPU}/freebsd.h 238.if ${TARGET_ARCH} == "amd64" 239TARGET_INC+= ${GCC_CPU}/x86-64.h 240TARGET_INC+= ${GCC_CPU}/freebsd64.h 241TARGET_INC+= freebsd64-fix.h 242.endif 243.if ${TARGET_ARCH} == "powepc" 244TARGET_INC+= altivec-defs.h 245.endif 246TARGET_INC+= defaults.h 247 248# 249# Use TARGET_INC as a template and build a list of target specific 250# include files for gengtype to scan 251# 252GCONFIG_H= ${.CURDIR}/auto-host.h 253 254.for H in ${TARGET_INC} 255.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} 256.if exists($D/$H) 257GCONFIG_H+= $D/$H 258.endif 259.endfor 260.endfor 261 262# 263# Define some variables to make blocks copied from Makefile.in happy 264# 265srcdir= ${GCCDIR} 266HASHTAB_H= ${GCCDIR}/hashtab.h 267SPLAY_TREE_H= ${GCCDIR}/splay-tree.h 268out_file= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.c 269GTFILES_SRCDIR= ${GCCDIR} 270 271# 272# Copied unchanged from gcc/Makefile.in 273# 274GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h $(srcdir)/cpplib.h \ 275 $(GCONFIG_H) $(HASHTAB_H) $(SPLAY_TREE_H) \ 276 $(srcdir)/bitmap.h $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \ 277 $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(srcdir)/hashtable.h \ 278 $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h \ 279 $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ 280 $(srcdir)/c-common.h $(srcdir)/c-tree.h \ 281 $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ 282 $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \ 283 $(srcdir)/dojump.c \ 284 $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ 285 $(srcdir)/fold-const.c $(srcdir)/function.c \ 286 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ 287 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \ 288 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \ 289 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \ 290 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \ 291 $(out_file) 292 293# 294# Build a list of frontend directories to look into 295# 296GTFILES_LANG_DIR_NAMES= 297 298.if !defined(NO_CXX) 299GTFILES_LANG_DIR_NAMES+= cp 300.endif 301 302.if !defined(NO_OBJC) 303GTFILES_LANG_DIR_NAMES+= objc 304.endif 305 306.if !defined(NO_FORTRAN) 307GTFILES_LANG_DIR_NAMES+= f 308.endif 309 310# 311# Build a list of language specific files for gengtype 312# 313.for L in ${GTFILES_LANG_DIR_NAMES} c 314.if exists(${GCCDIR}/$L-config-lang.in) 315# Source the language config file 316L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' 317.else 318L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' 319.endif 320.for F in ${L_GTFILES} 321GTFILES_FILES+= $F 322GTFILES_LANGS+= $L 323.endfor 324.endfor 325GTFILES+= ${GTFILES_FILES} 326 327#----------------------------------------------------------------------- 328# the host/target compiler config. 329 330COMMONHDRS= bconfig.h config.h configargs.h gencheck.h multilib.h \ 331 specs.h safe-ctype.h tconfig.h tm.h tm_p.h gcov-iov.h \ 332 gtyp-gen.h 333GENSRCS+= ${COMMONHDRS} 334 335MFILE?= ${.CURDIR}/Makefile 336${COMMONHDRS}: ${MFILE} 337 338configargs.h: 339 echo 'static const char configuration_arguments[] =' > ${.TARGET} 340 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} 341 echo 'static const char thread_model[] = "posix";' >> ${.TARGET} 342 echo 'static const struct {' >> ${.TARGET} 343 echo ' const char *name, *value;' >> ${.TARGET} 344 echo '} configure_default_options[] = {' >> ${.TARGET} 345 echo ' { "NULL", "NULL" } };' >> ${.TARGET} 346 347tconfig.h: 348 echo '#ifndef GCC_TCONFIG_H' > ${.TARGET} 349 echo '#define GCC_TCONFIG_H' >> ${.TARGET} 350 echo '#ifdef IN_GCC' >> ${.TARGET} 351 echo '# include "ansidecl.h"' >> ${.TARGET} 352 echo '#endif' >> ${.TARGET} 353 echo '#define USED_FOR_TARGET' >> ${.TARGET} 354 echo '#endif /* GCC_TCONFIG_H */' >> ${.TARGET} 355 356bconfig.h: 357 echo '#ifndef GCC_BCONFIG_H' > ${.TARGET} 358 echo '#define GCC_BCONFIG_H' >> ${.TARGET} 359 echo '#include "auto-host.h"' >> ${.TARGET} 360.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 361 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 362.endif 363 echo '#ifdef IN_GCC' >> ${.TARGET} 364 echo '# include "ansidecl.h"' >> ${.TARGET} 365 echo '#endif' >> ${.TARGET} 366 echo '#endif /* GCC_BCONFIG_H */' >> ${.TARGET} 367 368gencheck.h: 369 echo '#include "cp/cp-tree.def"' > ${.TARGET} 370 echo '#include "objc/objc-tree.def"' >> ${.TARGET} 371 372multilib.h: 373 echo 'static const char *const multilib_raw[] = { \ 374 "aout maout;", "elf !maout;", NULL };' > ${.TARGET} 375 echo 'static const char *const multilib_matches_raw[] = { \ 376 "maout maout;", "melf melf;", NULL };' >> ${.TARGET} 377 echo 'static const char *multilib_extra = "";' >> ${.TARGET} 378 echo 'static const char *multilib_options = "";'>> ${.TARGET} 379 echo 'static const char *const multilib_exclusions_raw[] = { \ 380 NULL };' >> ${.TARGET} 381 382specs.h: 383 echo '#include "cp/lang-specs.h"' > ${.TARGET} 384 echo '#include "f/lang-specs.h"' >> ${.TARGET} 385 echo '#include "objc/lang-specs.h"' >> ${.TARGET} 386 387config.h: bconfig.h 388 echo '#include <bconfig.h>' > ${.TARGET} 389 390tm.h: 391 echo '#ifndef GCC_TM_H' > ${.TARGET} 392 echo '#define GCC_TM_H' >> ${.TARGET} 393.if defined(TARGET_CPU_DEFAULT) 394 echo "#define TARGET_CPU_DEFAULT (${TARGET_CPU_DEFAULT})" >> ${.TARGET} 395.endif 396 echo '#ifdef IN_GCC' >> ${.TARGET} 397.for H in ${TARGET_INC} 398 echo '#include "$H"' >> ${.TARGET} 399.endfor 400 echo '#if !defined GENERATOR_FILE && !defined USED_FOR_TARGET' >> ${.TARGET} 401 echo '# include "insn-constants.h"' >> ${.TARGET} 402 echo '# include "insn-flags.h"' >> ${.TARGET} 403 echo '#endif' >> ${.TARGET} 404 echo '#endif' >> ${.TARGET} 405.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 406 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 407.endif 408 echo '#endif /* GCC_TM_H */' >> ${.TARGET} 409 410tm_p.h: 411 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET} 412 echo '#include "tm-preds.h"' >> ${.TARGET} 413 414safe-ctype.h: 415 echo '#include <ctype.h>' > ${.TARGET} 416.for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \ 417 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL 418 echo '#define ${Z} ${Z:L}' >> ${.TARGET} 419.endfor 420 echo "#define ISIDST(x) \ 421 ((x) == '_' || isalpha(x))" >> ${.TARGET} 422 echo "#define ISIDNUM(x) \ 423 (isdigit(x) || ISIDST(x))" >> ${.TARGET} 424 echo "#define IS_VSPACE(x) \ 425 ((x) == '\n' || (x) == '\r')" >> ${.TARGET} 426 echo "#define IS_NVSPACE(x) \ 427 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET} 428 echo "#define IS_SPACE_OR_NUL(x) \ 429 (isspace(x) || (x) == '\0')" >> ${.TARGET} 430 431gtyp-gen.h: 432 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} 433 echo "static const char *srcdir = " >> ${.TARGET} 434 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} 435 echo "static const char *lang_files[] = {" >> ${.TARGET} 436.for F in ${GTFILES_FILES} 437 echo "\"$F\", " >> ${.TARGET} 438.endfor 439 echo "NULL};" >> ${.TARGET} 440 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET} 441.for F in ${GTFILES_LANGS} 442 echo "\"$F\", " >> ${.TARGET} 443.endfor 444 echo "NULL};" >> ${.TARGET} 445 echo "static const char *all_files[] = {" >> ${.TARGET} 446.for F in ${GTFILES} 447 echo "\"$F\", " >> ${.TARGET} 448.endfor 449 echo "NULL};" >> ${.TARGET} 450 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET} 451.for F in ${GTFILES_LANG_DIR_NAMES} 452 echo "\"$F\", " >> ${.TARGET} 453.endfor 454 echo "NULL};" >> ${.TARGET} 455 456gcov-iov.h: 457 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x33303470)" >> ${.TARGET} 458 459#----------------------------------------------------------------------- 460# General things. 461 462SRCS+= ${GENSRCS} 463CLEANFILES+= ${GENSRCS} 464 465all: ${SRCS} 466 467.include <bsd.prog.mk> 468 469#----------------------------------------------------------------------- 470# Fixups. 471 472# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 473# define PROG because we have multiple programs. 474# 475OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 476CLEANFILES+= ${OBJS} 477 478.if !exists(${DEPENDFILE}) 479# Fudge pre-dependfile dependencies of objects in much the same way as 480# bsd.prog.mk would do if we defined PROG. 481 482${OBJS}: ${COMMONHDRS} 483 484dummy-conditions.o: 485gencheck.o: 486genmodes.o: 487 488genpreds.o: insn-modes.h 489genconstants.o: insn-modes.h genrtl.h 490gengtype.o: insn-modes.h genrtl.h gtyp-gen.h 491rtl.o: insn-modes.h gtype-desc.h genrtl.h 492bitmap.o: insn-modes.h gtype-desc.h genrtl.h 493ggc-none.o: gtype-desc.h 494gensupport.o: insn-modes.h genrtl.h 495varray.o: gtype-desc.h 496genautomata.o: insn-modes.h genrtl.h 497genconditions.o: insn-modes.h genrtl.h 498gencodes.o: insn-modes.h genrtl.h 499genconfig.o: insn-modes.h genrtl.h 500print-rtl.o: insn-modes.h genrtl.h tm-preds.h tree-check.h 501read-rtl.o: insn-modes.h genrtl.h 502genattr.o: insn-modes.h genrtl.h 503genemit.o: insn-modes.h genrtl.h 504genflags.o: insn-modes.h genrtl.h 505genopinit.o: insn-modes.h genrtl.h 506genoutput.o: insn-modes.h genrtl.h 507genpeep.o: insn-modes.h genrtl.h 508genrecog.o: insn-modes.h genrtl.h 509genextract.o: genrtl.h insn-config.h 510genattrtab.o: insn-modes.h gtype-desc.h genrtl.h 511genrtl.o: insn-modes.h genrtl.h gtype-desc.h 512 513insn-conditions.o: insn-constants.h tm-preds.h 514insn-modes.o: insn-modes.h 515min-insn-modes.o: insn-modes.h 516gtype-desc.o: insn-modes.h insn-config.h insn-codes.h tree-check.h 517 518.endif 519