git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Lattarini <stefano.lattarini@gmail.com>
To: git@vger.kernel.org
Cc: Stefano Lattarini <stefano.lattarini@gmail.com>
Subject: [RFC/PATCH] build: avoid possible confusion between GNU/XPG4 make on Solaris
Date: Fri,  2 Mar 2012 10:13:00 +0100	[thread overview]
Message-ID: <df98ed215324f521f3aaff7fa4ba41ba2a1894dc.1330679536.git.stefano.lattarini@gmail.com> (raw)

On a Solaris 10 system with Solaris XPG4 make installed as /usr/xpg4/bin/make,
GNU make installed as /usr/local/bin/make, and with /usr/local/bin appearing
in $PATH *before* /usr/xpg4/bin, I was seeing errors like this upon invoking
"make all":

        SUBDIR perl
    make: Warning: Ignoring DistributedMake -o option
    Usage : make [ -f makefile ][ -K statefile ]...
    make: Fatal error: Unknown option `-C'

This happens because the Git's Makefiles, when running on Solaris, sanitize
$PATH by prepending /usr/xpg6/bin and /usr/xpg4/bin to it, but in the setup
described above such a behaviour has the unintended consequence of forcing
the use of Solaris make in recursive make invocations, even if the $(MAKE)
macro is being correctly used in them; this happens because, in that setup,
the original GNU make process was invoked simply as "make".

To avoid such an issue, we instruct our Makefile to redefine $(MAKE) to
point to the absolute path of the originally-invoked make program.
---

 The implementation is still rough and not completely portable, but before
 investing more time in refining it I'd like to know if you gitsters think
 the idea behind it is sound.

 Regards,
   Stefano

 Makefile |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index e4f8e0e..8cba6e8 100644
--- a/Makefile
+++ b/Makefile
@@ -303,6 +303,19 @@ ifdef MSVC
 	uname_O := Windows
 endif
 
+# This Makefile will possibly sanitize PATH by prepending system-specific
+# directories to it (e.g., /usr/xpg4/bin on Solaris).  This can become
+# problematic for recursive make invocations, if one of those directories
+# contains a "make" program and the user has called GNU make by simply
+# invoking "make" (this can happen e.g. when GNU make has been installed
+# as /usr/local/bin/make).  To avoid such issues, we redefine $(MAKE) to
+# point to the absolute path of the originally-invoked make program.
+# FIXME: this is ugly, and which(1) is quite unportable.  Find a better
+# 	 way to obtain the same effect.
+MAKE := $(shell set $(MAKE); m1=$$1; shift; \
+                m2=`which $$m1 2>/dev/null` && test -n "$$m2" || m2=$$m1; \
+                echo "$$m2 $$*")
+
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 CFLAGS = -g -O2 -Wall
-- 
1.7.9

             reply	other threads:[~2012-03-02  9:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-02  9:13 Stefano Lattarini [this message]
2012-03-02  9:34 ` [RFC/PATCH] build: avoid possible confusion between GNU/XPG4 make on Solaris Thomas Rast
2012-03-02  9:41   ` Stefano Lattarini
2012-03-02 10:18     ` [PATCH v2] " Stefano Lattarini
2012-03-02 18:35 ` [RFC/PATCH] " Junio C Hamano
2012-03-02 19:00   ` Stefano Lattarini
2012-03-02 19:46     ` Junio C Hamano
2012-03-09 12:43   ` [PATCH] configure: allow user to prevent $PATH "sanitization" " Stefano Lattarini
2012-03-09 16:29     ` Junio C Hamano
2012-03-09 19:46     ` Junio C Hamano
2012-03-09 21:46       ` Stefano Lattarini
2012-03-09 21:59         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df98ed215324f521f3aaff7fa4ba41ba2a1894dc.1330679536.git.stefano.lattarini@gmail.com \
    --to=stefano.lattarini@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).