Skip to content

Commit 499c293

Browse files
peffgitster
authored andcommitted
Makefile: allow building without perl
For systems with a missing or broken perl, it is nicer to explicitly say "we don't want perl" because: 1. The Makefile knows not to bother with Perl-ish things like Git.pm. 2. We can print a more user-friendly error message than "foo is not a git command" or whatever the broken perl might barf 3. Test scripts that require perl can mark themselves and such and be skipped This patch implements parts (1) and (2). The perl/ subdirectory is skipped entirely, gitweb is not built, and any git commands which rely on perl will print a human-readable message and exit with an error code. This patch is based on one from Robin H. Johnson. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6da14ee commit 499c293

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

Makefile

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ all::
145145
# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
146146
# MakeMaker (e.g. using ActiveState under Cygwin).
147147
#
148+
# Define NO_PERL if you do not want Perl scripts or libraries at all.
149+
#
148150
# Define NO_TCLTK if you do not want Tcl/Tk GUI.
149151
#
150152
# The TCL_PATH variable governs the location of the Tcl interpreter
@@ -353,7 +355,10 @@ BUILT_INS += git-whatchanged$X
353355
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
354356

355357
# what 'all' will build but not install in gitexecdir
356-
OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
358+
OTHER_PROGRAMS = git$X
359+
ifndef NO_PERL
360+
OTHER_PROGRAMS += gitweb/gitweb.cgi
361+
endif
357362

358363
# Set paths to tools early so that they can be used for version tests.
359364
ifndef SHELL_PATH
@@ -1104,6 +1109,10 @@ ifeq ($(TCLTK_PATH),)
11041109
NO_TCLTK=NoThanks
11051110
endif
11061111

1112+
ifeq ($(PERL_PATH),)
1113+
NO_PERL=NoThanks
1114+
endif
1115+
11071116
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
11081117
QUIET_SUBDIR1 =
11091118

@@ -1178,7 +1187,9 @@ ifndef NO_TCLTK
11781187
$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
11791188
$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
11801189
endif
1190+
ifndef NO_PERL
11811191
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1192+
endif
11821193
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
11831194

11841195
please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -1226,6 +1237,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
12261237
chmod +x $@+ && \
12271238
mv $@+ $@
12281239

1240+
ifndef NO_PERL
12291241
$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
12301242

12311243
perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
@@ -1285,6 +1297,15 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
12851297
$@.sh > $@+ && \
12861298
chmod +x $@+ && \
12871299
mv $@+ $@
1300+
else # NO_PERL
1301+
$(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
1302+
$(QUIET_GEN)$(RM) $@ $@+ && \
1303+
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1304+
-e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
1305+
unimplemented.sh >$@+ && \
1306+
chmod +x $@+ && \
1307+
mv $@+ $@
1308+
endif # NO_PERL
12881309

12891310
configure: configure.ac
12901311
$(QUIET_GEN)$(RM) $@ $<+ && \
@@ -1603,9 +1624,11 @@ clean:
16031624
$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
16041625
$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
16051626
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1606-
$(RM) gitweb/gitweb.cgi
16071627
$(MAKE) -C Documentation/ clean
1628+
ifndef NO_PERL
1629+
$(RM) gitweb/gitweb.cgi
16081630
$(MAKE) -C perl clean
1631+
endif
16091632
$(MAKE) -C templates/ clean
16101633
$(MAKE) -C t/ clean
16111634
ifndef NO_TCLTK

unimplemented.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
echo >&2 "fatal: git was built without support for `basename $0` (@@REASON@@)."
4+
exit 128

0 commit comments

Comments
 (0)