threads / patch / 3367

patch, 5 partsFixes for ancient versions of GNU make

Subject: [PATCH 1/5] Fixes for ancient versions of GNU make

## tl;dr

5 messages between Feb 17, 2006 and Feb 18, 2006. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Johannes Schindelin· Feb 17, 2006, 14:22 UTC · lore

Some version of GNU make do not understand $(call), and have problems to interpret rules like this:

some_target: CFLAGS += -Dsome=defs
Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
---
 Makefile   |   71 +++++++++++++++++++++++++++++++++++++++---------------------
 t/Makefile |    7 ++----
 2 files changed, 48 insertions(+), 30 deletions(-)
b50c666c80ef6191e06c1c9ed88af534da7ea458
Show changes to 2 files +48 −30

Makefile, t/Makefile

diff --git a/Makefile b/Makefile
index d7d79de..b3401ac 100644
--- a/Makefile
+++ b/Makefile
@@ -203,12 +203,6 @@ LIB_OBJS = \
 LIBS = $(LIB_FILE)
 LIBS += -lz
 
-# Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
-
 #
 # Platform specific tweaks
 #
@@ -413,7 +407,24 @@ endif
 endif
 endif
 
-ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)
+# Shell quote (do not use $(call) to accomodate ancient setups);
+
+# Result of this needs to be placed inside ''
+SHA1_HEADER_QUOTED = '$(subst ','\'',$(SHA1_HEADER))'
+template_dir_QUOTED = '$(subst ','\'',"$(template_dir)")'
+
+# These will be used inside ''
+SHELL_PATH_QUOTED = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_QUOTED = $(subst ','\'',$(PERL_PATH))
+PYTHON_PATH_QUOTED = $(subst ','\'',$(PYTHON_PATH))
+GIT_PYTHON_DIR_QUOTED = $(subst ','\'',$(GIT_PYTHON_DIR))
+
+# prepend DESTDIR to these
+DESTDIR_bindir_QUOTED = '$(subst ','\'',$(DESTDIR)$(bindir))'
+DESTDIR_gitexecdir_QUOTED = '$(subst ','\'',$(DESTDIR)$(gitexecdir))'
+DESTDIR_GIT_PYTHON_DIR_QUOTED = '$(subst ','\'',$(DESTDIR)$(GIT_PYTHON_DIR))'
+
+ALL_CFLAGS += -DSHA1_HEADER=$(SHA1_HEADER_QUOTED) $(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
@@ -432,7 +443,7 @@ git$X: git.c $(LIB_FILE)
 
 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	rm -f $@
-	sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
+	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_QUOTED)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 	    $@.sh >$@
@@ -440,15 +451,15 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.
 
 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
 	rm -f $@
-	sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
+	sed -e '1s|#!.*perl|#!$(PERL_PATH_QUOTED)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@
 	chmod +x $@
 
 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
 	rm -f $@
-	sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
-	    -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
+	sed -e '1s|#!.*python|#!$(PYTHON_PATH_QUOTED)|' \
+	    -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_QUOTED)|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.py >$@
 	chmod +x $@
@@ -474,32 +485,42 @@ git$X git.spec \
 %.o: %.S
 	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
-exec_cmd.o: ALL_CFLAGS += -DGIT_EXEC_PATH=\"$(gitexecdir)\"
+exec_cmd.o: exec_cmd.c
+	$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_EXEC_PATH=\"$(gitexecdir)\" $<
 
 git-%$X: %.o $(LIB_FILE)
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
-git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
 $(SIMPLE_PROGRAMS) : git-%$X : %.o
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIB_FILE) $(SIMPLE_LIB)
 
-git-http-fetch$X: fetch.o http.o
-git-http-push$X: http.o
+git-mailinfo$X: mailinfo.o $(LIB_FILE)
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
+
 git-local-fetch$X: fetch.o
 git-ssh-fetch$X: rsh.o fetch.o
 git-ssh-upload$X: rsh.o
 git-ssh-pull$X: rsh.o fetch.o
 git-ssh-push$X: rsh.o
 
