1# $NetBSD: Makefile,v 1.22 2014/07/06 00:21:24 joerg Exp $ 2 3LIBISPRIVATE= yes 4 5LIB= backend 6 7SRCS= ${G_OBJS:.o=.c} ${G_out_file:T} 8 9BOTH_CPPFLAGS+= -I. -I${GCCARCH} ${G_ALL_CFLAGS:M-D*} ${G_INCLUDES:M-I*:N-I.*} 10CPPFLAGS+= ${BOTH_CPPFLAGS} -DTARGET_NAME=\"${MACHINE_GNU_PLATFORM}\" 11HOST_CPPFLAGS+= ${BOTH_CPPFLAGS} -DGENERATOR_FILE 12DPSRCS+= insn-attr.h insn-codes.h insn-config.h insn-flags.h tree-check.h 13CPPFLAGS+= -I${DIST}/libgcc 14CPPFLAGS+= -I${.CURDIR}/../../lib/libgcc/libgcov/arch/${MACHINE_ARCH} 15 16CPPFLAGS.cppdefault.c+= -DPREFIX=\"/usr\" \ 17 -DNATIVE_SYSTEM_HEADER_DIR=\"${G_NATIVE_SYSTEM_HEADER_DIR}\" 18 19HOSTPROG_CXX= 1 20 21.include <bsd.lib.mk> 22 23# Force using C++ for this 24ORIGHOST_CC:= ${HOST_CC} 25HOST_CC:= ${HOST_CXX} 26CC:= ${CXX} 27CFLAGS:= ${CXXFLAGS} 28 29# Check PREPROCESSOR_DEFINES for cppbuiltin.c and cppdefault.c 30CPPFLAGS.cppbuiltin.c+= -DBASEVER="\"${BASEVER}"\" 31 32# 33# Independent generation programs. 34# 35CLEANFILES+= gengenrtl genrtl.h \ 36 gengtype gtyp-gen.h gtype-desc.c gtype-desc.h \ 37 gtype-c.h gtype-cp.h gtype-f.h gtype-objc.h \ 38 genflags genflags.h \ 39 gencheck tree-check.h \ 40 insn-preds.c genpreds tm-preds.h tm_p.h cs-tm_p.h \ 41 genmodes insn-modes.c insn-modes.h min-insn-modes.c \ 42 auto-host.h build-print-rtl.c \ 43 build-rtl.c build-errors.c build-varray.c \ 44 build-bitmap.c build-ggc-none.c \ 45 gt-*.h *.o *.lo \ 46 cs-config.h \ 47 gcov-iov gcov-iov.h \ 48 gtype-go.h gtype.state 49 50# XXX 51COPTS.varasm.c= -Wno-error 52 53# XXX Override the normal rule to use HOST_COMPILE.cc 54.c.lo: 55 ${_MKTARGET_COMPILE} 56 ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} 57 mv ${.TARGET}.o ${.TARGET} 58 59# Headers that host objects depend on (except gen*rtl*) 60HH_NORTL= ${G_tm_file_list} ${G_build_xm_include_list} 61HH= ${HH_NORTL} genrtl.h insn-modes.h 62 63# 64# Generate the various header files we need. 65# 66genrtl.h: gengenrtl 67 ${_MKTARGET_CREATE} 68 ./gengenrtl >${.TARGET} 69gengenrtl.lo: ${HH_NORTL} 70gengenrtl: gengenrtl.lo build-errors.lo 71 ${_MKTARGET_LINK} 72 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 73 74insn-preds.c: genpreds ${G_md_file} 75 ${_MKTARGET_CREATE} 76 ./genpreds ${G_md_file} >${.TARGET} 77tm-preds.h: genpreds ${G_md_file} 78 ${_MKTARGET_CREATE} 79 ./genpreds -h ${G_md_file} >${.TARGET} 80tm-constrs.h: genpreds ${G_md_file} 81 ${_MKTARGET_CREATE} 82 ./genpreds -c ${G_md_file} >${.TARGET} 83 84# be nice to generate this entirely; but difficult. 85gtyp-input.list.tmp: ${GCCARCH}/gtyp-input.list 86 sed s#SRCDIR#${DIST}# < ${.ALLSRC} > ${.TARGET} 87CLEANFILES+= gtyp-input.list.tmp 88 89# XXX 90CLEANFILES+= gtype-lto.h gtype-objcp.h tm-constrs.h 91 92gtype-desc.c: gtype-desc.h 93gtype-desc.h: gengtype gtyp-input.list.tmp 94 ${_MKTARGET_CREATE} 95 rm -f auto-host.h 96 ln -s ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/auto-host.h . 97 if [ -f ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/sysroot-suffix.h ]; then \ 98 rm -f sysroot-suffix.h; \ 99 ln -s ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/sysroot-suffix.h ; \ 100 fi 101 ./gengtype -S ${DIST}/gcc -I gtyp-input.list.tmp -w gtype.state 102 ./gengtype -r gtype.state 103 # GCC 4.8 installs gtype-state and gengtype as a plugin 104 105# gengtype is the real need for options.h 106gengtype.lo gengtype-lex.lo gengtype-parse.lo gengtype-state.lo version.lo: ${HH} gtyp-gen.h config.h options.h 107gengtype: gengtype.lo gengtype-lex.lo gengtype-parse.lo gengtype-state.lo build-errors.lo version.lo 108 ${_MKTARGET_LINK} 109 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 110 111gtyp-gen.h: Makefile 112 ${_MKTARGET_CREATE} 113 (\ 114 unset empty ; \ 115 echo "static const char *srcdir = \"$(G_GTFILES_SRCDIR)\";" ; \ 116 echo "static const char *lang_files[] = {" ; \ 117 for f in $$empty $(G_GTFILES_FILES_FILES); do echo "\"$$f\", "; done ; \ 118 echo "NULL };" ; \ 119 echo "static const char *langs_for_lang_files[] = {" ; \ 120 for f in $$empty $(G_GTFILES_FILES_LANGS); do echo "\"$$f\", "; done ; \ 121 echo "NULL };" ; \ 122 echo "static const char *all_files[] = {" ; \ 123 for f in $$empty $(G_GTFILES); do echo "\"$$f\", "; done ; \ 124 echo " NULL };" ; \ 125 echo "static const char *lang_dir_names[] = {" ; \ 126 for f in c $(G_GTFILES_LANG_DIR_NAMES); do echo "\"$$f\", "; done ; \ 127 echo "NULL };" ; \ 128 ) >${.TARGET} 129 130insn-modes.c: genmodes 131 ${_MKTARGET_CREATE} 132 ./genmodes >${.TARGET} 133insn-modes.h: genmodes 134 ${_MKTARGET_CREATE} 135 ./genmodes -h >${.TARGET} 136min-insn-modes.c: genmodes 137 ${_MKTARGET_CREATE} 138 ./genmodes -m >${.TARGET} 139genmodes.lo: ${HH_NORTL} 140genmodes: genmodes.lo build-errors.lo 141 ${_MKTARGET_LINK} 142 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 143 144gcov-iov.h: gcov-iov 145 ${_MKTARGET_CREATE} 146 ./gcov-iov "${BASEVER}" "${DEVPHASE}" >${.TARGET} 147gcov-iov.lo: ${HH_NORTL} 148gcov-iov: gcov-iov.lo 149 ${_MKTARGET_CREATE} 150 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 151 152tm_p.h: Makefile tm-preds.h 153 ${_MKTARGET_CREATE} 154 TARGET_CPU_DEFAULT="" \ 155 HEADERS="$(G_tm_p_include_list)" DEFINES="" \ 156 ${HOST_SH} ${GNUHOSTDIST}/gcc/mkconfig.sh ${.TARGET} 157 158${G_OBJS} ${G_OBJS:.o=.d}: tm_p.h # XXX crude 159 160.include "../Makefile.options" 161 162# Yuck, we have to run configure to generate this one... 163# We use ORIGHOST_CC here because GCC's ./configure expects (and 164# depends upon) it. 165CLEANFILES+= auto-build.h 166HOST_CFLAGS+= -I${.OBJDIR} 167auto-build.h: gmp.h Makefile 168 ${_MKTARGET_CREATE} 169 rm -rf .ab && \ 170 mkdir .ab && \ 171 (cd .ab && \ 172 AWK=${TOOL_AWK:Q} \ 173 CC=${ORIGHOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} \ 174 MAKE=${MAKE:Q} \ 175 CONFIG_SHELL=${HOST_SH:Q} \ 176 gcc_cv_ld=${LD} \ 177 gcc_cv_as=${AS} \ 178 ${HOST_SH} ${GNUHOSTDIST}/gcc/configure \ 179 --build=`${HOST_SH} ${GNUHOSTDIST}/config.guess` \ 180 --host=`${HOST_SH} ${GNUHOSTDIST}/config.guess` \ 181 --target=${MACHINE_GNU_PLATFORM} && \ 182 mv auto-host.h ../auto-build.h) && \ 183 rm -rf .ab 184 185# 186# These are copies of files we build for the build host that are used 187# by the genfoo programs. 188# 189 190build-rtl.c: rtl.c \ 191 ${G_RTL_H} real.h ${G_GCC_H} errors.h gtype-desc.h 192 ${_MKTARGET_CREATE} 193 rm -f build-rtl.c 194 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 195 ${GNUHOSTDIST}/gcc/rtl.c >${.TARGET} 196build-rtl.lo: ${HH} 197 198build-print-rtl.c: print-rtl.c \ 199 ${G_RTL_BASE_H} ${G_GTM_H} hard-reg-set.h 200 ${_MKTARGET_CREATE} 201 rm -f build-print-rtl.c 202 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 203 ${GNUHOSTDIST}/gcc/print-rtl.c >${.TARGET} 204build-print-rtl.lo: ${HH} 205build/print-rtl.o: print-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \ 206 $(GTM_H) $(RTL_BASE_H) 207 208 209build-bitmap.c: bitmap.c \ 210 ${G_RTL_H} flags.h ${G_BASIC_BLOCK_H} ${REGS_H} ${G_GCC_H} gtype-desc.h 211 ${_MKTARGET_CREATE} 212 rm -f build-bitmap.c 213 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 214 ${GNUHOSTDIST}/gcc/bitmap.c >${.TARGET} 215build-bitmap.lo: ${HH} 216 217build-errors.c: errors.c errors.h 218 ${_MKTARGET_CREATE} 219 rm -f build-errors.c 220 cat ${GNUHOSTDIST}/gcc/errors.c >${.TARGET} 221build-errors.lo: ${HH_NORTL} 222 223build-varray.c: varray.c \ 224 ${G_RTL_H} ${G_GCC_H} ${TREE_H} bitmap.h errors.h 225 ${_MKTARGET_CREATE} 226 rm -f build-varray.c 227 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 228 ${GNUHOSTDIST}/gcc/varray.c >${.TARGET} 229build-varray.lo: ${HH} gtype-desc.h 230 231build-ggc-none.c: ggc-none.c \ 232 ${G_GCC_H} gtype-desc.h 233 ${_MKTARGET_CREATE} 234 rm -f build-ggc-none.c 235 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 236 ${GNUHOSTDIST}/gcc/ggc-none.c >${.TARGET} 237build-ggc-none.lo: ${HH} 238 239# 240# The normal insn-foo generators 241# 242.for f in gensupport.c read-rtl.c dummy-conditions.c 243${f:R}.lo: ${HH} 244.endfor 245 246# 247# There are 5 main classes of generator programs. Ones 248# that are self contained, ones that use error reporting 249# mechanisms, ones that use the MD reader, and ones that 250# use the RTL reader. 251# 252GENPROG_ERROR_DEPENDS= ${G_BUILD_ERRORS:.o=.lo} 253GENPROG_READER_DEPENDS= ${G_BUILD_MD:.o=.lo} ${GENPROG_ERROR_DEPENDS} 254GENPROG_RTL_DEPENDS= ${G_BUILD_RTL:.o=.lo} ${GENPROG_READER_DEPENDS} ${GENPROG_ERROR_DEPENDS} 255 256# 257# First we generate the rules for the generators. 258# 259.for f in attr attr-common attrtab automata codes conditions config emit \ 260 extract flags opinit output peep preds recog mddump condmd 261gen${f}.lo: ${HH} gen${f}.c 262gen${f}: gen${f}.lo ${GENPROG_RTL_DEPENDS} 263 ${_MKTARGET_LINK} 264 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} ${LDFLAGS.${.TARGET}} 265CLEANFILES+= gen${f} gen${f}.lo 266.endfor 267 268.for f in mddeps constants enums 269gen${f}.lo: ${HH} gen${f}.c 270gen${f}: gen${f}.lo ${GENPROG_READER_DEPENDS} 271 ${_MKTARGET_LINK} 272 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} ${LDFLAGS.${.TARGET}} 273CLEANFILES+= gen${f} gen${f}.lo 274.endfor 275 276.for f in check checksum 277gen${f}.lo: ${HH} gen${f}.c 278gen${f}: gen${f}.lo 279 ${_MKTARGET_LINK} 280 ${HOST_LINK.cc} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} ${LDFLAGS.${.TARGET}} 281CLEANFILES+= gen${f} gen${f}.lo 282.endfor 283 284.include "../../Makefile.hooks" 285 286# 287# Second we generate the rules for the generated files. There 288# are 3 main classes: RTL based or not, plus special cases. 289# 290# The special cases are: gencheck, genattrtab, genopinit, 291# gencondmd 292# 293 294# RTL based files 295.for f in attr.h attr-common.h codes.h config.h flags.h \ 296 automata.c emit.c extract.c output.c peep.c recog.c 297insn-${f}: gen${f:R} ${G_md_file} insn-conditions.md 298 ${_MKTARGET_CREATE} 299 ./gen${f:R} ${G_md_file} insn-conditions.md >${.TARGET} 300CLEANFILES+= insn-${f} 301.endfor 302 303# normal files 304.for f in constants.h enums.c 305insn-${f}: gen${f:R} ${G_md_file} 306 ${_MKTARGET_CREATE} 307 ./gen${f:R} ${G_md_file} >${.TARGET} 308CLEANFILES+= insn-${f} 309.endfor 310 311# genconditions outputs gencondmd.c 312gencondmd.c: genconditions ${G_md_file} 313 ${_MKTARGET_CREATE} 314 ./genconditions ${G_md_file} >${.TARGET} 315CLEANFILES+= gencondmd.c 316 317# gencheck outputs tree-check.h 318tree-check.h: gencheck 319 ${_MKTARGET_CREATE} 320 ./gencheck >${.TARGET} 321CLEANFILES+= tree-check.h 322 323# Some generators output is not the normal name. 324BUILDSYMLINKS+= insn-check.h tree-check.h 325 326# genattrtab has three output files 327# XXX fix me 328insn-attrtab.c insn-dfatab.c insn-latencytab.c: genattrtab ${G_md_file} insn-conditions.md 329 ${_MKTARGET_CREATE} 330 ./genattrtab ${G_md_file} insn-conditions.md -Ainsn-attrtab.c -Dinsn-dfatab.c -Linsn-latencytab.c 331CLEANFILES+= insn-attrtab.c insn-dfatab.c insn-latencytab.c 332 333# genopinit has two output files 334insn-opinit.c insn-opinit.h: genopinit ${G_md_file} insn-conditions.md 335 ${_MKTARGET_CREATE} 336 ./genopinit ${G_md_file} insn-conditions.md -hinsn-opinit.h -cinsn-opinit.c 337CLEANFILES+= insn-opinit.h insn-opinit.c 338 339LDFLAGS.genautomata+= -lm 340 341# gencondmd outputs a special .md file 342insn-conditions.md: gencondmd 343 ./gencondmd >${.TARGET} 344CLEANFILES+= insn-conditions.md 345 346 347# 348# Required hard-coded dependancies. 349# 350genextract.lo: insn-config.h 351gencondmd.lo: tm_p.h tm-constrs.h 352read-rtl.lo gencodes.lo genattrtab.lo genautomata.lo: insn-constants.h 353genattr-common.lo gensupport.lo genconditions.lo: insn-constants.h 354genattr.lo genflags.lo genemit.lo genconfig.lo gencheck.lo: insn-constants.h 355genopinit.lo genrecog.lo genpreds.lo genoutput.lo genpeep.lo: insn-constants.h 356build-ggc-none.lo: gtype-desc.h 357ggc-none.o: gtype-desc.h 358 359insn-attrtab.o: insn-config.h 360insn-extract.o: insn-config.h 361toplev.d toplev.o: options.h 362coverage.d: gcov-iov.h 363gcov-io.h: gcov-iov.h 364alias.d alias.o: insn-constants.h tm_p.h 365cgraph.d cgraphunit.d cgraphunit.o: gcov-io.h 366vec.lo: gtype-desc.h 367gtype-desc.d gtype-desc.o: insn-constants.h 368insn-emit.d insn-emit.o: tm-constrs.h 369insn-attr.h: insn-attr-common.h 370asan.d asan.o: insn-opinit.h 371data-streamer.d data-streamer-out.d coverage.d gcov-dump.d gcov-io.d gcov-iov.d gcov.d libgcov.d lto-cgraph.d mcf.d modulo-sched.d profile.d value-prof.d: gcov-io.h 372data-streamer.o data-streamer-out.o coverage.o gcov-dump.o gcov-io.o gcov-iov.o gcov.o libgcov.o lto-cgraph.o mcf.o modulo-sched.o profile.o value-prof.o: gcov-io.h 373gcov-io.h: gcov-iov.h 374df-scan.d df-scan.o: target-hooks-def.h 375read-md.d read-md.o read-md.lo: auto-build.h 376 377# XXX make all hooks generated for now. 378final.o: target-hooks-def.h c-family/c-target-hooks-def.h common/common-target-hooks-def.h 379 380.if ${GCC_MACHINE_ARCH} == "alpha" 381alpha.d alpha.o: tm-constrs.h tm_p.h insn-opinit.h target-hooks-def.h 382.endif 383 384.if ${MACHINE_CPU} == "arm" 385arm.d arm.o: insn-constants.h tm_p.h insn-opinit.h target-hooks-def.h 386.endif 387 388.if ${GCC_MACHINE_ARCH} == "i386" || ${GCC_MACHINE_ARCH} == "x86_64" 389i386.d i386.o: tm-constrs.h 390.endif 391 392.if ${GCC_MACHINE_ARCH} == "vax" 393CPPFLAGS+=-I${.CURDIR}/../../lib/libgcc/libgcov/arch/${GCC_MACHINE_ARCH} 394COPTS.expmed.c=-O0 395COPTS.recog.c=-O0 396.endif 397 398CFLAGS+= -Wno-stack-protector 399 400.if ${GCC_MACHINE_ARCH} == "m68000" || ${GCC_MACHINE_ARCH} == "m68k" 401COPTS.lambda-code.c= -O0 402COPTS.tree-loop-linear.c= -O0 403.endif 404 405COPTS.tree.c= ${${ACTIVE_CC} == "clang" :? -O0 :} 406 407.PATH: ${DIST}/gcc ${DIST}/libiberty ${GCCARCH} ${G_out_file:H} ${DIST}/include 408.PATH: ${DIST}/gcc/config 409