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