-git-http-fetch$X: LIBS += $(CURL_LIBCURL)
-git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
-git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
+git-http-fetch$X: fetch.o http.o http-fetch.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(CURL_LIBCURL)
+
+git-http-push$X: http.o http-push.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
+
+git-rev-list$X: rev-list.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(OPENSSL_LIBSSL)
 
 init-db.o: init-db.c
 	$(CC) -c $(ALL_CFLAGS) \
-		-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
+		-DDEFAULT_GIT_TEMPLATE_DIR=$(template_dir_QUOTED) $*.c
 
 $(LIB_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
@@ -531,13 +552,13 @@ check:
 ### Installation rules
 
 install: all
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(gitexecdir))
-	$(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(gitexecdir))
-	$(INSTALL) git$X gitk $(call shellquote,$(DESTDIR)$(bindir))
+	$(INSTALL) -d -m755 $(DESTDIR_bindir_QUOTED)
+	$(INSTALL) -d -m755 $(DESTDIR_gitexecdir_QUOTED)
+	$(INSTALL) $(ALL_PROGRAMS) $(DESTDIR_gitexecdir_QUOTED)
+	$(INSTALL) git$X gitk $(DESTDIR_bindir_QUOTED)
 	$(MAKE) -C templates install
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
-	$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
+	$(INSTALL) -d -m755 $(DESTDIR_GIT_PYTHON_DIR_QUOTED)
+	$(INSTALL) $(PYMODULES) $(DESTDIR_GIT_PYTHON_DIR_QUOTED)
 
 install-doc:
 	$(MAKE) -C Documentation install
diff --git a/t/Makefile b/t/Makefile
index 5c5a620..d78404f 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -8,17 +8,14 @@ SHELL_PATH ?= $(SHELL)
 TAR ?= $(TAR)
 
 # Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
+SHELL_PATH_QUOTED = '$(subst ','\'',$(SHELL_PATH))'
 
 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 
 all: $(T) clean
 
 $(T):
-	@echo "*** $@ ***"; $(call shellquote,$(SHELL_PATH)) $@ $(GIT_TEST_OPTS)
+	@echo "*** $@ ***"; $(SHELL_PATH_QUOTED) $@ $(GIT_TEST_OPTS)
 
 clean:
 	rm -fr trash
-- 
1.2.1.g09fe-dirty
Jason Riedy· Feb 17, 2006, 17:15 UTC · re: Johannes Schindelin · lore

Re: [PATCH 1/5] Fixes for ancient versions of GNU make

And Johannes Schindelin writes:
 - 
 - Some version of GNU make do not understand $(call), and have 
 - problems to interpret rules like this:

Is building a newer version of GNU make impossible on Irix? Thankfully, I haven't had to deal with that OS in quite some time.

Jason
Johannes Schindelin· Feb 17, 2006, 23:29 UTC · re: Jason Riedy · lore

Re: [PATCH 1/5] Fixes for ancient versions of GNU make

Hi,
On Fri, 17 Feb 2006, Jason Riedy wrote:
Show 6 quoted lines
> And Johannes Schindelin writes:
>  - 
>  - Some version of GNU make do not understand $(call), and have 
>  - problems to interpret rules like this:
> 
> Is building a newer version of GNU make impossible on Irix?

No. But it is annoying to be forced to upgrade every second package. If there'd be some real benefit, then okay, I'd do it. But there is really no point in not supporting the old version.

Besides, in some environments you are just not allowed to go wild installing programs. And in some environments, you just don't have the quota.

Hth, Dscho

Junio C Hamano· Feb 18, 2006, 06:50 UTC · re: Johannes Schindelin · lore

