Skip to content

Commit 712b1dd

Browse files
author
Junio C Hamano
committed
Merge branch 'js/portable'
* js/portable: Fix "gmake -j" Really honour NO_PYTHON avoid makefile override warning Fixes for ancient versions of GNU make
2 parents d800795 + b992933 commit 712b1dd

File tree

2 files changed

+50
-33
lines changed

2 files changed

+50
-33
lines changed

Makefile

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
142142

143143
# The ones that do not have to link with lcrypto nor lz.
144144
SIMPLE_PROGRAMS = \
145-
git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
145+
git-get-tar-commit-id$X git-mailsplit$X \
146146
git-stripspace$X git-daemon$X
147147

148148
# ... and all the rest that could be moved out of bindir to gitexecdir
@@ -210,12 +210,6 @@ LIB_OBJS = \
210210
LIBS = $(LIB_FILE)
211211
LIBS += -lz
212212

213-
# Shell quote;
214-
# Result of this needs to be placed inside ''
215-
shq = $(subst ','\'',$(1))
216-
# This has surrounding ''
217-
shellquote = '$(call shq,$(1))'
218-
219213
#
220214
# Platform specific tweaks
221215
#
@@ -299,8 +293,10 @@ endif
299293
ifdef WITH_OWN_SUBPROCESS_PY
300294
PYMODULES += compat/subprocess.py
301295
else
302-
ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
303-
PYMODULES += compat/subprocess.py
296+
ifeq ($(NO_PYTHON),)
297+
ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
298+
PYMODULES += compat/subprocess.py
299+
endif
304300
endif
305301
endif
306302

@@ -424,7 +420,21 @@ ifdef NO_ACCURATE_DIFF
424420
ALL_CFLAGS += -DNO_ACCURATE_DIFF
425421
endif
426422

427-
ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)
423+
# Shell quote (do not use $(call) to accomodate ancient setups);
424+
425+
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
426+
427+
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
428+
bindir_SQ = $(subst ','\'',$(bindir))
429+
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
430+
template_dir_SQ = $(subst ','\'',$(template_dir))
431+
432+
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
433+
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
434+
PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
435+
GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
436+
437+
ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
428438
LIB_OBJS += $(COMPAT_OBJS)
429439
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
430440
### Build rules
@@ -443,7 +453,7 @@ git$X: git.c $(LIB_FILE)
443453

444454
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
445455
rm -f $@
446-
sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
456+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
447457
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
448458
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
449459
-e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
@@ -452,15 +462,15 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
452462

453463
$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
454464
rm -f $@
455-
sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
465+
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
456466
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
457467
$@.perl >$@
458468
chmod +x $@
459469

460470
$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
461471
rm -f $@
462-
sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
463-
-e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
472+
sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
473+
-e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
464474
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
465475
$@.py >$@
466476
chmod +x $@
@@ -486,32 +496,42 @@ git$X git.spec \
486496
%.o: %.S
487497
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
488498

489-
exec_cmd.o: ALL_CFLAGS += -DGIT_EXEC_PATH=\"$(gitexecdir)\"
499+
exec_cmd.o: exec_cmd.c
500+
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
490501

491502
git-%$X: %.o $(LIB_FILE)
492503
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
493504

494-
git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
495505
$(SIMPLE_PROGRAMS) : $(LIB_FILE)
496506
$(SIMPLE_PROGRAMS) : git-%$X : %.o
497507
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
498508
$(LIB_FILE) $(SIMPLE_LIB)
499509

500-
git-http-fetch$X: fetch.o http.o
501-
git-http-push$X: http.o
510+
git-mailinfo$X: mailinfo.o $(LIB_FILE)
511+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
512+
$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
513+
502514
git-local-fetch$X: fetch.o
503515
git-ssh-fetch$X: rsh.o fetch.o
504516
git-ssh-upload$X: rsh.o
505517
git-ssh-pull$X: rsh.o fetch.o
506518
git-ssh-push$X: rsh.o
507519

508-
git-http-fetch$X: LIBS += $(CURL_LIBCURL)
509-
git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
510-
git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
520+
git-http-fetch$X: fetch.o http.o http-fetch.o $(LIB_FILE)
521+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
522+
$(LIBS) $(CURL_LIBCURL)
523+
524+
git-http-push$X: http.o http-push.o $(LIB_FILE)
525+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
526+
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
527+
528+
git-rev-list$X: rev-list.o $(LIB_FILE)
529+
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
530+
$(LIBS) $(OPENSSL_LIBSSL)
511531

512532
init-db.o: init-db.c
513533
$(CC) -c $(ALL_CFLAGS) \
514-
-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
534+
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $*.c
515535

516536
$(LIB_OBJS): $(LIB_H)
517537
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
@@ -549,13 +569,13 @@ check:
549569
### Installation rules
550570

551571
install: all
552-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
553-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(gitexecdir))
554-
$(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(gitexecdir))
555-
$(INSTALL) git$X gitk $(call shellquote,$(DESTDIR)$(bindir))
572+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
573+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
574+
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
575+
$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
556576
$(MAKE) -C templates install
557-
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
558-
$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
577+
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
578+
$(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
559579

560580
install-doc:
561581
$(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)