Makefile revision 133956
1# $FreeBSD: head/gnu/usr.bin/cc/cc_tools/Makefile 133956 2004-08-18 13:21:40Z ru $ 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)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ 284 $(srcdir)/fold-const.c $(srcdir)/function.c \ 285 $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ 286 $(srcdir)/profile.c $(srcdir)/ra-build.c $(srcdir)/regclass.c \ 287 $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c $(srcdir)/langhooks.c \ 288 $(srcdir)/sdbout.c $(srcdir)/stmt.c $(srcdir)/stor-layout.c \ 289 $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c $(out_file) 290 291# 292# Build a list of frontend directories to look into 293# 294GTFILES_LANG_DIR_NAMES= 295 296.if !defined(NO_CXX) 297GTFILES_LANG_DIR_NAMES+= cp 298.endif 299 300.if !defined(NO_OBJC) 301GTFILES_LANG_DIR_NAMES+= objc 302.endif 303 304.if !defined(NO_FORTRAN) 305GTFILES_LANG_DIR_NAMES+= f 306.endif 307 308# 309# Build a list of language specific files for gengtype 310# 311.for L in ${GTFILES_LANG_DIR_NAMES} c 312.if exists(${GCCDIR}/$L-config-lang.in) 313# Source the language config file 314L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' 315.else 316L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' 317.endif 318.for F in ${L_GTFILES} 319GTFILES_FILES+= $F 320GTFILES_LANGS+= $L 321.endfor 322.endfor 323GTFILES+= ${GTFILES_FILES} 324 325#----------------------------------------------------------------------- 326# the host/target compiler config. 327 328COMMONHDRS= bconfig.h config.h configargs.h gencheck.h multilib.h \ 329 specs.h safe-ctype.h tconfig.h tm.h tm_p.h gcov-iov.h \ 330 gtyp-gen.h 331GENSRCS+= ${COMMONHDRS} 332 333MFILE?= ${.CURDIR}/Makefile 334${COMMONHDRS}: ${MFILE} 335 336configargs.h: 337 echo 'static const char configuration_arguments[] =' > ${.TARGET} 338 echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} 339 echo 'static const char thread_model[] = "posix";' >> ${.TARGET} 340 echo 'static const struct {' >> ${.TARGET} 341 echo ' const char *name, *value;' >> ${.TARGET} 342 echo '} configure_default_options[] = {' >> ${.TARGET} 343 echo ' { "NULL", "NULL" } };' >> ${.TARGET} 344 345tconfig.h: 346 echo '#ifndef GCC_TCONFIG_H' > ${.TARGET} 347 echo '#define GCC_TCONFIG_H' >> ${.TARGET} 348 echo '#ifdef IN_GCC' >> ${.TARGET} 349 echo '# include "ansidecl.h"' >> ${.TARGET} 350 echo '#endif' >> ${.TARGET} 351 echo '#define USED_FOR_TARGET' >> ${.TARGET} 352 echo '#endif /* GCC_TCONFIG_H */' >> ${.TARGET} 353 354bconfig.h: 355 echo '#ifndef GCC_BCONFIG_H' > ${.TARGET} 356 echo '#define GCC_BCONFIG_H' >> ${.TARGET} 357 echo '#include "auto-host.h"' >> ${.TARGET} 358.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 359 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 360.endif 361 echo '#ifdef IN_GCC' >> ${.TARGET} 362 echo '# include "ansidecl.h"' >> ${.TARGET} 363 echo '#endif' >> ${.TARGET} 364 echo '#endif /* GCC_BCONFIG_H */' >> ${.TARGET} 365 366gencheck.h: 367 echo '#include "cp/cp-tree.def"' > ${.TARGET} 368 echo '#include "objc/objc-tree.def"' >> ${.TARGET} 369 370multilib.h: 371 echo 'static const char *const multilib_raw[] = { \ 372 "aout maout;", "elf !maout;", NULL };' > ${.TARGET} 373 echo 'static const char *const multilib_matches_raw[] = { \ 374 "maout maout;", "melf melf;", NULL };' >> ${.TARGET} 375 echo 'static const char *multilib_extra = "";' >> ${.TARGET} 376 echo 'static const char *multilib_options = "";'>> ${.TARGET} 377 echo 'static const char *const multilib_exclusions_raw[] = { \ 378 NULL };' >> ${.TARGET} 379 380specs.h: 381 echo '#include "cp/lang-specs.h"' > ${.TARGET} 382 echo '#include "f/lang-specs.h"' >> ${.TARGET} 383 echo '#include "objc/lang-specs.h"' >> ${.TARGET} 384 385config.h: bconfig.h 386 echo '#include <bconfig.h>' > ${.TARGET} 387 388tm.h: 389 echo '#ifndef GCC_TM_H' > ${.TARGET} 390 echo '#define GCC_TM_H' >> ${.TARGET} 391.if defined(TARGET_CPU_DEFAULT) 392 echo "#define TARGET_CPU_DEFAULT (${TARGET_CPU_DEFAULT})" >> ${.TARGET} 393.endif 394 echo '#ifdef IN_GCC' >> ${.TARGET} 395.for H in ${TARGET_INC} 396 echo '#include "$H"' >> ${.TARGET} 397.endfor 398 echo '#if !defined GENERATOR_FILE && !defined USED_FOR_TARGET' >> ${.TARGET} 399 echo '# include "insn-constants.h"' >> ${.TARGET} 400 echo '# include "insn-flags.h"' >> ${.TARGET} 401 echo '#endif' >> ${.TARGET} 402 echo '#endif' >> ${.TARGET} 403.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) 404 echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} 405.endif 406 echo '#endif /* GCC_TM_H */' >> ${.TARGET} 407 408tm_p.h: 409 echo '#include "${GCC_CPU}/${GCC_CPU}-protos.h"' >> ${.TARGET} 410 echo '#include "tm-preds.h"' >> ${.TARGET} 411 412safe-ctype.h: 413 echo '#include <ctype.h>' > ${.TARGET} 414.for Z in TOUPPER TOLOWER ISDIGIT ISXDIGIT ISUPPER ISLOWER ISALPHA ISALNUM \ 415 ISSPACE ISPUNCT ISGRAPH ISBLANK ISPRINT ISCNTRL 416 echo '#define ${Z} ${Z:L}' >> ${.TARGET} 417.endfor 418 echo "#define ISIDST(x) \ 419 ((x) == '_' || isalpha(x))" >> ${.TARGET} 420 echo "#define ISIDNUM(x) \ 421 (isdigit(x) || ISIDST(x))" >> ${.TARGET} 422 echo "#define IS_VSPACE(x) \ 423 ((x) == '\n' || (x) == '\r')" >> ${.TARGET} 424 echo "#define IS_NVSPACE(x) \ 425 (!IS_VSPACE(x) && (isspace(x) || (x) == '\0'))" >> ${.TARGET} 426 echo "#define IS_SPACE_OR_NUL(x) \ 427 (isspace(x) || (x) == '\0')" >> ${.TARGET} 428 429gtyp-gen.h: 430 echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} 431 echo "static const char *srcdir = " >> ${.TARGET} 432 echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} 433 echo "static const char *lang_files[] = {" >> ${.TARGET} 434.for F in ${GTFILES_FILES} 435 echo "\"$F\", " >> ${.TARGET} 436.endfor 437 echo "NULL};" >> ${.TARGET} 438 echo "static const char *langs_for_lang_files[] = {" >> ${.TARGET} 439.for F in ${GTFILES_LANGS} 440 echo "\"$F\", " >> ${.TARGET} 441.endfor 442 echo "NULL};" >> ${.TARGET} 443 echo "static const char *all_files[] = {" >> ${.TARGET} 444.for F in ${GTFILES} 445 echo "\"$F\", " >> ${.TARGET} 446.endfor 447 echo "NULL};" >> ${.TARGET} 448 echo "static const char *lang_dir_names[] = { \"c\", " >> ${.TARGET} 449.for F in ${GTFILES_LANG_DIR_NAMES} 450 echo "\"$F\", " >> ${.TARGET} 451.endfor 452 echo "NULL};" >> ${.TARGET} 453 454gcov-iov.h: 455 echo "#define GCOV_VERSION ((gcov_unsigned_t)0x33303470)" >> ${.TARGET} 456 457#----------------------------------------------------------------------- 458# General things. 459 460SRCS+= ${GENSRCS} 461CLEANFILES+= ${GENSRCS} 462 463all: ${SRCS} 464 465.include <bsd.prog.mk> 466 467#----------------------------------------------------------------------- 468# Fixups. 469 470# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't 471# define PROG because we have multiple programs. 472# 473OBJS+= ${SRCS:N*.h:R:S/$/.o/g} 474CLEANFILES+= ${OBJS} 475 476.if !exists(${DEPENDFILE}) 477# Fudge pre-dependfile dependencies of objects in much the same way as 478# bsd.prog.mk would do if we defined PROG. 479 480${OBJS}: ${COMMONHDRS} 481 482dummy-conditions.o: 483gencheck.o: 484genmodes.o: 485 486genpreds.o: insn-modes.h 487genconstants.o: insn-modes.h genrtl.h 488gengtype.o: insn-modes.h genrtl.h gtyp-gen.h 489rtl.o: insn-modes.h gtype-desc.h genrtl.h 490bitmap.o: insn-modes.h gtype-desc.h genrtl.h 491ggc-none.o: gtype-desc.h 492gensupport.o: insn-modes.h genrtl.h 493varray.o: gtype-desc.h 494genautomata.o: insn-modes.h genrtl.h 495genconditions.o: insn-modes.h genrtl.h 496gencodes.o: insn-modes.h genrtl.h 497genconfig.o: insn-modes.h genrtl.h 498print-rtl.o: insn-modes.h genrtl.h tm-preds.h tree-check.h 499read-rtl.o: insn-modes.h genrtl.h 500genattr.o: insn-modes.h genrtl.h 501genemit.o: insn-modes.h genrtl.h 502genflags.o: insn-modes.h genrtl.h 503genopinit.o: insn-modes.h genrtl.h 504genoutput.o: insn-modes.h genrtl.h 505genpeep.o: insn-modes.h genrtl.h 506genrecog.o: insn-modes.h genrtl.h 507genextract.o: genrtl.h insn-config.h 508genattrtab.o: insn-modes.h gtype-desc.h genrtl.h 509genrtl.o: insn-modes.h genrtl.h gtype-desc.h 510 511insn-conditions.o: insn-constants.h tm-preds.h 512insn-modes.o: insn-modes.h 513min-insn-modes.o: insn-modes.h 514gtype-desc.o: insn-modes.h insn-config.h insn-codes.h tree-check.h 515 516.endif 517