Module Name:    src
Committed By:   christos
Date:           Fri Jan 20 23:01:05 UTC 2012

Modified Files:
        src/tools: Makefile.gmakehost Makefile.gnuhost

Log Message:
Merge the two Makefiles that were mostly copies of each others.
The reason to do this was to add support for cleaning up the config.cache
files when the build environment (as determined by uname -srm) changes.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tools/Makefile.gmakehost
cvs rdiff -u -r1.35 -r1.36 src/tools/Makefile.gnuhost

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tools/Makefile.gmakehost
diff -u src/tools/Makefile.gmakehost:1.6 src/tools/Makefile.gmakehost:1.7
--- src/tools/Makefile.gmakehost:1.6	Wed Nov 25 06:49:36 2009
+++ src/tools/Makefile.gmakehost	Fri Jan 20 18:01:05 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.gmakehost,v 1.6 2009/11/25 11:49:36 uebayasi Exp $
+#	$NetBSD: Makefile.gmakehost,v 1.7 2012/01/20 23:01:05 christos Exp $
 #
 # Rules used when building a GNU host package.  Expects MODULE to be set.
 # This version runs ${TOOL_GMAKE} instead of ${MAKE}
@@ -17,109 +17,5 @@
 #   since the last install in the current directory.
 
 .include <bsd.own.mk>
-
-# Disable use of pre-compiled headers on Darwin.
-BUILD_OSTYPE!=  uname -s
-.if ${BUILD_OSTYPE} == "Darwin"
-HOST_CFLAGS+=-O2 -no-cpp-precomp
-.endif
-
-GNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
-
-FIND_ARGS+=	\! \( -type d \( \
-			-name 'CVS' -o \
-			-name 'config' -o \
-			-name 'doc' -o \
-			-name 'po' -o \
-			-name 'nbsd.mt' -o \
-			-name 'tests*' \
-		\) -prune \)
-
-# Do this "find" only if actually building something.
-.if (${USETOOLS} == "yes") && empty(.MAKEFLAGS:M-V*) && \
-    (make(all) || make(realall) || (!make(clean) && !make(cleandir) && !make(obj))) && \
-    !defined(_GNU_CFGSRC)
-
-_GNU_CFGSRC!=	find ${GNUHOSTDIST} ${FIND_ARGS} \
-		-type f \( -name 'config*' -o -name '*.in' \) -print
-.MAKEOVERRIDES+= _GNU_CFGSRC
-.endif
-
-CONFIGURE_ENV+= \
-		AR=${HOST_AR:Q} \
-		AWK=${TOOL_AWK:Q} \
-		CC=${HOST_CC:Q} \
-		CFLAGS=${HOST_CFLAGS:Q} \
-		CPPFLAGS=${HOST_CPPFLAGS:Q} \
-		CXX=${HOST_CXX:Q} \
-		CXXFLAGS=${HOST_CXXFLAGS:Q} \
-		INSTALL=${HOST_INSTALL_FILE:Q} \
-		LDFLAGS=${HOST_LDFLAGS:Q} \
-		LEX=${LEX:Q} \
-		MAKE=${TOOL_GMAKE:Q} \
-		PATH="${TOOLDIR}/bin:$$PATH" \
-		RANLIB=${HOST_RANLIB:Q} \
-		YACC=${YACC:Q}
-
-BUILD_ENV+=	${CONFIGURE_ENV}
-
-CONFIGURE_ARGS+=--prefix=${TOOLDIR}
-.if ${MKPIC} == "no"
-CONFIGURE_ARGS+=--disable-shared
-.endif
-
-# don't need this for gmake? i hope.  might need gmake equiv of -X?
-##.ifndef _NOWRAPPER
-### Some systems have a small ARG_MAX.  On such systems, prevent Make
-### variables set on the command line from being exported in the
-### environment (they will still be set in MAKEOVERRIDES).
-##BUILD_OSTYPE!=	uname -s
-##.if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
-##__noenvexport=	-X
-##.endif
-##MAKE_ARGS:=	${__noenvexport} -f ${.PARSEDIR}/Makefile.gnuwrap ${MAKE_ARGS}
-##.else
-##MAKE_ARGS+=	_NOWRAPPER=1
-##.endif
-
-MAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
-
-ALL_TARGET?=	all
-INSTALL_TARGET?=install
-
-.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
-	@mkdir build 2>/dev/null || true
-	@(cd build && /usr/bin/env ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
-	@touch $@
-
-# The .build_done timestamp is only updated if a file actually changes
-# in the build tree during "make all".  This way, if nothing has changed,
-# a "make install MKUPDATE=yes" will do nothing.
-
-# gmake version of this puts MAKE_ARGS in the environment to be sure that
-# sub-gmake's get them, otherwise tools/gcc tries to build libgcc and
-# fails.  it also uses "env -i" to entirely clear out MAKEFLAGS.
-
-GMAKE_J_ARGS?=	${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W}
-
-.build_done: .configure_done
-	@(cd build && /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS} ${ALL_TARGET})
-	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
-		then touch $@; fi
-
-.install_done! ${BUILD:D.build_done}
-	@(cd ${.OBJDIR}/build && /usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} -e ${MAKE_ARGS} ${INSTALL_TARGET})
-	@touch $@
-
-# Mapping to standard targets.
-
-.if ${USETOOLS} == "yes"
-realall: .build_done
-realinstall: .install_done
-.endif
-
-clean: clean.gnu
-clean.gnu:
-	-rm -r -f .*_done build
-
-.include <bsd.hostprog.mk>
+MAKE_PROGRAM=${TOOL_GMAKE}
+.include "Makefile.gnuhost"

