1# $NetBSD: Makefile,v 1.1.1.1 2014/02/25 18:42:26 mrg 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.prefix.c+= -DPREFIX=\"/usr\" 14CPPFLAGS.cppdefault.c+= -DPREFIX=\"/usr\" 15CPPFLAGS+= -I${DIST}/libgcc 16 17.include <bsd.lib.mk> 18 19# For early builders. 20EXTRADEPENDSEARLY= ${G_BUILD_EARLY_SUPPORT:.o=.lo} ${G_BUILD_RTL:.o=.lo} \ 21 ${G_BUILD_ERRORS:.o=.lo} 22 23# Don't auto-frob .y or .l files. 24.l.c .y.c .y.h: 25 @true 26 27# 28# Independent generation programs. 29# 30CLEANFILES+= gengenrtl genrtl.c genrtl.h \ 31 gengtype gtyp-gen.h gtype-desc.c gtype-desc.h \ 32 gtype-c.h gtype-cp.h gtype-f.h gtype-objc.h \ 33 genflags genflags.h \ 34 gencheck tree-check.h \ 35 insn-preds.c genpreds tm-preds.h tm_p.h cs-tm_p.h \ 36 genmodes insn-modes.c insn-modes.h min-insn-modes.c \ 37 auto-host.h build-print-rtl.c \ 38 build-rtl.c build-errors.c build-varray.c \ 39 build-bitmap.c build-ggc-none.c \ 40 gt-*.h *.o *.lo \ 41 cs-config.h \ 42 gcov-iov gcov-iov.h \ 43 44# XXX 45COPTS.varasm.c= -Wno-error 46 47 48# Headers that host objects depend on (except gen*rtl*) 49HH_NORTL= ${G_tm_file_list} ${G_build_xm_include_list} 50HH= ${HH_NORTL} genrtl.h insn-modes.h 51 52# 53# Generate the various header files we need. 54# 55genrtl.c: gengenrtl 56 ${_MKTARGET_CREATE} 57 ./gengenrtl >${.TARGET} 58genrtl.h: gengenrtl 59 ${_MKTARGET_CREATE} 60 ./gengenrtl -h >${.TARGET} 61gengenrtl.lo: ${HH_NORTL} 62gengenrtl: gengenrtl.lo build-errors.lo 63 ${_MKTARGET_LINK} 64 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 65 66tm-preds.h: genpreds ${G_md_file} 67 ${_MKTARGET_CREATE} 68 ./genpreds -h ${G_md_file} >${.TARGET} 69tm-constrs.h: genpreds ${G_md_file} 70 ${_MKTARGET_CREATE} 71 ./genpreds -c ${G_md_file} >${.TARGET} 72insn-preds.c: genpreds ${G_md_file} 73 ${_MKTARGET_CREATE} 74 ./genpreds ${G_md_file} >${.TARGET} 75genpreds.lo: ${HH} 76genpreds: genpreds.lo ${EXTRADEPENDSEARLY} 77 ${_MKTARGET_LINK} 78 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 79 80tree-check.h: gencheck 81 ${_MKTARGET_CREATE} 82 ./gencheck >${.TARGET} 83gencheck.lo: ${HH} 84gencheck: gencheck.lo 85 ${_MKTARGET_LINK} 86 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 87 88# be nice to generate this entirely; but difficult. 89gtyp-input.list.tmp: ${GCCARCH}/gtyp-input.list 90 sed s#SRCDIR#${DIST}# < ${.ALLSRC} > ${.TARGET} 91CLEANFILES+= gtyp-input.list.tmp 92 93# XXX 94CLEANFILES+= gtype-lto.h gtype-objcp.h tm-constrs.h 95 96gtype-desc.c: gtype-desc.h 97gtype-desc.h: gengtype gtyp-input.list.tmp 98 ${_MKTARGET_CREATE} 99 rm -f auto-host.h 100 ln -s ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/auto-host.h . 101 if [ -f ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/sysroot-suffix.h ]; then \ 102 rm -f sysroot-suffix.h; \ 103 ln -s ${.CURDIR}/../gcc/arch/${GCC_MACHINE_ARCH}/sysroot-suffix.h ; \ 104 fi 105 ./gengtype ${DIST}/gcc gtyp-input.list.tmp 106# gengtype is the real need for options.h 107gengtype.lo gengtype-lex.lo gengtype-parse.lo: ${HH} gtyp-gen.h config.h options.h 108gengtype: gengtype.lo gengtype-lex.lo gengtype-parse.lo build-errors.lo 109 ${_MKTARGET_LINK} 110 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 111 112gtyp-gen.h: Makefile 113 ${_MKTARGET_CREATE} 114 (\ 115 unset empty ; \ 116 echo "static const char *srcdir = \"$(G_GTFILES_SRCDIR)\";" ; \ 117 echo "static const char *lang_files[] = {" ; \ 118 for f in $$empty $(G_GTFILES_FILES_FILES); do echo "\"$$f\", "; done ; \ 119 echo "NULL };" ; \ 120 echo "static const char *langs_for_lang_files[] = {" ; \ 121 for f in $$empty $(G_GTFILES_FILES_LANGS); do echo "\"$$f\", "; done ; \ 122 echo "NULL };" ; \ 123 echo "static const char *all_files[] = {" ; \ 124 for f in $$empty $(G_GTFILES); do echo "\"$$f\", "; done ; \ 125 echo " NULL };" ; \ 126 echo "static const char *lang_dir_names[] = {" ; \ 127 for f in c $(G_GTFILES_LANG_DIR_NAMES); do echo "\"$$f\", "; done ; \ 128 echo "NULL };" ; \ 129 ) >${.TARGET} 130 131insn-modes.c: genmodes 132 ${_MKTARGET_CREATE} 133 ./genmodes >${.TARGET} 134insn-modes.h: genmodes 135 ${_MKTARGET_CREATE} 136 ./genmodes -h >${.TARGET} 137min-insn-modes.c: genmodes 138 ${_MKTARGET_CREATE} 139 ./genmodes -m >${.TARGET} 140genmodes.lo: ${HH_NORTL} 141genmodes: genmodes.lo build-errors.lo 142 ${_MKTARGET_LINK} 143 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 144 145gcov-iov.h: gcov-iov 146 ${_MKTARGET_CREATE} 147 ./gcov-iov "${BASEVER}" "${DEVPHASE}" >${.TARGET} 148gcov-iov.lo: ${HH_NORTL} 149gcov-iov: gcov-iov.lo 150 ${_MKTARGET_CREATE} 151 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 152 153#config.h: Makefile 154# ${_MKTARGET_CREATE} 155# TM_DEFINES="$(G_tm_defines)" \ 156# HEADERS="$(G_host_xm_file)" XM_DEFINES="$(G_host_xm_defines)" \ 157# TARGET_CPU_DEFAULT="$(G_target_cpu_default)" \ 158# ${HOST_SH} ${GNUHOSTDIST}/gcc/mkconfig.sh ${.TARGET} 159 160tm_p.h: Makefile tm-preds.h 161 ${_MKTARGET_CREATE} 162 TARGET_CPU_DEFAULT="" \ 163 HEADERS="$(G_tm_p_include_list)" DEFINES="" \ 164 ${HOST_SH} ${GNUHOSTDIST}/gcc/mkconfig.sh ${.TARGET} 165 166${G_OBJS} ${G_OBJS:.o=.d}: tm_p.h # XXX crude 167 168CLEANFILES+= options.h options.c optionlist 169optionlist: ${G_ALL_OPT_FILES} ${GCCARCH}/defs.mk Makefile ${DIST}/gcc/opt-gather.awk 170 ${TOOL_AWK} -f ${DIST}/gcc/opt-gather.awk ${G_ALL_OPT_FILES} > ${.TARGET} 171 172options.c: optionlist ${DIST}/gcc/opt-functions.awk ${DIST}/gcc/optc-gen.awk 173 ${TOOL_AWK} -f ${DIST}/gcc/opt-functions.awk -f ${DIST}/gcc/optc-gen.awk \ 174 -v header_name="config.h system.h coretypes.h tm.h" < optionlist > ${.TARGET} 175 176options.h: optionlist ${DIST}/gcc/opt-functions.awk ${DIST}/gcc/opth-gen.awk 177 ${TOOL_AWK} -f ${DIST}/gcc/opt-functions.awk -f ${DIST}/gcc/opth-gen.awk \ 178 < optionlist > ${.TARGET} 179 180options.o: options.c coretypes.h opts.h intl.h 181#options.o: options.c ${G_CONFIG_H} ${G_SYSTEM_H} coretypes.h ${G_TM_H} opts.h intl.h 182 183# Yuck, we have to run configure to generate this one... 184CLEANFILES+= auto-build.h 185auto-build.h: Makefile 186 ${_MKTARGET_CREATE} 187 rm -rf .ab && \ 188 mkdir .ab && \ 189 (cd .ab && \ 190 AWK=${TOOL_AWK:Q} \ 191 CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} \ 192 MAKE=${MAKE:Q} \ 193 CONFIG_SHELL=${HOST_SH:Q} \ 194 ${HOST_SH} ${GNUHOSTDIST}/gcc/configure \ 195 --build=`${HOST_SH} ${GNUHOSTDIST}/config.guess` \ 196 --host=`${HOST_SH} ${GNUHOSTDIST}/config.guess` \ 197 --target=${MACHINE_GNU_PLATFORM} && \ 198 mv auto-host.h ../auto-build.h) && \ 199 rm -rf .ab 200 201# 202# These are copies of files we build for the build host that are used 203# by the genfoo programs. 204# 205 206build-rtl.c: rtl.c \ 207 ${G_RTL_H} real.h ${G_GCC_H} errors.h gtype-desc.h 208 ${_MKTARGET_CREATE} 209 rm -f build-rtl.c 210 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 211 ${GNUHOSTDIST}/gcc/rtl.c >${.TARGET} 212build-rtl.lo: ${HH} 213 214build-print-rtl.c: print-rtl.c \ 215 ${G_RTL_H} ${G_TREE_H} hard-reg-set.h ${G_BASIC_BLOCK_H} 216 ${_MKTARGET_CREATE} 217 rm -f buid-print-rtl.c 218 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 219 ${GNUHOSTDIST}/gcc/print-rtl.c >${.TARGET} 220build-print-rtl.lo: ${HH} 221 222build-bitmap.c: bitmap.c \ 223 ${G_RTL_H} flags.h ${G_BASIC_BLOCK_H} ${REGS_H} ${G_GCC_H} gtype-desc.h 224 ${_MKTARGET_CREATE} 225 rm -f build-bitmap.c 226 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 227 ${GNUHOSTDIST}/gcc/bitmap.c >${.TARGET} 228build-bitmap.lo: ${HH} 229 230build-errors.c: errors.c errors.h 231 ${_MKTARGET_CREATE} 232 rm -f build-errors.c 233 cat ${GNUHOSTDIST}/gcc/errors.c >${.TARGET} 234build-errors.lo: ${HH_NORTL} 235 236build-varray.c: varray.c \ 237 ${G_RTL_H} ${G_GCC_H} ${TREE_H} bitmap.h errors.h 238 ${_MKTARGET_CREATE} 239 rm -f build-varray.c 240 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 241 ${GNUHOSTDIST}/gcc/varray.c >${.TARGET} 242build-varray.lo: ${HH} gtype-desc.h 243 244build-ggc-none.c: ggc-none.c \ 245 ${G_GCC_H} gtype-desc.h 246 ${_MKTARGET_CREATE} 247 rm -f build-ggc-none.c 248 ${TOOL_SED} -e 's/<config[.]h/hconfig.h/' \ 249 ${GNUHOSTDIST}/gcc/ggc-none.c >${.TARGET} 250build-ggc-none.lo: ${HH} 251 252# 253# The `early' insn-foo generators 254# 255.for f in conditions.c constants.h 256CLEANFILES+= gen${f:R} insn-${f} 257 258gen${f:R}.lo: gen${f:R}.c ${HH} 259gen${f:R}: gen${f:R}.lo ${EXTRADEPENDSEARLY} 260 ${_MKTARGET_LINK} 261 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 262insn-${f}: gen${f:R} ${G_md_file} 263 ${_MKTARGET_CREATE} 264 ./gen${f:R} ${G_md_file} >${.TARGET} 265.endfor 266 267# 268# The normal insn-foo generators 269# 270.for f in gensupport.c read-rtl.c dummy-conditions.c 271${f:R}.lo: ${HH} 272.endfor 273 274EXTRADEPENDS= ${G_BUILD_RTL:.o=.lo} ${G_BUILD_SUPPORT:.o=.lo} \ 275 ${G_BUILD_PRINT:.o=.lo} ${G_BUILD_ERRORS:.o=.lo} 276LDFLAGS.genautomata+= -lm 277 278.for f in attr.h attrtab.c automata.c codes.h config.h emit.c extract.c flags.h opinit.c output.c \ 279 peep.c recog.c 280CLEANFILES+= gen${f:R} insn-${f} 281 282gen${f:R}.lo: ${HH} 283gen${f:R}: gen${f:R}.lo ${EXTRADEPENDS} 284 ${_MKTARGET_LINK} 285 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} ${LDFLAGS.${.TARGET}} 286insn-${f}: gen${f:R} ${G_md_file} 287 ${_MKTARGET_CREATE} 288 ./gen${f:R} ${G_md_file} >${.TARGET} 289.endfor 290 291# 292# Required hard-coded dependancies. 293# 294genextract.lo: insn-config.h 295insn-conditions.lo: insn-constants.h tm_p.h 296build-ggc-none.lo: gtype-desc.h 297ggc-none.o: gtype-desc.h 298 299insn-attrtab.o: insn-config.h 300insn-extract.o: insn-config.h 301toplev.d toplev.o: options.h 302coverage.d: gcov-iov.h 303gcov-io.h: gcov-iov.h 304alias.d alias.o: insn-constants.h tm_p.h 305cgraphunit.d cgraphunit.o: gcov-io.h 306vec.lo: gtype-desc.h 307gtype-desc.d gtype-desc.o: insn-constants.h 308insn-emit.d insn-emit.o: tm-constrs.h 309 310.if ${GCC_MACHINE_ARCH} == "alpha" 311alpha.d alpha.o: tm-constrs.h tm_p.h 312.endif 313 314.if ${MACHINE_CPU} == "arm" 315arm.d arm.o: insn-constants.h tm_p.h 316.endif 317 318.if ${GCC_MACHINE_ARCH} == "i386" || ${GCC_MACHINE_ARCH} == "x86_64" 319i386.d i386.o: tm-constrs.h 320.endif 321 322CFLAGS+= -Wno-stack-protector 323 324.if ${GCC_MACHINE_ARCH} == "m68000" || ${GCC_MACHINE_ARCH} == "m68k" 325COPTS.lambda-code.c= -O0 326COPTS.tree-loop-linear.c= -O0 327.endif 328 329.PATH: ${DIST}/gcc ${DIST}/libiberty ${GCCARCH} ${G_out_file:H} ${DIST}/include 330