Makefile.gnuhost revision 1.6
11.6Stv#	$NetBSD: Makefile.gnuhost,v 1.6 2001/11/14 22:07:03 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.1Stv			-name 'tests*' \
281.1Stv		\) -prune \)
291.1Stv
301.1Stv# Do this "find" only if actually building something.
311.1Stv.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
321.1Stv    (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
331.1Stv    !defined(_GNU_CFGSRC)
341.1Stv
351.1Stv_GNU_CFGSRC!=	find ${DIST} ${FIND_ARGS} \
361.1Stv		-type f \( -name 'config*' -o -name '*.in' \) -print
371.1Stv.MAKEOVERRIDES+= _GNU_CFGSRC
381.1Stv.endif
391.1Stv
401.1StvCONFIGURE_ENV+=	CC=${HOST_CC:Q} \
411.1Stv		CFLAGS=${HOST_CFLAGS:Q} \
421.1Stv		CPPFLAGS=${HOST_CPPFLAGS:Q} \
431.1Stv		CXX=${HOST_CXX:Q} \
441.1Stv		CXXFLAGS=${HOST_CXXFLAGS:Q} \
451.6Stv		INSTALL=${INSTALL_FILE:N-U:Q} \
461.1Stv		LDFLAGS=${HOST_LDFLAGS:Q} \
471.1Stv		PATH="${TOOLDIR}/bin:$$PATH"
481.1Stv
491.1StvCONFIGURE_ARGS+=--prefix=${TOOLDIR} --disable-shared
501.5Stv
511.5StvMAKE_ARGS:=	-j1 ${MAKE_ARGS}
521.1Stv
531.2Stv.ifndef _NOWRAPPER
541.2StvMAKE_ARGS:=	-f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
551.2Stv.else
561.2StvMAKE_ARGS+=	_NOWRAPPER=1
571.2Stv.endif
581.3Stv
591.6StvMAKE_ARGS+=	LEX=true BISON=true DESTDIR= INSTALL=${INSTALL_FILE:N-U:Q}
601.2Stv
611.1StvALL_TARGET?=	all
621.1StvINSTALL_TARGET?=install
631.1Stv
641.1Stv.configure_done: ${_GNU_CFGSRC}
651.1Stv	@mkdir build 2>/dev/null || true
661.1Stv	@(cd build && ${CONFIGURE_ENV} ${DIST}/configure ${CONFIGURE_ARGS})
671.1Stv	@touch $@
681.1Stv
691.1Stv.build_done: .configure_done
701.2Stv	@(cd build && ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
711.1Stv	@touch $@
721.1Stv
731.1Stv.install_done:
741.1Stv.if defined(UPDATE)
751.1Stv	@if [ ! -f .install_done ] || [ .build_done -nt .install_done ]; then \
761.2Stv		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
771.1Stv	fi
781.1Stv.else
791.2Stv	@(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
801.1Stv.endif
811.1Stv	@touch $@
821.1Stv
831.1Stv.PHONY:		.build_done .install_done
841.1Stv.ORDER:		.build_done .install_done
851.1Stv
861.1Stv# Mapping to standard targets.
871.1Stv
881.1Stv.if ${USETOOLS} == "yes"
891.1Stvrealall: .build_done
901.1Stvrealinstall: .install_done
911.1Stv.endif
921.1Stv
931.1Stvclean: clean.gnu
941.1Stvclean.gnu:
951.1Stv	-rm -r -f .*_done build
961.1Stv
971.1Stv.include <bsd.hostprog.mk>
98