Skip to content

Commit 39c015c

Browse files
dschoJunio C Hamano
authored andcommitted
Fixes for ancient versions of GNU make
Some versions of GNU make do not understand $(call), and have problems to interpret rules like this: some_target: CFLAGS += -Dsome=defs [jc: simplified substitution a bit. ] Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent abb7c7b commit 39c015c

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

Makefile

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ LIB_OBJS = \
204204
LIBS = $(LIB_FILE)
205205
LIBS += -lz
206206

207-
# Shell quote;
208-
# Result of this needs to be placed inside ''
209-
shq = $(subst ','\'',$(1))
210-
# This has surrounding ''
211-
shellquote = '$(call shq,$(1))'
212-
213207
#
214208
# Platform specific tweaks
215209
#
@@ -422,7 +416,21 @@ ifdef NO_ACCURATE_DIFF
422416
ALL_CFLAGS += -DNO_ACCURATE_DIFF
423417
endif
424418

425-
ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)
419+
# Shell quote (do not use $(call) to accomodate ancient setups);
420+
421+
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
422+
423+
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
424+
bindir_SQ = $(subst ','\'',$(bindir))
425+
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
426+
template_dir_SQ = $(subst ','\'',$(template_dir))
427+
428+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
429+
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
430+
PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
431+
GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
432+
433+
ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
426434
LIB_OBJS += $(COMPAT_OBJS)
427435
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
428436
### Build rules
@@ -441,7 +449,7 @@ git$X: git.c $(LIB_FILE)
441449

442450
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
443451
rm -f $@
444-
sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
452+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
445453
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
446454
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
447455
-e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
@@ -450,15 +458,15 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
450458

451459
$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
452460
rm -f $@
453-
sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
461+
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
454462
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
455463
$@.perl >$@
456464
chmod +x $@
457465

458466
$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
459467
rm -f $@
460-
sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
461-
-e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
468+
sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
469+
-e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
462470
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
463471
$@.py >$@
464472
chmod +x $@
@@ -484,32 +492,42 @@ git$X git.spec \
484492
%.o: %.S
485493
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
486494

487-
exec_cmd.o: ALL_CFLAGS += -DGIT_EXEC_PATH=\"$(gitexecdir)\"
495+
exec_cmd.o: exec_cmd.c
496+
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
488497

489498
git-%$X: %.o $(LIB_FILE)
490499
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
491500

492-
git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
493501
$(SIMPLE_PROGRAMS) : $(LIB_FILE)
494502
$(SIMPLE_PROGRAMS) : git-%$X : %.o
495503
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
496504
$(LIB_FILE) $(SIMPLE_LIB)
497505

498-
git-http-fetch$X: fetch.o http.o
499-
git-http-push$X: http.o
506+
git-mailinfo$X: mailinfo.o $(LIB_FILE)
507+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
508+
$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
509+
500510
git-local-fetch$X: fetch.o
501511
git-ssh-fetch$X: rsh.o fetch.o
502512
git-ssh-upload$X: rsh.o
503513
git-ssh-pull$X: rsh.o fetch.o
504514
git-ssh-push$X: rsh.o
505515

506-
git-http-fetch$X: LIBS += $(CURL_LIBCURL)
507-
git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
508-
git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
516+
git-http-fetch$X: fetch.o http.o http-fetch.o
517+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
518+
$(LIBS) $(CURL_LIBCURL)
519+
520+
git-http-push$X: http.o http-push.o
521+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
522+
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
523+
524+
git-rev-list$X: rev-list.o
525+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
526+
$(LIBS) $(OPENSSL_LIBSSL)
509527

510528
init-db.o: init-db.c
511529
$(CC) -c $(ALL_CFLAGS) \
512-
-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
530+
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $*.c
513531

514532
$(LIB_OBJS): $(LIB_H)
515533
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
@@ -547,13 +565,13 @@ check:
547565
### Installation rules
548566

549567
install: all
550-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
551-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(gitexecdir))
552-
$(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(gitexecdir))
553-
$(INSTALL) git$X gitk $(call shellquote,$(DESTDIR)$(bindir))
568+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
569+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
570+
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
571+
$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
554572
$(MAKE) -C templates install
555-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
556-
$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
573+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
574+
$(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
557575

558576
install-doc:
559577
$(MAKE) -C Documentation install

t/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ SHELL_PATH ?= $(SHELL)
88
TAR ?= $(TAR)
99

1010
# Shell quote;
11-
# Result of this needs to be placed inside ''
12-
shq = $(subst ','\'',$(1))
13-
# This has surrounding ''
14-
shellquote = '$(call shq,$(1))'
11+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1512

1613
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
1714

@@ -22,7 +19,7 @@ endif
2219
all: $(T) clean
2320

2421
$(T):
25-
@echo "*** $@ ***"; $(call shellquote,$(SHELL_PATH)) $@ $(GIT_TEST_OPTS)
22+
@echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
2623

2724
clean:
2825
rm -fr trash

0 commit comments

Comments
 (0)