Index: src/tools/Makefile.gnuhost
diff -u src/tools/Makefile.gnuhost:1.35 src/tools/Makefile.gnuhost:1.36
--- src/tools/Makefile.gnuhost:1.35	Mon Nov 21 08:46:37 2011
+++ src/tools/Makefile.gnuhost	Fri Jan 20 18:01:05 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.gnuhost,v 1.35 2011/11/21 13:46:37 tsutsui Exp $
+#	$NetBSD: Makefile.gnuhost,v 1.36 2012/01/20 23:01:05 christos Exp $
 #
 # Rules used when building a GNU host package.  Expects MODULE to be set.
 #
@@ -18,10 +18,11 @@
 .include <bsd.own.mk>
 
 # Disable use of pre-compiled headers on Darwin.
-BUILD_OSTYPE!=  uname -s
+BUILD_OSTYPE!= uname -s
 .if ${BUILD_OSTYPE} == "Darwin"
 HOST_CFLAGS+=-O2 -no-cpp-precomp
 .endif
+MAKE_PROGRAM?=	${MAKE}
 
 GNUHOSTDIST?=	${.CURDIR}/../../gnu/dist/${MODULE}
 
@@ -56,7 +57,7 @@ CONFIGURE_ENV+= \
 		LDFLAGS=${HOST_LDFLAGS:Q} \
 		LEX=${LEX:Q} \
 		M4=${TOOL_M4:Q} \
-		MAKE=${MAKE:Q} \
+		MAKE=${MAKE_PROGRAM:Q} \
 		PATH="${TOOLDIR}/bin:$$PATH" \
 		RANLIB=${HOST_RANLIB:Q} \
 		YACC=${YACC:Q}
@@ -68,11 +69,11 @@ CONFIGURE_ARGS+=--prefix=${TOOLDIR}
 CONFIGURE_ARGS+=--disable-shared
 .endif
 
+.if ${MAKE_PROGRAM} == ${MAKE}
 .ifndef _NOWRAPPER
 # Some systems have a small ARG_MAX.  On such systems, prevent Make
 # variables set on the command line from being exported in the
 # environment (they will still be set in MAKEOVERRIDES).
-BUILD_OSTYPE!=	uname -s
 .if ${BUILD_OSTYPE} == "Darwin" || ${BUILD_OSTYPE} == "FreeBSD"
 __noenvexport=	-X
 .endif
@@ -80,28 +81,58 @@ MAKE_ARGS:=	${__noenvexport} -f ${.PARSE
 .else
 MAKE_ARGS+=	_NOWRAPPER=1
 .endif
+BUILD_COMMAND=	${BUILD_ENV} ${MAKE} ${MAKE_ARGS}
+.else
+
+# gmake version of this puts MAKE_ARGS in the environment to be sure that
+# sub-gmake's get them, otherwise tools/gcc tries to build libgcc and
+# fails.  it also uses "env -i" to entirely clear out MAKEFLAGS.
+GMAKE_J_ARGS?=	${MAKEFLAGS:[*]:M*-j*:C/.*(-j ?[0-9]*).*/\1/W}
+BUILD_COMMAND=	/usr/bin/env -i ${BUILD_ENV} ${MAKE_ARGS} ${TOOL_GMAKE} ${GMAKE_J_ARGS} -e ${MAKE_ARGS}
+
+.endif
 
 MAKE_ARGS+=	BISON=true DESTDIR= INSTALL=${HOST_INSTALL_FILE:Q}
 
 ALL_TARGET?=	all
 INSTALL_TARGET?=install
 
-.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
+BUILD_PLATFORM!= uname -srm | tr ' ' '-'
+CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi
+.if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}"
+configure_cleanup:
+	@mkdir build 2>/dev/null || true
+	@(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}")
+	@(cd build && find . -name config.cache -print0 | xargs -0 rm -f)
+configure_cleanup=configure_cleanup
+.endif
+
+BUILD_PLATFORM!= uname -srm | tr ' ' '-'
+CONFIGURE_PLATFORM!= if [ -s .configure_done ]; then cat .configure_done; else echo none; fi
+.if "${BUILD_PLATFORM}" != "${CONFIGURE_PLATFORM}"
+configure_cleanup:
+	@mkdir build 2>/dev/null || true
+	@(echo "Cleaning stale cache files ${BUILD_PLATFORM} != ${CONFIGURE_PLATFORM}")
+	@(cd build && find . -name config.cache -print0 | xargs -0 rm -f)
+configure_cleanup=configure_cleanup
+.endif
+
+.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup}
 	@mkdir build 2>/dev/null || true
 	@(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
-	@touch $@
+	@echo ${BUILD_PLATFORM} > $@
 
 # The .build_done timestamp is only updated if a file actually changes
 # in the build tree during "make all".  This way, if nothing has changed,
 # a "make install MKUPDATE=yes" will do nothing.
 
 .build_done: .configure_done
-	@(cd build && ${BUILD_ENV} ${MAKE} ${MAKE_ARGS} ${ALL_TARGET})
+	@(cd build && ${BUILD_COMMAND} ${ALL_TARGET})
 	@if [ ! -f $@ ] || [ -n "$$(find build -type f -newer .build_done -print)" ]; \
 		then touch $@; fi
 
 .install_done! ${BUILD:D.build_done}
-	@(cd ${.OBJDIR}/build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET})
+	@(cd ${.OBJDIR}/build && ${BUILD_COMMAND} ${INSTALL_TARGET})
 	@touch $@
 
 # Mapping to standard targets.

Reply via email to