1 # $NetBSD: Makefile,v 1.16 2013/01/14 16:00:49 pooka Exp $ 2 3 LIBISPRIVATE= yes 4 5 LIB= backend 6 7 SRCS= ${G_OBJS:.o=.c} ${G_out_file:T} 8 9 BOTH_CPPFLAGS+= -I. -I${GCCARCH} ${G_ALL_CFLAGS:M-D*} ${G_INCLUDES:M-I*:N-I.*} 10 CPPFLAGS+= ${BOTH_CPPFLAGS} -DTARGET_NAME=\"${MACHINE_GNU_PLATFORM}\" 11 HOST_CPPFLAGS+= ${BOTH_CPPFLAGS} -DGENERATOR_FILE 12 DPSRCS+= insn-attr.h insn-codes.h insn-config.h insn-flags.h tree-check.h 13 CPPFLAGS.prefix.c+= -DPREFIX=\"/usr\" 14 CPPFLAGS.cppdefault.c+= -DPREFIX=\"/usr\" 15 CPPFLAGS+= -I${DIST}/libgcc 16 17 .include <bsd.lib.mk> 18 19 # For early builders. 20 EXTRADEPENDSEARLY= ${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 # 30 CLEANFILES+= 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 45 COPTS.varasm.c= -Wno-error 46 47 48 # Headers that host objects depend on (except gen*rtl*) 49 HH_NORTL= ${G_tm_file_list} ${G_build_xm_include_list} 50 HH= ${HH_NORTL} genrtl.h insn-modes.h 51 52 # 53 # Generate the various header files we need. 54 # 55 genrtl.c: gengenrtl 56 ${_MKTARGET_CREATE} 57 ./gengenrtl >${.TARGET} 58 genrtl.h: gengenrtl 59 ${_MKTARGET_CREATE} 60 ./gengenrtl -h >${.TARGET} 61 gengenrtl.lo: ${HH_NORTL} 62 gengenrtl: gengenrtl.lo build-errors.lo 63 ${_MKTARGET_LINK} 64 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 65 66 tm-preds.h: genpreds ${G_md_file} 67 ${_MKTARGET_CREATE} 68 ./genpreds -h ${G_md_file} >${.TARGET} 69 tm-constrs.h: genpreds ${G_md_file} 70 ${_MKTARGET_CREATE} 71 ./genpreds -c ${G_md_file} >${.TARGET} 72 insn-preds.c: genpreds ${G_md_file} 73 ${_MKTARGET_CREATE} 74 ./genpreds ${G_md_file} >${.TARGET} 75 genpreds.lo: ${HH} 76 genpreds: genpreds.lo ${EXTRADEPENDSEARLY} 77 ${_MKTARGET_LINK} 78 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 79 80 tree-check.h: gencheck 81 ${_MKTARGET_CREATE} 82 ./gencheck >${.TARGET} 83 gencheck.lo: ${HH} 84 gencheck: gencheck.lo 85 ${_MKTARGET_LINK} 86 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 87 88 # be nice to generate this entirely; but difficult. 89 gtyp-input.list.tmp: ${GCCARCH}/gtyp-input.list 90 sed s#SRCDIR#${DIST}# < ${.ALLSRC} > ${.TARGET} 91 CLEANFILES+= gtyp-input.list.tmp 92 93 # XXX 94 CLEANFILES+= gtype-lto.h gtype-objcp.h tm-constrs.h 95 96 gtype-desc.c: gtype-desc.h 97 gtype-desc.h: gengtype gtyp-input.list.tmp 98 ${_MKTARGET_CREATE} 99 rm -f auto-host.h 100 ln -s ${.CURDIR}/../gcc/arch/${MACHINE_ARCH}/auto-host.h . 101 if [ -f ${.CURDIR}/../gcc/arch/${MACHINE_ARCH}/sysroot-suffix.h ]; then \ 102 rm -f sysroot-suffix.h; \ 103 ln -s ${.CURDIR}/../gcc/arch/${MACHINE_ARCH}/sysroot-suffix.h ; \ 104 fi 105 ./gengtype ${DIST}/gcc gtyp-input.list.tmp 106 # gengtype is the real need for options.h 107 gengtype.lo gengtype-lex.lo gengtype-parse.lo: ${HH} gtyp-gen.h config.h options.h 108 gengtype: gengtype.lo gengtype-lex.lo gengtype-parse.lo build-errors.lo 109 ${_MKTARGET_LINK} 110 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 111 112 gtyp-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 131 insn-modes.c: genmodes 132 ${_MKTARGET_CREATE} 133 ./genmodes >${.TARGET} 134 insn-modes.h: genmodes 135 ${_MKTARGET_CREATE} 136 ./genmodes -h >${.TARGET} 137 min-insn-modes.c: genmodes 138 ${_MKTARGET_CREATE} 139 ./genmodes -m >${.TARGET} 140 genmodes.lo: ${HH_NORTL} 141 genmodes: genmodes.lo build-errors.lo 142 ${_MKTARGET_LINK} 143 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 144 145 gcov-iov.h: gcov-iov 146 ${_MKTARGET_CREATE} 147 ./gcov-iov "${BASEVER}" "${DEVPHASE}" >${.TARGET} 148 gcov-iov.lo: ${HH_NORTL} 149 gcov-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 160 tm_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 168 CLEANFILES+= options.h options.c optionlist 169 optionlist: ${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 172 options.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 176 options.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 180 options.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... 184 CLEANFILES+= auto-build.h 185 auto-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 206 build-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} 212 build-rtl.lo: ${HH} 213 214 build-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} 220 build-print-rtl.lo: ${HH} 221 222 build-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} 228 build-bitmap.lo: ${HH} 229 230 build-errors.c: errors.c errors.h 231 ${_MKTARGET_CREATE} 232 rm -f build-errors.c 233 cat ${GNUHOSTDIST}/gcc/errors.c >${.TARGET} 234 build-errors.lo: ${HH_NORTL} 235 236 build-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} 242 build-varray.lo: ${HH} gtype-desc.h 243 244 build-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} 250 build-ggc-none.lo: ${HH} 251 252 # 253 # The `early' insn-foo generators 254 # 255 .for f in conditions.c constants.h 256 CLEANFILES+= gen${f:R} insn-${f} 257 258 gen${f:R}.lo: gen${f:R}.c ${HH} 259 gen${f:R}: gen${f:R}.lo ${EXTRADEPENDSEARLY} 260 ${_MKTARGET_LINK} 261 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} 262 insn-${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 274 EXTRADEPENDS= ${G_BUILD_RTL:.o=.lo} ${G_BUILD_SUPPORT:.o=.lo} \ 275 ${G_BUILD_PRINT:.o=.lo} ${G_BUILD_ERRORS:.o=.lo} 276 LDFLAGS.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 280 CLEANFILES+= gen${f:R} insn-${f} 281 282 gen${f:R}.lo: ${HH} 283 gen${f:R}: gen${f:R}.lo ${EXTRADEPENDS} 284 ${_MKTARGET_LINK} 285 ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} ${NBCOMPATLIB} ${HOSTLIBIBERTY} ${LDFLAGS.${.TARGET}} 286 insn-${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 # 294 genextract.lo: insn-config.h 295 insn-conditions.lo: insn-constants.h tm_p.h 296 build-ggc-none.lo: gtype-desc.h 297 ggc-none.o: gtype-desc.h 298 299 insn-attrtab.o: insn-config.h 300 insn-extract.o: insn-config.h 301 toplev.d toplev.o: options.h 302 coverage.d: gcov-iov.h 303 gcov-io.h: gcov-iov.h 304 alias.d alias.o: insn-constants.h tm_p.h 305 cgraphunit.d cgraphunit.o: gcov-io.h 306 vec.lo: gtype-desc.h 307 gtype-desc.d gtype-desc.o: insn-constants.h 308 insn-emit.d insn-emit.o: tm-constrs.h 309 310 .if ${MACHINE_ARCH} == "alpha" 311 alpha.d alpha.o: tm-constrs.h tm_p.h 312 .endif 313 314 .if ${MACHINE_CPU} == "arm" 315 arm.d arm.o: insn-constants.h tm_p.h 316 .endif 317 318 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" 319 i386.d i386.o: tm-constrs.h 320 .endif 321 322 CFLAGS+= -Wno-stack-protector 323 324 .if ${MACHINE_ARCH} == "m68000" 325 COPTS.lambda-code.c= -O0 326 COPTS.tree-loop-linear.c= -O0 327 .endif 328 329 .PATH: ${DIST}/gcc ${DIST}/libiberty ${GCCARCH} ${G_out_file:H} ${DIST}/include 330