Re: [PATCH 1/5] Fixes for ancient versions of GNU make

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 21 quoted lines
> diff --git a/Makefile b/Makefile
> index d7d79de..b3401ac 100644
> --- a/Makefile
> +++ b/Makefile
> ...
> +# These will be used inside ''
> +SHELL_PATH_QUOTED = $(subst ','\'',$(SHELL_PATH))
> ...
> diff --git a/t/Makefile b/t/Makefile
> index 5c5a620..d78404f 100644
> --- a/t/Makefile
> +++ b/t/Makefile
> @@ -8,17 +8,14 @@ SHELL_PATH ?= $(SHELL)
>  TAR ?= $(TAR)
>  
>  # Shell quote;
> -# Result of this needs to be placed inside ''
> -shq = $(subst ','\'',$(1))
> -# This has surrounding ''
> -shellquote = '$(call shq,$(1))'
> +SHELL_PATH_QUOTED = '$(subst ','\'',$(SHELL_PATH))'

I am not opposed to avoiding $(call), but subst everywhere look ugly ;-).

You inherited this problem, but these two symbols in different Makefiles with the same name mean two completely different things, which confused me quite badly.

So if we were to do this portability fix, how about consistently defining it without surrounding sq pair? Most of the places in the main Makefile you use the symbol with other string, with the whole thing quoted inside a sq pair, so that would make things easier to read.

Then the one that uses it in the t/Makefile in 5/5 becomes:
        $(T):
                @echo "*** $@ ***"; '$(SHELL_PATH_QUOTED)' $@ $(GIT_TEST_OPTS)
Johannes Schindelin· Feb 18, 2006, 11:40 UTC · re: Junio C Hamano · lore

Some versions of GNU make do not understand $(call), and have problems to interpret rules like this:

some_target: CFLAGS += -Dsome=defs
Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
---
	On Fri, 17 Feb 2006, Junio C Hamano wrote:
	> I am not opposed to avoiding $(call), but subst everywhere look
	> ugly ;-).
	Agreed. But I think it is a minor hassle for few, and an 
	improvement for	more.
	> You inherited this problem, but these two symbols in different
	> Makefiles with the same name mean two completely different
	> things, which confused me quite badly.
	Fixed. Tested. Works.
 Makefile   |   69 ++++++++++++++++++++++++++++++++++++++----------------------
 t/Makefile |    7 ++----
 2 files changed, 46 insertions(+), 30 deletions(-)
165dab0734398530da84da3ae6df37f33293c660
Show changes to 2 files +46 −30

Makefile, t/Makefile

diff --git a/Makefile b/Makefile
index d7d79de..0a978c2 100644
--- a/Makefile
+++ b/Makefile
@@ -203,12 +203,6 @@ LIB_OBJS = \
 LIBS = $(LIB_FILE)
 LIBS += -lz
 
-# Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
-
 #
 # Platform specific tweaks
 #
@@ -413,7 +407,22 @@ endif
 endif
 endif
 
-ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)
+# Shell quote (do not use $(call) to accomodate ancient setups);
+
+SHA1_HEADER_QUOTED = $(subst ','\'',$(SHA1_HEADER))
+template_dir_QUOTED = $(subst ','\'',$(template_dir))
+
+SHELL_PATH_QUOTED = $(subst ','\'',$(SHELL_PATH))
+PERL_PATH_QUOTED = $(subst ','\'',$(PERL_PATH))
+PYTHON_PATH_QUOTED = $(subst ','\'',$(PYTHON_PATH))
+GIT_PYTHON_DIR_QUOTED = $(subst ','\'',$(GIT_PYTHON_DIR))
+
+# prepend DESTDIR to these
+DESTDIR_bindir_QUOTED = $(subst ','\'',$(DESTDIR)$(bindir))
+DESTDIR_gitexecdir_QUOTED = $(subst ','\'',$(DESTDIR)$(gitexecdir))
+DESTDIR_GIT_PYTHON_DIR_QUOTED = $(subst ','\'',$(DESTDIR)$(GIT_PYTHON_DIR))
+
+ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_QUOTED)' $(COMPAT_CFLAGS)
 LIB_OBJS += $(COMPAT_OBJS)
 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
 ### Build rules
