# [PATCH] Fix compilation

4 messages from 2006-07-06 to 2006-07-08. Participants: Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/4790

## Johannes Schindelin, 2006-07-06 23:21

Subject: [PATCH] Fix compilation
Message-ID: <Pine.LNX.4.63.0607070120590.29667@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0607070120590.29667%40wbgn013.biozentrum.uni-wuerzburg.de

```

Without this, make 3.79.1 (Darwin) says

rm -f git-archimport git-archimport+
INSTLIBDIR=`make -C perl -s --no-print-directory instlibdir` && \
sed -e '1s|#!.*perl|#!/usr/bin/perl|1' \
    -e '2i\
        use lib (split(/:/, $ENV{GITPERLLIB} || '\'"$INSTLIBDIR"\''));' \
    -e 's|@@INSTLIBDIR@@|'"$INSTLIBDIR"'|g' \
    -e 's/@@GIT_VERSION@@/1.4.1.gb564-dirty/g' \
    git-archimport.perl >git-archimport+
sed: 1: "2i use lib (split(/:/,  ...": command i expects \ followed by text

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	Note that this just fixes compilation, not the tests. All of
	a sudden, I have to install Scalar::Util, where things were
	fine before Git.pm.

	Note also, that this patch relies on the perl scripts not
	caring if an additional command is shifted into the 2nd line.
	I checked all of them, and they don't.

 Makefile |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -563,8 +563,7 @@ common-cmds.h: Documentation/git-*.txt
 	rm -f $@ $@+
 	INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
 	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|1' \
-	    -e '2i\
-	        use lib (split(/:/, $$ENV{GITPERLLIB} || '\'"$$INSTLIBDIR"\''));' \
+	    -e "2s=^=use lib (split(/:/, \$$ENV{GITPERLLIB} || \'$$INSTLIBDIR\')); =g" \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@+

```

## Junio C Hamano, 2006-07-07 00:15

Subject: Re: [PATCH] Fix compilation
Message-ID: <7vmzbm46e4.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmzbm46e4.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0607070120590.29667@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Without this, make 3.79.1 (Darwin) says
>
> rm -f git-archimport git-archimport+
> INSTLIBDIR=`make -C perl -s --no-print-directory instlibdir` && \
> sed -e '1s|#!.*perl|#!/usr/bin/perl|1' \
>     -e '2i\
>         use lib (split(/:/, $ENV{GITPERLLIB} || '\'"$INSTLIBDIR"\''));' \
>     -e 's|@@INSTLIBDIR@@|'"$INSTLIBDIR"'|g' \
>     -e 's/@@GIT_VERSION@@/1.4.1.gb564-dirty/g' \
>     git-archimport.perl >git-archimport+
> sed: 1: "2i use lib (split(/:/,  ...": command i expects \ followed by text
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

Traditionally 'i' and 'a' command to sed has been unfriendly
with make, primarily because different make implementations did
unexpected things to backslashes at the end of lines.

For portability I would even suggest making that command into a
separate helper shell script, and call that from the Makefile.

> 	Note that this just fixes compilation, not the tests. All of
> 	a sudden, I have to install Scalar::Util, where things were
> 	fine before Git.pm.

I recall Pasky talking about Scalar::Util removal and I thought
I took a patch.

 ... goes "git grep" ...

Ah the private edition of Error.pm pulls that in.  Sheesh.

```

## Junio C Hamano, 2006-07-07 20:02

Subject: Re: [PATCH] Fix compilation
Message-ID: <7vbqs1w5d0.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vbqs1w5d0.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0607070120590.29667@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 	Note also, that this patch relies on the perl scripts not
> 	caring if an additional command is shifted into the 2nd line.

How about doing something like this instead, then?

diff --git a/Makefile b/Makefile
index 71657ec..01b9a94 100644
--- a/Makefile
+++ b/Makefile
@@ -550,9 +550,13 @@ common-cmds.h: Documentation/git-*.txt
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	rm -f $@ $@+
 	INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
-	sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|1' \
-	    -e '2i\
-	        use lib (split(/:/, $$ENV{GITPERLLIB} || '\'"$$INSTLIBDIR"\''));' \
+	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 >$@+

```

## Johannes Schindelin, 2006-07-08 02:04

Subject: Re: [PATCH] Fix compilation
Message-ID: <Pine.LNX.4.63.0607080403470.29667@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0607080403470.29667%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vbqs1w5d0.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Fri, 7 Jul 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > 	Note also, that this patch relies on the perl scripts not
> > 	caring if an additional command is shifted into the 2nd line.
> 
> How about doing something like this instead, then?

I will try as soon as possible. ATM my iBook is in my car, which I had to 
leave at a friend's place, because said friend sensibly refused to let me 
drive.

Ciao,
Dscho

```
