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