git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] build: avoid possible confusion between GNU/XPG4 make on Solaris

From
Stefano Lattarini <stefano.lattarini@gmail.com>
Date
Mar 2, 2012, 10:18 UTC
Message-ID
<abe2c43575849e612b17a1e6a6f8eb33db9623b8.1330683426.git.stefano.lattarini@gmail.com>
In-Reply-To
<4F5095D6.6050401@gmail.com>

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.

Helped-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
---
 Makefile |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index e4f8e0e..e71d688 100644
--- a/Makefile
+++ b/Makefile
@@ -303,6 +303,21 @@ 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.
+original_MAKE := $(MAKE)
+MAKE := $(shell command -v $(firstword $(original_MAKE)) 2>/dev/null)
+ifeq ($(MAKE),)
+	MAKE := $(original_MAKE)
+else
+	MAKE += $(wordlist 2,$(words $(original_MAKE)),$(original_MAKE))
+endif
+
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 CFLAGS = -g -O2 -Wall
-- 
1.7.9
Previous: Stefano LattariniNext: Junio C Hamano
Message 4 of 12 in “build: avoid possible confusion between GNU/XPG4 make on Solaris”
  1. build: avoid possible confusion between GNU/XPG4 make on SolarisStefano Lattarini, Mar 2, 2012
  2. Thomas RastMar 2, 2012
  3. Stefano LattariniMar 2, 2012
  4. build: avoid possible confusion between GNU/XPG4 make on SolarisStefano Lattarini, Mar 2, 2012
  5. Junio C HamanoMar 2, 2012
  6. Stefano LattariniMar 2, 2012
  7. Junio C HamanoMar 2, 2012
  8. configure: allow user to prevent $PATH "sanitization" on SolarisStefano Lattarini, Mar 9, 2012
  9. Junio C HamanoMar 9, 2012
  10. Junio C HamanoMar 9, 2012
  11. Stefano LattariniMar 9, 2012
  12. Junio C HamanoMar 9, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.