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