xref: /minix3/tools/binutils/Makefile (revision a150b26ee803b20080e65cd7a048322ba498f6bf)
1#	$NetBSD: Makefile,v 1.24 2014/02/15 13:34:28 tsutsui Exp $
2
3.include <bsd.own.mk>
4
5MODULE=		binutils
6
7GNUHOSTDIST=	${.CURDIR}/../../external/gpl3/binutils/dist
8
9BRANDING?=	\
10	--with-pkgversion="NetBSD Binutils nb1" \
11	--with-bugurl="http://www.NetBSD.org/support/send-pr.html" \
12	--with-lib-path="=/usr/lib" --with-sysroot
13
14CONFIGURE_ARGS=	--target=${MACHINE_GNU_PLATFORM} --disable-nls \
15		--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
16		--disable-werror \
17		${BRANDING}
18
19.if defined(__MINIX) && ! exists(${GNUHOSTDIST}/gas/m68k-parse.c)
20# MINIX: LSC: Make sure we trigger the fetch rule
21.include "${.CURDIR}/../../minix/Makefile.fetchgnu"
22
23${GNUHOSTDIST}/gas/m68k-parse.c: ${fetch_done}
24	@true
25.endif # defined(__MINIX)
26
27build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c
28	@mkdir build 2>/dev/null || true
29	@mkdir build/gas 2>/dev/null || true
30	cat ${GNUHOSTDIST}/gas/m68k-parse.c > ${.TARGET}
31
32.configure_done: build/gas/m68k-parse.c
33
34MAKE_ARGS=	MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q}
35
36ALL_TARGET=	all-binutils all-gas all-ld
37INSTALL_TARGET=	install-binutils install-gas install-ld
38.if ${MKCROSSGPROF:Uno} != "no"
39ALL_TARGET+=	all-gprof
40INSTALL_TARGET+=install-gprof
41.endif
42
43.if defined(__MINIX) && ${HAVE_GOLD:Uyes} != "no"
44ALL_TARGET+=	all-gold
45INSTALL_TARGET+=install-gold
46
47CONFIGURE_ARGS+=	\
48	--enable-lto \
49	--enable-plugins
50# LSC: Here we use the MK variable, as we have to select the right default
51#      linker. Problem is, when Gold is not seen, USE_BITCODE is forced to
52#      "no".
53.if ${MKBITCODE:Uno} == "yes"
54CONFIGURE_ARGS+= \
55	--enable-ld=yes \
56	--enable-gold=default
57.else
58CONFIGURE_ARGS+= \
59	--enable-ld=default \
60	--enable-gold=yes
61.endif # ${MKBITCODE:Uno} == "yes"
62.endif # defined(__MINIX)
63.include "${.CURDIR}/../Makefile.gnuhost"
64
65CCADDFLAGS=	-I${DESTDIR}/usr/include -L${DESTDIR}/lib -L${DESTDIR}/usr/lib -B${DESTDIR}/usr/lib/
66
67# Force avoiding possibly non-executable install-sh.
68CONFIGURE_ENV+= ac_cv_path_mkdir="${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install -d"
69
70NEWCONFIGDIR?=	${.CURDIR}/../..
71MKNATIVE?=	${.CURDIR}/mknative-binutils
72
73native-binutils: .native/.configure_done
74	@echo 'Extracting GNU binutils configury for a native toolchain.'
75	MAKE=${MAKE:Q} ${HOST_SH} ${MKNATIVE} binutils \
76		${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM}
77
78.native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
79	mkdir .native 2>/dev/null || true
80	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
81		(cd .native && ${CONFIGURE_ENV:NC*:NLD*} \
82			CC_FOR_BUILD=${HOST_CC:Q} \
83			CC=${CC:Q}' '${CCADDFLAGS:Q} \
84			CXX=${CXX:Q}' '${CCADDFLAGS:Q} \
85			CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
86			CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS= \
87			MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
88			XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
89			LIBS=-lintl \
90			ac_cv_prog_cc_cross=yes \
91			ac_cv_func_strcoll_works=yes \
92			${HOST_SH} ${GNUHOSTDIST}/configure \
93			--build=`${GNUHOSTDIST}/config.guess` \
94			--host=${MACHINE_GNU_PLATFORM} \
95			--target=${MACHINE_GNU_PLATFORM} \
96			${BRANDING} \
97		)
98	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
99		(cd .native && ${MAKE} configure-host)
100	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
101		(cd .native/bfd && ${MAKE} bfd.h bfdver.h)
102	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
103		(cd .native/ld && ${MAKE} ldemul-list.h)
104	@touch $@
105
106clean: clean.native
107clean.native:
108	-rm -r -f .native
109