@@ -432,7 +441,7 @@ git$X: git.c $(LIB_FILE)
 
 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	rm -f $@
-	sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
+	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_QUOTED)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 	    $@.sh >$@
@@ -440,15 +449,15 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.
 
 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
 	rm -f $@
-	sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
+	sed -e '1s|#!.*perl|#!$(PERL_PATH_QUOTED)|' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@
 	chmod +x $@
 
 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
 	rm -f $@
-	sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
-	    -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
+	sed -e '1s|#!.*python|#!$(PYTHON_PATH_QUOTED)|' \
+	    -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_QUOTED)|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.py >$@
 	chmod +x $@
@@ -474,32 +483,42 @@ git$X git.spec \
 %.o: %.S
 	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
 
-exec_cmd.o: ALL_CFLAGS += -DGIT_EXEC_PATH=\"$(gitexecdir)\"
+exec_cmd.o: exec_cmd.c
+	$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_EXEC_PATH=\"$(gitexecdir)\" $<
 
 git-%$X: %.o $(LIB_FILE)
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
-git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
 $(SIMPLE_PROGRAMS) : git-%$X : %.o
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(LIB_FILE) $(SIMPLE_LIB)
 
-git-http-fetch$X: fetch.o http.o
-git-http-push$X: http.o
+git-mailinfo$X: mailinfo.o $(LIB_FILE)
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
+
 git-local-fetch$X: fetch.o
 git-ssh-fetch$X: rsh.o fetch.o
 git-ssh-upload$X: rsh.o
 git-ssh-pull$X: rsh.o fetch.o
 git-ssh-push$X: rsh.o
 
-git-http-fetch$X: LIBS += $(CURL_LIBCURL)
-git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
-git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
+git-http-fetch$X: fetch.o http.o http-fetch.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(CURL_LIBCURL)
+
+git-http-push$X: http.o http-push.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
+
+git-rev-list$X: rev-list.o
+	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(OPENSSL_LIBSSL)
 
 init-db.o: init-db.c
 	$(CC) -c $(ALL_CFLAGS) \
-		-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
+		-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_QUOTED)"' $*.c
 
 $(LIB_OBJS): $(LIB_H)
 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
@@ -531,13 +550,13 @@ check:
 ### Installation rules
 
 install: all
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(gitexecdir))
-	$(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(gitexecdir))
-	$(INSTALL) git$X gitk $(call shellquote,$(DESTDIR)$(bindir))
+	$(INSTALL) -d -m755 '$(DESTDIR_bindir_QUOTED)'
+	$(INSTALL) -d -m755 '$(DESTDIR_gitexecdir_QUOTED)'
+	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_gitexecdir_QUOTED)'
+	$(INSTALL) git$X gitk $(DESTDIR_bindir_QUOTED)'
 	$(MAKE) -C templates install
-	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
-	$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
+	$(INSTALL) -d -m755 '$(DESTDIR_GIT_PYTHON_DIR_QUOTED)'
+	$(INSTALL) $(PYMODULES) '$(DESTDIR_GIT_PYTHON_DIR_QUOTED)'
 
 install-doc:
 	$(MAKE) -C Documentation install
diff --git a/t/Makefile b/t/Makefile
index 5c5a620..e7e4229 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -8,17 +8,14 @@ SHELL_PATH ?= $(SHELL)
 TAR ?= $(TAR)
 
 # Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
+SHELL_PATH_QUOTED = $(subst ','\'',$(SHELL_PATH))
 
 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 
 all: $(T) clean
 
 $(T):
-	@echo "*** $@ ***"; $(call shellquote,$(SHELL_PATH)) $@ $(GIT_TEST_OPTS)
+	@echo "*** $@ ***"; '$(SHELL_PATH_QUOTED)' $@ $(GIT_TEST_OPTS)
 
 clean:
 	rm -fr trash
-- 
1.2.1.geb73

← back to recent threads