Makefile.gnuhost revision 1.12
11.12Stv#	$NetBSD: Makefile.gnuhost,v 1.12 2002/01/03 16:45:18 tv 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.1StvDIST=		${.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.1Stv_GNU_CFGSRC!=	find ${DIST} ${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.1Stv		PATH="${TOOLDIR}/bin:$$PATH"
491.1Stv
501.1StvCONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
511.5Stv
521.5StvMAKE_ARGS:=	-j1 ${MAKE_ARGS}
531.1Stv
541.2Stv.ifndef _NOWRAPPER
551.2StvMAKE_ARGS:=	-f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
561.2Stv.else
571.2StvMAKE_ARGS+=	_NOWRAPPER=1
581.2Stv.endif
591.3Stv
601.9SperryMAKE_ARGS+=	LEX=true BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
611.2Stv
621.1StvALL_TARGET?=	all
631.1StvINSTALL_TARGET?=install
641.1Stv
651.7Stv.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
661.1Stv	@mkdir build 2>/dev/null || true
671.10Sjmc	@(cd build && ${CONFIGURE_ENV} sh ${DIST}/configure ${CONFIGURE_ARGS})
681.1Stv	@touch $@
691.1Stv
701.12Stv# The .build_done timestamp is only updated if a file actually changes
711.12Stv# in the build tree during "make all".  This way, if nothing has changed,
721.12Stv# a "make install UPDATE=" will do nothing.
731.12Stv
741.1Stv.build_done: .configure_done
751.2Stv	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
761.12Stv	@if [ ! -f .build_done ] || \
771.12Stv		find build -type f -newer .build_done -print | grep -q ''; \
781.12Stv		then echo build changed; touch $@; fi
791.1Stv
801.12Stv.install_done: ${BUILD:D.build_done}
811.1Stv.if defined(UPDATE)
821.1Stv	@if [ ! -f .install_done ] || [ .build_done -nt .install_done ]; then \
831.8Stv		(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
841.1Stv	fi
851.1Stv.else
861.8Stv	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
871.1Stv.endif
881.1Stv	@touch $@
891.12Stv
901.12Stv.PHONY: .build_done
911.1Stv
921.1Stv# Mapping to standard targets.
931.1Stv
941.1Stv.if ${USETOOLS} == "yes"
951.1Stvrealall: .build_done
961.1Stvrealinstall: .install_done
971.1Stv.endif
981.1Stv
991.1Stvclean: clean.gnu
1001.1Stvclean.gnu:
1011.1Stv	-rm -r -f .*_done build
1021.1Stv
1031.1Stv.include <bsd.hostprog.mk>
104