Makefile revision 1.27
1#	$NetBSD: Makefile,v 1.27 2016/01/26 17:48:31 christos Exp $
2
3.include <bsd.own.mk>
4
5MODULE=		gdb
6GNUHOSTDIST=    ${.CURDIR}/../../external/gpl3/${EXTERNAL_GDB_SUBDIR}/dist
7
8FIND_ARGS=	\! \( -type d -name sim -prune \)
9
10CONFIGURE_ARGS=	--target=${MACHINE_GNU_PLATFORM} --disable-nls \
11		--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-,"
12
13MAKE_ARGS=	MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q}
14
15ALL_TARGET=	all-gdb
16INSTALL_TARGET=	install-gdb
17
18.include "${.CURDIR}/../Makefile.gmakehost"
19
20CCADDFLAGS=	--sysroot=${DESTDIR} -L${DESTDIR}/lib -L${DESTDIR}/usr/lib -B${DESTDIR}/usr/lib/ -I${.OBJDIR}/.native/gcc/include
21
22NEWCONFIGDIR?=	${.CURDIR}/../..
23MKNATIVE?=	${.CURDIR}/mknative-gdb
24
25# Some configure tests require running a test program, which is not
26# possible when cross-building.  Provide configure with "cached"
27# values in the environment.
28MKNATIVE_CONFIGURE_PRESET= \
29	ac_cv_prog_cc_cross=yes \
30	ac_cv_func_fork_works=yes \
31	ac_cv_func_strcoll_works=yes \
32	bash_cv_func_ctype_nonascii=yes \
33	bash_cv_func_sigsetjmp=present \
34	bash_cv_func_strcoll_broken=no \
35	bash_cv_must_reinstall_sighandlers=no
36
37# Recent versions of Solaris have ncurses, but they hide the lib in an
38# odd directory. Prevent configure from finding the ncurses headers,
39# Solaris curses is sufficient.
40.if ${BUILD_OSTYPE} == "SunOS"
41CONFIGURE_ENV+=	ac_cv_header_ncurses_h=no \
42		ac_cv_header_ncurses_ncurses_h=no \
43		ac_cv_header_ncurses_term_h=no
44.endif
45
46# Disable sim unless it's known to work (configure's default is to
47# enable sim if supported).
48CONFIGURE_ARGS_SIM=
49.if \
50    ${MACHINE_CPU} != "powerpc" && \
51    ${MACHINE_CPU} != "powerpc64"
52CONFIGURE_ARGS_SIM+= --disable-sim
53.endif
54
55native-gdb: .native/.configure_done
56	@echo 'Extracting GDB configury for a native toolchain.'
57	MAKE=${MAKE:Q} ${HOST_SH} ${MKNATIVE} gdb \
58		${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM}
59
60.native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
61	mkdir ${.OBJDIR}/.native 2>/dev/null || true
62	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
63		(cd ${.OBJDIR}/.native && ${CONFIGURE_ENV:NC*:NLD*} \
64			CC_FOR_BUILD=${HOST_CC:Q} \
65			CC=${CC:Q}' '${CCADDFLAGS:Q} \
66			CXX=${CXX:Q}' '${CCADDFLAGS:Q} \
67			CPP=${CPP:Q}' '-isystem' '${DESTDIR}/usr/include \
68			CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS=${LDADDFLAGS:Q} \
69			MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
70			XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
71			LIBS=-lintl \
72			${MKNATIVE_CONFIGURE_PRESET} \
73			${HOST_SH} ${GNUHOSTDIST}/configure \
74			--prefix=/usr \
75			--with-separate-debug-dir=/usr/libdata/debug \
76			${CONFIGURE_ARGS_SIM} \
77			--build=`${GNUHOSTDIST}/config.guess` \
78			--host=${MACHINE_GNU_PLATFORM} \
79			--target=${MACHINE_GNU_PLATFORM}) && \
80		(cd ${.OBJDIR}/.native && \
81			/usr/bin/env ${MKNATIVE_CONFIGURE_PRESET} \
82				${MAKE} configure-host) && \
83		(cd ${.OBJDIR}/.native/bfd && ${MAKE} bfd.h bfdver.h) && \
84		(cd ${.OBJDIR}/.native/gdb && ${MAKE} init.c version.c)
85	@touch $@
86
87clean: clean.native
88clean.native:
89	-rm -r -f .native
90