Makefile revision 1.31
1#	$NetBSD: Makefile,v 1.31 2020/04/04 00:47:30 christos Exp $
2
3.include <bsd.hostinit.mk>
4
5MODULE=		binutils
6
7GNUHOSTDIST=	${.CURDIR}/../../external/gpl3/${EXTERNAL_BINUTILS_SUBDIR}/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 --disable-initfini-array \
17		${BRANDING}
18
19build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c
20	@mkdir build 2>/dev/null || true
21	@mkdir build/gas 2>/dev/null || true
22	cat ${GNUHOSTDIST}/gas/m68k-parse.c > ${.TARGET}
23
24.configure_done: build/gas/m68k-parse.c
25
26MAKE_ARGS=	MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q}
27
28ALL_TARGET=	all-binutils all-gas all-ld
29INSTALL_TARGET=	install-binutils install-gas install-ld
30.if ${MKCROSSGPROF:Uno} != "no"
31ALL_TARGET+=	all-gprof
32INSTALL_TARGET+=install-gprof
33.endif
34
35.include "${.CURDIR}/../Makefile.gnuhost"
36
37CCADDFLAGS=	-I${GNUHOSTDIST}/include  -I${DESTDIR}/usr/include
38CCADDFLAGS+=	-B${DESTDIR}/usr/lib/
39LDADDFLAGS=	-L${DESTDIR}/lib -L${DESTDIR}/usr/lib
40
41# Force avoiding possibly non-executable install-sh.
42CONFIGURE_ENV+= ac_cv_path_mkdir="${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install -d"
43
44NEWCONFIGDIR?=	${.CURDIR}/../..
45MKNATIVE?=	${.CURDIR}/mknative-binutils
46
47native-binutils: .native/.configure_done
48	@echo 'Extracting GNU binutils configury for a native toolchain.'
49	MAKE=${MAKE:Q} ${HOST_SH} ${MKNATIVE} binutils \
50		${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM}
51
52.native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
53	mkdir .native 2>/dev/null || true
54	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
55		(cd .native && ${CONFIGURE_ENV:NC*:NLD*} \
56			CC_FOR_BUILD=${HOST_CC:Q} \
57			CC=${CC:Q}' '${CCADDFLAGS:Q} \
58			CXX=${CXX:Q}' '${CCADDFLAGS:Q} \
59			CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
60			CFLAGS= CPPFLAGS= CXXFLAGS= \
61			LDFLAGS=${LDADDFLAGS:Q} \
62			MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
63			XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
64			LIBS=-lintl \
65			ac_cv_prog_cc_cross=yes \
66			ac_cv_func_strcoll_works=yes \
67			${HOST_SH} ${GNUHOSTDIST}/configure \
68			--build=`${GNUHOSTDIST}/config.guess` \
69			--host=${MACHINE_GNU_PLATFORM} \
70			--target=${MACHINE_GNU_PLATFORM} \
71			--disable-initfini-array \
72			${BRANDING} \
73		)
74	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
75		(cd .native && ${MAKE} configure-host)
76	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
77		(cd .native/bfd && ${MAKE} bfd.h bfdver.h)
78	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
79		(cd .native/ld && ${MAKE} ldemul-list.h)
80	@touch $@
81
82clean: clean.native
83clean.native:
84	-rm -r -f .native
85