Makefile.gnuhost revision 1.18
11.18Sthorpej#	$NetBSD: Makefile.gnuhost,v 1.18 2003/03/14 05:22:51 thorpej 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.1Stv# * If UPDATE is set, "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.1Stv
201.17SlukemGNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
211.1Stv
221.1StvFIND_ARGS+=	\! \( -type d \( \
231.1Stv			-name 'CVS' -o \
241.1Stv			-name 'config' -o \
251.1Stv			-name 'doc' -o \
261.1Stv			-name 'po' -o \
271.8Stv			-name 'nbsd.mt' -o \
281.1Stv			-name 'tests*' \
291.1Stv		\) -prune \)
301.1Stv
311.1Stv# Do this "find" only if actually building something.
321.1Stv.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
331.1Stv    (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
341.1Stv    !defined(_GNU_CFGSRC)
351.1Stv
361.17Slukem_GNU_CFGSRC!=	find ${GNUHOSTDIST} ${FIND_ARGS} \
371.1Stv		-type f \( -name 'config*' -o -name '*.in' \) -print
381.1Stv.MAKEOVERRIDES+= _GNU_CFGSRC
391.1Stv.endif
401.1Stv
411.1StvCONFIGURE_ENV+=	CC=${HOST_CC:Q} \
421.1Stv		CFLAGS=${HOST_CFLAGS:Q} \
431.1Stv		CPPFLAGS=${HOST_CPPFLAGS:Q} \
441.1Stv		CXX=${HOST_CXX:Q} \
451.1Stv		CXXFLAGS=${HOST_CXXFLAGS:Q} \
461.9Sperry		INSTALL=${HOST_INSTALL_FILE:Q} \
471.1Stv		LDFLAGS=${HOST_LDFLAGS:Q} \
481.14Stv		LEX=${LEX:Q} \
491.14Stv		PATH="${TOOLDIR}/bin:$$PATH" \
501.14Stv		YACC=${YACC:Q}
511.1Stv
521.1StvCONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
531.1Stv
541.2Stv.ifndef _NOWRAPPER
551.18Sthorpej# Some systems have a small ARG_MAX.  On such systems, prevent Make
561.18Sthorpej# variables set on the command line from being exported in the
571.18Sthorpej# environment (they will still be set in MAKEOVERRIDES).
581.18SthorpejBUILD_OSTYPE!=	uname -s
591.18Sthorpej.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
601.18Sthorpej__noenvexport=	-X
611.18Sthorpej.endif
621.18SthorpejMAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
631.2Stv.else
641.2StvMAKE_ARGS+=	_NOWRAPPER=1
651.2Stv.endif
661.3Stv
671.15StvMAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
681.2Stv
691.1StvALL_TARGET?=	all
701.1StvINSTALL_TARGET?=install
711.1Stv
721.7Stv.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
731.1Stv	@mkdir build 2>/dev/null || true
741.17Slukem	@(cd build && ${CONFIGURE_ENV} sh ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
751.1Stv	@touch $@
761.1Stv
771.12Stv# The .build_done timestamp is only updated if a file actually changes
781.12Stv# in the build tree during "make all".  This way, if nothing has changed,
791.12Stv# a "make install UPDATE=" will do nothing.
801.12Stv
811.1Stv.build_done: .configure_done
821.2Stv	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
831.15Stv	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
841.13Stv		then touch $@; fi
851.1Stv
861.12Stv.install_done: ${BUILD:D.build_done}
871.1Stv.if defined(UPDATE)
881.15Stv	@cd ${.OBJDIR}; \
891.15Stv	if [ ! -f .install_done ] || [ ! -f .build_done ] || \
901.15Stv	[ -n "$$(find .build_done -prune -newer .install_done -print)" ]; then \
911.15Stv		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
921.1Stv	fi
931.1Stv.else
941.8Stv	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
951.1Stv.endif
961.1Stv	@touch $@
971.12Stv
981.15Stv.PHONY: .build_done .install_done
991.1Stv
1001.1Stv# Mapping to standard targets.
1011.1Stv
1021.1Stv.if ${USETOOLS} == "yes"
1031.1Stvrealall: .build_done
1041.1Stvrealinstall: .install_done
1051.1Stv.endif
1061.1Stv
1071.1Stvclean: clean.gnu
1081.1Stvclean.gnu:
1091.1Stv	-rm -r -f .*_done build
1101.1Stv
1111.1Stv.include <bsd.hostprog.mk>
112