Work around sed and make interactions on the backslash at the end of line.
[gitweb.git] / Makefile
index 703016725358c7122a211261eca946f17b31452f..01b9a948238daef7fe89dace4cba3fbe0be12aa9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -550,7 +550,13 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/Makefile
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
        rm -f $@ $@+
        INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
-       sed -e '1s|#!.*perl\(.*\)|#!$(PERL_PATH_SQ)\1|' \
+       sed -e '1{' \
+           -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
+           -e '        h' \
+           -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
+           -e '        H' \
+           -e '        x' \
+           -e '}' \
            -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            $@.perl >$@+