@matheusbsbs / matheus-bagliano / commits / 499c29394c
Fork 0

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>

Jeff King committed Apr 3, 2009 at 15:32 UTC 499c29394ce1ead3ebd29b0d3c8014cdb7a32e63
2 files changed +29 -2
Makefile
+25 -2
@@ -145,6 +145,8 @@ all::
145 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
146 # MakeMaker (e.g. using ActiveState under Cygwin).
147 #
148 +# Define NO_PERL if you do not want Perl scripts or libraries at all.
149 +#
150 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
151 #
152 # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -353,7 +355,10 @@ BUILT_INS += git-whatchanged$X
355 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
356
357 # 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
362
363 # Set paths to tools early so that they can be used for version tests.
364 ifndef SHELL_PATH
@@ -1104,6 +1109,10 @@ ifeq ($(TCLTK_PATH),)
1109 NO_TCLTK=NoThanks
1110 endif
1111
1112 +ifeq ($(PERL_PATH),)
1113 +NO_PERL=NoThanks
1114 +endif
1115 +
1116 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
1117 QUIET_SUBDIR1 =
1118
@@ -1178,7 +1187,9 @@ ifndef NO_TCLTK
1187 $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
1188 $(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1189 endif
1190 +ifndef NO_PERL
1191 $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
1192 +endif
1193 $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
1194
1195 please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -1226,6 +1237,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
1237 chmod +x $@+ && \
1238 mv $@+ $@
1239
1240 +ifndef NO_PERL
1241 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
1242
1243 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
1297 $@.sh > $@+ && \
1298 chmod +x $@+ && \
1299 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
1309
1310 configure: configure.ac
1311 $(QUIET_GEN)$(RM) $@ $<+ && \
@@ -1603,9 +1624,11 @@ clean:
1624 $(RM) -r $(GIT_TARNAME) .doc-tmp-dir
1625 $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
1626 $(RM) $(htmldocs).tar.gz $(manpages).tar.gz
1606 - $(RM) gitweb/gitweb.cgi
1627 $(MAKE) -C Documentation/ clean
1628 +ifndef NO_PERL
1629 + $(RM) gitweb/gitweb.cgi
1630 $(MAKE) -C perl clean
1631 +endif
1632 $(MAKE) -C templates/ clean
1633 $(MAKE) -C t/ clean
1634 ifndef NO_TCLTK
unimplemented.sh new
+4
@@ -0,0 +1,4 @@
1 +#!/bin/sh
2 +
3 +echo >&2 "fatal: git was built without support for `basename $0` (@@REASON@@)."
4 +exit 128