Makefile.gnuhost revision 1.35
11.35Stsutsui#	$NetBSD: Makefile.gnuhost,v 1.35 2011/11/21 13:46:37 tsutsui 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.21SdbjHOST_CFLAGS+=-O2 -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.33SapbCONFIGURE_ENV+= \
481.33Sapb		AR=${HOST_AR:Q} \
491.33Sapb		AWK=${TOOL_AWK:Q} \
501.33Sapb		CC=${HOST_CC:Q} \
511.1Stv		CFLAGS=${HOST_CFLAGS:Q} \
521.1Stv		CPPFLAGS=${HOST_CPPFLAGS:Q} \
531.1Stv		CXX=${HOST_CXX:Q} \
541.1Stv		CXXFLAGS=${HOST_CXXFLAGS:Q} \
551.9Sperry		INSTALL=${HOST_INSTALL_FILE:Q} \
561.1Stv		LDFLAGS=${HOST_LDFLAGS:Q} \
571.14Stv		LEX=${LEX:Q} \
581.35Stsutsui		M4=${TOOL_M4:Q} \
591.28Sjmc		MAKE=${MAKE:Q} \
601.14Stv		PATH="${TOOLDIR}/bin:$$PATH" \
611.33Sapb		RANLIB=${HOST_RANLIB:Q} \
621.14Stv		YACC=${YACC:Q}
631.1Stv
641.31SjmcBUILD_ENV+=	${CONFIGURE_ENV}
651.31Sjmc
661.25SskrllCONFIGURE_ARGS+=--prefix=${TOOLDIR}
671.26Sskrll.if ${MKPIC} == "no"
681.26SskrllCONFIGURE_ARGS+=--disable-shared
691.26Sskrll.endif
701.1Stv
711.2Stv.ifndef _NOWRAPPER
721.18Sthorpej# Some systems have a small ARG_MAX.  On such systems, prevent Make
731.18Sthorpej# variables set on the command line from being exported in the
741.18Sthorpej# environment (they will still be set in MAKEOVERRIDES).
751.18SthorpejBUILD_OSTYPE!=	uname -s
761.18Sthorpej.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
771.18Sthorpej__noenvexport=	-X
781.18Sthorpej.endif
791.18SthorpejMAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
801.2Stv.else
811.2StvMAKE_ARGS+=	_NOWRAPPER=1
821.2Stv.endif
831.3Stv
841.15StvMAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
851.2Stv
861.1StvALL_TARGET?=	all
871.1StvINSTALL_TARGET?=install
881.1Stv
891.7Stv.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
901.1Stv	@mkdir build 2>/dev/null || true
911.32Sjmc	@(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
921.1Stv	@touch $@
931.1Stv
941.12Stv# The .build_done timestamp is only updated if a file actually changes
951.12Stv# in the build tree during "make all".  This way, if nothing has changed,
961.19Slukem# a "make install MKUPDATE=yes" will do nothing.
971.12Stv
981.1Stv.build_done: .configure_done
991.31Sjmc	@(cd build && ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
1001.15Stv	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
1011.13Stv		then touch $@; fi
1021.1Stv
1031.27Sjmc.install_done! ${BUILD:D.build_done}
1041.8Stv	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
1051.1Stv	@touch $@
1061.12Stv
1071.1Stv# Mapping to standard targets.
1081.1Stv
1091.1Stv.if ${USETOOLS} == "yes"
1101.1Stvrealall: .build_done
1111.1Stvrealinstall: .install_done
1121.1Stv.endif
1131.1Stv
1141.1Stvclean: clean.gnu
1151.1Stvclean.gnu:
1161.29Sjmc	-rm -r -f .*_done build
1171.1Stv
1181.1Stv.include <bsd.hostprog.mk>
119