Makefile revision 1.50
11.50Schristos#	$NetBSD: Makefile,v 1.50 2024/08/14 23:56:19 christos Exp $
21.1Scl
31.36Schristos.include <bsd.hostinit.mk>
41.1Scl
51.19SchristosMODULE=		gdb
61.30SmrgGDBDIR=		${.CURDIR}/../../external/gpl3/${EXTERNAL_GDB_SUBDIR}
71.30SmrgGNUHOSTDIST=    ${GDBDIR}/dist
81.1Scl
91.1SclFIND_ARGS=	\! \( -type d -name sim -prune \)
101.1Scl
111.1SclCONFIGURE_ARGS=	--target=${MACHINE_GNU_PLATFORM} --disable-nls \
121.37Schristos		--program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
131.50Schristos		--with-zstd=no \
141.50Schristos		--with-mpfr=${TOOLDIR} \
151.50Schristos		--with-mpc=${TOOLDIR} \
161.50Schristos		--with-gmp=${TOOLDIR}
171.1Scl
181.47Srin.if ${MACHINE} == "ia64"
191.47SrinCONFIGURE_ARGS+=--enable-obsolete
201.47Srin.endif
211.47Srin
221.1SclMAKE_ARGS=	MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q}
231.1Scl
241.1SclALL_TARGET=	all-gdb
251.1SclINSTALL_TARGET=	install-gdb
261.1Scl
271.30Smrg.include "${GDBDIR}/Makefile.gdb_arch"
281.30Smrg#GDB_MACHINE_ARCH=       ${MACHINE_ARCH:C/e?armv[4-7]h?f?/arm/}
291.30Smrg
301.22Sbouyer.include "${.CURDIR}/../Makefile.gmakehost"
311.32SchristosBUILD_MAKE=${TOOL_GMAKE}
321.32Schristos
331.32SchristosBINENV=		/usr/bin/env -i
341.32Schristos
351.43Schristos.include "${.CURDIR}/../gcc/lgpl3.mk"
361.32Schristos
371.34SchristosMKNATIVE_ENV=	${BINENV} ${CONFIGURE_ENV:NC*:NLD*:Nam_cv_func_iconv*} \
381.32Schristos			CC_FOR_BUILD=${HOST_CC:Q} \
391.33Schristos			CXX_FOR_BUILD=${HOST_CXX:Q} \
401.33Schristos			CFLAGS_FOR_BUILD="-I${TOOLDIR}/include" \
411.32Schristos			CC=${CC:Q}' '${CCADDFLAGS:Q} \
421.33Schristos			CXX=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
431.33Schristos			CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
441.48Srin			CFLAGS= CPPFLAGS= \
451.43Schristos			CXXFLAGS= LDFLAGS=-L${GMPOBJ} \
461.33Schristos			AS=${AS:Q} AWK=${TOOL_AWK:Q} LD=${LD:Q} \
471.32Schristos			MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
481.33Schristos			NM=${NM:Q} OBJDUMP=${OBJDUMP:Q} \
491.32Schristos			XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
501.32Schristos			LIBS=-lintl \
511.32Schristos			${MKNATIVE_CONFIGURE_PRESET}
521.32Schristos
531.32SchristosMKENV_BUILD_MAKE=${MKNATIVE_ENV} ${BUILD_MAKE}
541.1Scl
551.48SrinCCADDFLAGS+= --sysroot=${DESTDIR} -B${DESTDIR}/usr/lib/ \
561.48Srin		-I${.OBJDIR}/.native/include \
571.48Srin		-I${.OBJDIR}/.native/gcc/include
581.29SchristosLDADDFLAGS+= -L${DESTDIR}/lib -L${DESTDIR}/usr/lib
591.28SchristosCXXADDFLAGS+= -D__STDC_FORMAT_MACROS
601.28SchristosCXXADDFLAGS+= -D__STDC_LIMIT_MACROS
611.28SchristosCXXADDFLAGS+= -D__STDC_CONSTANT_MACROS
621.29SchristosHOST_CXXFLAGS+= ${CXXADDFLAGS}
631.46Schristos# Since we are using gmake -e the environment overwrites CPPFLAGS
641.46Schristos# so we overwrite it again here! (see Makefile.gnuhost)
651.46SchristosHOST_CPPFLAGS+= -I${TOOLDIR}/include
661.2Snathanw
671.2SnathanwNEWCONFIGDIR?=	${.CURDIR}/../..
681.2SnathanwMKNATIVE?=	${.CURDIR}/mknative-gdb
691.2Snathanw
701.7Suwe# Some configure tests require running a test program, which is not
711.7Suwe# possible when cross-building.  Provide configure with "cached"
721.7Suwe# values in the environment.
731.7SuweMKNATIVE_CONFIGURE_PRESET= \
741.7Suwe	ac_cv_prog_cc_cross=yes \
751.7Suwe	ac_cv_func_fork_works=yes \
761.41Sskrll	ac_cv_func_sigprocmask=yes \
771.7Suwe	ac_cv_func_strcoll_works=yes \
781.38Schristos	ac_cv_func_XML_StopParser=yes \
791.38Schristos	ac_cv_libexpat=yes \
801.7Suwe	bash_cv_func_ctype_nonascii=yes \
811.7Suwe	bash_cv_func_sigsetjmp=present \
821.7Suwe	bash_cv_func_strcoll_broken=no \
831.49Srin	bash_cv_must_reinstall_sighandlers=no \
841.49Srin	gl_cv_func_rename_slash_dst_works=yes \
851.49Srin	gl_cv_func_rename_slash_src_works=yes \
861.49Srin	gl_cv_func_rename_link_works=yes \
871.49Srin	gl_cv_func_rename_dest_works=yes
881.7Suwe
891.34SchristosCONFIGURE_ENV+=	am_cv_func_iconv=no
901.31Sjmcneill
911.17Shans# Recent versions of Solaris have ncurses, but they hide the lib in an
921.17Shans# odd directory. Prevent configure from finding the ncurses headers,
931.17Shans# Solaris curses is sufficient.
941.17Shans.if ${BUILD_OSTYPE} == "SunOS"
951.17ShansCONFIGURE_ENV+=	ac_cv_header_ncurses_h=no \
961.17Shans		ac_cv_header_ncurses_ncurses_h=no \
971.17Shans		ac_cv_header_ncurses_term_h=no
981.17Shans.endif
991.17Shans
1001.8Suwe# Disable sim unless it's known to work (configure's default is to
1011.8Suwe# enable sim if supported).
1021.8SuweCONFIGURE_ARGS_SIM=
1031.8Suwe.if \
1041.9Sskrll    ${MACHINE_CPU} != "powerpc" && \
1051.8Suwe    ${MACHINE_CPU} != "powerpc64"
1061.8SuweCONFIGURE_ARGS_SIM+= --disable-sim
1071.8Suwe.endif
1081.8Suwe
1091.39SchristosCONFIGURE_ARGS_GDBSERVER=
1101.39Schristos.if \
1111.39Schristos    ${MACHINE_CPU} == "x86_64"
1121.39SchristosCONFIGURE_ARGS_GDBSERVER+= --enable-gdbserver
1131.39Schristos.endif
1141.39Schristos
1151.43Schristos
1161.2Snathanwnative-gdb: .native/.configure_done
1171.2Snathanw	@echo 'Extracting GDB configury for a native toolchain.'
1181.32Schristos	MAKE=${BUILD_MAKE:Q} ${HOST_SH} ${MKNATIVE} gdb \
1191.30Smrg		${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM} \
1201.30Smrg		${GDB_MACHINE_ARCH}
1211.2Snathanw
1221.2Snathanw.native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
1231.45Schristos	mkdir -p ${.OBJDIR}/.native/include
1241.45Schristos	# we need to make a copy because ${GMPINC} has a config.h
1251.45Schristos	cp -p ${GMPINC}/gmp.h ${.OBJDIR}/.native/include
1261.2Snathanw	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
1271.32Schristos		(cd ${.OBJDIR}/.native && \
1281.32Schristos			${MKNATIVE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure \
1291.4Snathanw			--prefix=/usr \
1301.5Slukem			--with-separate-debug-dir=/usr/libdata/debug \
1311.50Schristos			--with-zstd=no \
1321.50Schristos			--with-mpfr=${TOOLDIR} \
1331.50Schristos			--with-mpc=${TOOLDIR} \
1341.50Schristos			--with-gmp=${TOOLDIR} \
1351.8Suwe			${CONFIGURE_ARGS_SIM} \
1361.39Schristos			${CONFIGURE_ARGS_GDBSERVER} \
1371.2Snathanw			--build=`${GNUHOSTDIST}/config.guess` \
1381.2Snathanw			--host=${MACHINE_GNU_PLATFORM} \
1391.32Schristos			--target=${MACHINE_GNU_PLATFORM})
1401.32Schristos	PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
1411.7Suwe		(cd ${.OBJDIR}/.native && \
1421.32Schristos			${MKENV_BUILD_MAKE} configure-host) && \
1431.32Schristos		(cd ${.OBJDIR}/.native/bfd && \
1441.32Schristos			${MKENV_BUILD_MAKE} bfd.h bfdver.h) && \
1451.32Schristos		(cd ${.OBJDIR}/.native/gdb && \
1461.42Schristos			${MKENV_BUILD_MAKE} xml-builtin.c init.c version.c) && \
1471.42Schristos		(cd ${.OBJDIR}/.native/libbacktrace && \
1481.42Schristos			${MKENV_BUILD_MAKE} backtrace-supported.h) && \
1491.40Schristos		(if [ -d ${.OBJDIR}/.native/gdbserver ]; then \
1501.40Schristos			cd ${.OBJDIR}/.native/gdbserver && \
1511.40Schristos			${MKENV_BUILD_MAKE} version-generated.cc; fi)
1521.2Snathanw	@touch $@
1531.2Snathanw
1541.2Snathanwclean: clean.native
1551.2Snathanwclean.native:
1561.2Snathanw	-rm -r -f .native
157