Makefile.gnuhost revision 1.20
11.20Sdbj#	$NetBSD: Makefile.gnuhost,v 1.20 2003/10/07 14:12:36 dbj Exp $
21.1Stv#
31.1Stv# Rules used when building a GNU host package.  Expects MODULE to be set.
41.1Stv#
51.1Stv# There's not a lot we can do to build reliably in the face of many
61.1Stv# available configuration options.  To be as low-overhead as possible,
71.1Stv# we follow the following scheme:
81.1Stv#
91.1Stv# * Configuration is only re-run when an autoconf source file (such as
101.1Stv#   "configure" or "config.sub") is changed.
111.1Stv#
121.1Stv# * "config.status" is run to rebuild Makefiles and .h files if an
131.1Stv#   autoconf-parsed file (such as Makefile.in) is changed.
141.1Stv#
151.19Slukem# * If MKUPDATE != "no", "make install" is only run if a build has happened
161.1Stv#   since the last install in the current directory.
171.1Stv
181.1Stv.include <bsd.own.mk>
191.20Sdbj
201.20Sdbj# Disable use of pre-compiled headers on Darwin.
211.20SdbjBUILD_OSTYPE!=  uname -s
221.20Sdbj.if ${BUILD_OSTYPE} == "Darwin"
231.20SdbjHOST_CFLAGS+=	-no-cpp-precomp
241.20Sdbj.endif
251.1Stv
261.17SlukemGNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
271.1Stv
281.1StvFIND_ARGS+=	\! \( -type d \( \
291.1Stv			-name 'CVS' -o \
301.1Stv			-name 'config' -o \
311.1Stv			-name 'doc' -o \
321.1Stv			-name 'po' -o \
331.8Stv			-name 'nbsd.mt' -o \
341.1Stv			-name 'tests*' \
351.1Stv		\) -prune \)
361.1Stv
371.1Stv# Do this "find" only if actually building something.
381.1Stv.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
391.1Stv    (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
401.1Stv    !defined(_GNU_CFGSRC)
411.1Stv
421.17Slukem_GNU_CFGSRC!=	find ${GNUHOSTDIST} ${FIND_ARGS} \
431.1Stv		-type f \( -name 'config*' -o -name '*.in' \) -print
441.1Stv.MAKEOVERRIDES+= _GNU_CFGSRC
451.1Stv.endif
461.1Stv
471.1StvCONFIGURE_ENV+=	CC=${HOST_CC:Q} \
481.1Stv		CFLAGS=${HOST_CFLAGS:Q} \
491.1Stv		CPPFLAGS=${HOST_CPPFLAGS:Q} \
501.1Stv		CXX=${HOST_CXX:Q} \
511.1Stv		CXXFLAGS=${HOST_CXXFLAGS:Q} \
521.9Sperry		INSTALL=${HOST_INSTALL_FILE:Q} \
531.1Stv		LDFLAGS=${HOST_LDFLAGS:Q} \
541.14Stv		LEX=${LEX:Q} \
551.14Stv		PATH="${TOOLDIR}/bin:$$PATH" \
561.14Stv		YACC=${YACC:Q}
571.1Stv
581.1StvCONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
591.1Stv
601.2Stv.ifndef _NOWRAPPER
611.18Sthorpej# Some systems have a small ARG_MAX.  On such systems, prevent Make
621.18Sthorpej# variables set on the command line from being exported in the
631.18Sthorpej# environment (they will still be set in MAKEOVERRIDES).
641.18SthorpejBUILD_OSTYPE!=	uname -s
651.18Sthorpej.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
661.18Sthorpej__noenvexport=	-X
671.18Sthorpej.endif
681.18SthorpejMAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
691.2Stv.else
701.2StvMAKE_ARGS+=	_NOWRAPPER=1
711.2Stv.endif
721.3Stv
731.15StvMAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
741.2Stv
751.1StvALL_TARGET?=	all
761.1StvINSTALL_TARGET?=install
771.1Stv
781.7Stv.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
791.1Stv	@mkdir build 2>/dev/null || true
801.17Slukem	@(cd build && ${CONFIGURE_ENV} sh ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
811.1Stv	@touch $@
821.1Stv
831.12Stv# The .build_done timestamp is only updated if a file actually changes
841.12Stv# in the build tree during "make all".  This way, if nothing has changed,
851.19Slukem# a "make install MKUPDATE=yes" will do nothing.
861.12Stv
871.1Stv.build_done: .configure_done
881.2Stv	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
891.15Stv	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
901.13Stv		then touch $@; fi
911.1Stv
921.12Stv.install_done: ${BUILD:D.build_done}
931.19Slukem.if ${MKUPDATE} != "no"
941.15Stv	@cd ${.OBJDIR}; \
951.15Stv	if [ ! -f .install_done ] || [ ! -f .build_done ] || \
961.15Stv	[ -n "$$(find .build_done -prune -newer .install_done -print)" ]; then \
971.15Stv		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
981.1Stv	fi
991.1Stv.else
1001.8Stv	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
1011.1Stv.endif
1021.1Stv	@touch $@
1031.12Stv
1041.15Stv.PHONY: .build_done .install_done
1051.1Stv
1061.1Stv# Mapping to standard targets.
1071.1Stv
1081.1Stv.if ${USETOOLS} == "yes"
1091.1Stvrealall: .build_done
1101.1Stvrealinstall: .install_done
1111.1Stv.endif
1121.1Stv
1131.1Stvclean: clean.gnu
1141.1Stvclean.gnu:
1151.1Stv	-rm -r -f .*_done build
1161.1Stv
1171.1Stv.include <bsd.hostprog.mk>
118