Re: [PATCH] NO_PERL support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 03, 2009 at 09:25:21AM -0700, Junio C Hamano wrote:

> While I do not mind omitting whole programs in fringes like you did for
> archimport and relink, I *really* do not like this particular change (and
> any change to the C code).
> 
> I'd rather see something along the lines of:
> 
> 	if NO_PERL
>         git-add--interactive: unimplemented.sh
>         	rm -f $@+ $@
>                 cat $? >$@+
>                 chmod +x $@+
>                 mv $@+ $@
> 	else
>         git-add--interactive: git-add--interactive.perl
>         	... usual .perl to script rule applies
> 	endif
> 
> and ship:
> 
> 	#!/bin/sh
>         echo >&2 "Sorry $0 not available here"
>         exit 1
> 
> in unimplemented.sh, *without* touching code that calls out to
> scripts that happen to be implemented in Perl.

OK, that is more or less what I proposed elsewhere in the thread. Below
is a cleaned up version of the Makefile bits.

The test script changes should come in a different patch, but they are a
bit more complex. Tests that rely on missing scripts should obviously
just be skipped outright.  But there are some test scripts that use perl
for testing tasks (e.g., t4103), and those are not covered by Robin's
patch. Do we want to also skip those? Do we want to place the burden on
authors of the test suite to always check for NO_PERL whenever they use
perl?

The other option would be saying "we support building with NO_PERL, but
not running the test suite".

Thoughts?

-- >8 --
Subject: [PATCH] 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@xxxxxxxx>
---
 Makefile         |   23 +++++++++++++++++++++--
 unimplemented.sh |    4 ++++
 2 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100644 unimplemented.sh

diff --git a/Makefile b/Makefile
index 0675c43..44c856d 100644
--- a/Makefile
+++ b/Makefile
@@ -139,6 +139,8 @@ all::
 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
 # MakeMaker (e.g. using ActiveState under Cygwin).
 #
+# Define NO_PERL if you do not want Perl scripts or libraries at all.
+#
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
 #
 # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -335,7 +337,10 @@ BUILT_INS += git-whatchanged$X
 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
 # what 'all' will build but not install in gitexecdir
-OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
+OTHER_PROGRAMS = git$X
+ifndef NO_PERL
+OTHER_PROGRAMS += gitweb/gitweb.cgi
+endif
 
 # Set paths to tools early so that they can be used for version tests.
 ifndef SHELL_PATH
@@ -1142,7 +1147,9 @@ ifndef NO_TCLTK
 	$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
 	$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
 endif
+ifndef NO_PERL
 	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
+endif
 	$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
 
 please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -1189,6 +1196,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
 	chmod +x $@+ && \
 	mv $@+ $@
 
+ifndef NO_PERL
 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
 
 perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
@@ -1248,6 +1256,15 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
 	    $@.sh > $@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
+else # NO_PERL
+$(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
+	$(QUIET_GEN)$(RM) $@ $@+ && \
+	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
+	    unimplemented.sh >$@+ && \
+	chmod +x $@+ && \
+	mv $@+ $@
+endif # NO_PERL
 
 configure: configure.ac
 	$(QUIET_GEN)$(RM) $@ $<+ && \
@@ -1565,9 +1582,11 @@ clean:
 	$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
 	$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
 	$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
-	$(RM) gitweb/gitweb.cgi
 	$(MAKE) -C Documentation/ clean
+ifndef NO_PERL
+	$(RM) gitweb/gitweb.cgi
 	$(MAKE) -C perl clean
+endif
 	$(MAKE) -C templates/ clean
 	$(MAKE) -C t/ clean
 ifndef NO_TCLTK
diff --git a/unimplemented.sh b/unimplemented.sh
new file mode 100644
index 0000000..5252de4
--- /dev/null
+++ b/unimplemented.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo >&2 "fatal: git was built without support for `basename $0` (@@REASON@@)."
+exit 128
-- 
1.6.2.2.569.g2d4b2



> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux