From bcb915b0d0018e19c7e67beeb32d212fd4bb0b85 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 2 Jul 2009 18:19:10 -0400 Subject: [PATCH] Enhance build system so that "make V=1" works like the Linux Kernel If gmake is available, the developer can use "make V=1" instead of using a configure-time switch, --enable-verbose-makecmds, to see all of the commands executed by the Makefile. Signed-off-by: "Theodore Ts'o" --- MCONFIG.in | 23 +++++++++-------- aclocal.m4 | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 31 +++++++++++++++++++++++ configure.in | 1 + 4 files changed, 126 insertions(+), 10 deletions(-) diff --git a/MCONFIG.in b/MCONFIG.in index 6381eac..fba2208 100644 --- a/MCONFIG.in +++ b/MCONFIG.in @@ -32,16 +32,19 @@ datadir = @datadir@ @SET_MAKE@ -E = @E@ -Q = @Q@ - -# Uncomment to pretty-print the makefile commands -# E = @echo -# Q = @ -# -# Uncomment to show the full makefile commands -# E = @\# -# Q = +@ifGNUmake@ V = +@ifGNUmake@ ifeq ($(strip $(V)),) +@ifGNUmake@ # E = @echo +@ifGNUmake@ # Q = @ +@ifGNUmake@ E = @E@ +@ifGNUmake@ Q = @Q@ +@ifGNUmake@ else +@ifGNUmake@ E = @\# +@ifGNUmake@ Q = +@ifGNUmake@ endif + +@ifNotGNUmake@ E = @E@ +@ifNotGNUmake@ Q = @Q@ CC = @CC@ BUILD_CC = @BUILD_CC@ diff --git a/aclocal.m4 b/aclocal.m4 index 3c32c83..6fd4652 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -2694,3 +2694,84 @@ if test -n "$PKG_CONFIG"; then fi[]dnl ])# PKG_PROG_PKG_CONFIG +# =========================================================================== +# http://www.nongnu.org/autoconf-archive/check_gnu_make.html +# =========================================================================== +# +# SYNOPSIS +# +# CHECK_GNU_MAKE() +# +# DESCRIPTION +# +# This macro searches for a GNU version of make. If a match is found, the +# makefile variable `ifGNUmake' is set to the empty string, otherwise it +# is set to "#". This is useful for including a special features in a +# Makefile, which cannot be handled by other versions of make. The +# variable _cv_gnu_make_command is set to the command to invoke GNU make +# if it exists, the empty string otherwise. +# +# Here is an example of its use: +# +# Makefile.in might contain: +# +# # A failsafe way of putting a dependency rule into a makefile +# $(DEPEND): +# $(CC) -MM $(srcdir)/*.c > $(DEPEND) +# +# @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) +# @ifGNUmake@ include $(DEPEND) +# @ifGNUmake@ endif +# +# Then configure.in would normally contain: +# +# CHECK_GNU_MAKE() +# AC_OUTPUT(Makefile) +# +# Then perhaps to cause gnu make to override any other make, we could do +# something like this (note that GNU make always looks for GNUmakefile +# first): +# +# if ! test x$_cv_gnu_make_command = x ; then +# mv Makefile GNUmakefile +# echo .DEFAULT: > Makefile ; +# echo \ $_cv_gnu_make_command \$@ >> Makefile; +# fi +# +# Then, if any (well almost any) other make is called, and GNU make also +# exists, then the other make wraps the GNU make. +# +# LICENSE +# +# Copyright (c) 2008 John Darrington +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. +# +# Note: Modified by Ted Ts'o to add @ifNotGNUMake@ + +AC_DEFUN( + [CHECK_GNU_MAKE], [ AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command, + _cv_gnu_make_command='' ; +dnl Search all the common names for GNU make + for a in "$MAKE" make gmake gnumake ; do + if test -z "$a" ; then continue ; fi ; + if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then + _cv_gnu_make_command=$a ; + break; + fi + done ; + ) ; +dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise + if test "x$_cv_gnu_make_command" != "x" ; then + ifGNUmake='' ; + ifNotGNUmake='#' ; + else + ifGNUmake='#' ; + ifNotGNUmake='' ; + AC_MSG_RESULT("Not found"); + fi + AC_SUBST(ifGNUmake) + AC_SUBST(ifNotGNUmake) +] ) diff --git a/configure b/configure index 9460d3b..769dc09 100755 --- a/configure +++ b/configure @@ -674,6 +674,8 @@ CP MV LN_S LN +ifNotGNUmake +ifGNUmake BINARY_TYPE POSUB LTLIBINTL @@ -11628,6 +11630,35 @@ $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi + { $as_echo "$as_me:$LINENO: checking for GNU make" >&5 +$as_echo_n "checking for GNU make... " >&6; } +if test "${_cv_gnu_make_command+set}" = set; then + $as_echo_n "(cached) " >&6 +else + _cv_gnu_make_command='' ; + for a in "$MAKE" make gmake gnumake ; do + if test -z "$a" ; then continue ; fi ; + if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then + _cv_gnu_make_command=$a ; + break; + fi + done ; + +fi +{ $as_echo "$as_me:$LINENO: result: $_cv_gnu_make_command" >&5 +$as_echo "$_cv_gnu_make_command" >&6; } ; + if test "x$_cv_gnu_make_command" != "x" ; then + ifGNUmake='' ; + ifNotGNUmake='#' ; + else + ifGNUmake='#' ; + ifNotGNUmake='' ; + { $as_echo "$as_me:$LINENO: result: \"Not found\"" >&5 +$as_echo "\"Not found\"" >&6; }; + fi + + + # Extract the first word of "ln", so it can be a program name with args. set dummy ln; ac_word=$2 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 diff --git a/configure.in b/configure.in index 0a1232c..d11faec 100644 --- a/configure.in +++ b/configure.in @@ -674,6 +674,7 @@ dnl End of configuration options dnl AC_SUBST(BINARY_TYPE) AC_PROG_MAKE_SET +CHECK_GNU_MAKE AC_PATH_PROG(LN, ln, ln) AC_PROG_LN_S AC_PATH_PROG(MV, mv, mv) -- 1.8.3.1