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