# [PATCH] documentation: Makefile accounts for SHELL_PATH setting

4 messages from 2009-03-21 to 2009-03-22. Participants: Ben Walton, Jeff King.
Thread: https://gitlist.dev/t/18443

## Ben Walton, 2009-03-21 02:40

Subject: [PATCH] documentation: Makefile accounts for SHELL_PATH setting
Message-ID: <1237603220-22897-1-git-send-email-bwalton@artsci.utoronto.ca>
URL: https://gitlist.dev/e/1237603220-22897-1-git-send-email-bwalton%40artsci.utoronto.ca

```
Take SHELL_PATH into account, if set, in Documentation/Makefile.  This
allows the caller to provide a shell capable of running the install
scripts on systems where sh is not bash.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 Documentation/Makefile |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 144ec32..2eb5a72 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -67,6 +67,11 @@ ASCIIDOC_EXTRA += -a docbook-xsl-172
 MANPAGE_XSL = manpage-1.72.xsl
 endif
 
+#retain original (but broken) behaviour if SHELL_PATH isn't overridden
+ifndef SHELL_PATH
+	SHELL_PATH = sh
+endif
+
 #
 # Please note that there is a minor bug in asciidoc.
 # The version after 6.0.3 _will_ include the patch found here:
@@ -116,7 +121,7 @@ install-pdf: pdf
 	$(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
 
 install-html: html
-	sh ./install-webdoc.sh $(DESTDIR)$(htmldir)
+	$(SHELL_PATH) ./install-webdoc.sh $(DESTDIR)$(htmldir)
 
 ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 	$(MAKE) -C ../ GIT-VERSION-FILE
@@ -178,7 +183,7 @@ user-manual.xml: user-manual.txt user-manual.conf
 
 technical/api-index.txt: technical/api-index-skel.txt \
 	technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
-	cd technical && sh ./api-index.sh
+	cd technical && $(SHELL_PATH) ./api-index.sh
 
 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
 	$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
@@ -220,7 +225,7 @@ $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
 
 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
 	$(RM) $@+ $@
-	sh ./howto-index.sh $(wildcard howto/*.txt) >$@+
+	$(SHELL_PATH) ./howto-index.sh $(wildcard howto/*.txt) >$@+
 	mv $@+ $@
 
 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
@@ -234,14 +239,14 @@ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
 	mv $@+ $@
 
 install-webdoc : html
-	sh ./install-webdoc.sh $(WEBDOC_DEST)
+	$(SHELL_PATH) ./install-webdoc.sh $(WEBDOC_DEST)
 
 quick-install: quick-install-man
 
 quick-install-man:
-	sh ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
+	$(SHELL_PATH) ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
 
 quick-install-html:
-	sh ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
+	$(SHELL_PATH) ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
 
 .PHONY: .FORCE-GIT-VERSION-FILE
-- 
1.6.0.5

```

## Jeff King, 2009-03-21 03:22

Subject: Re: [PATCH] documentation: Makefile accounts for SHELL_PATH setting
Message-ID: <20090321032240.GA31547@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090321032240.GA31547%40coredump.intra.peff.net
In-Reply-To: <1237603220-22897-1-git-send-email-bwalton@artsci.utoronto.ca>

```
On Fri, Mar 20, 2009 at 10:40:20PM -0400, Ben Walton wrote:

> Take SHELL_PATH into account, if set, in Documentation/Makefile.  This
> allows the caller to provide a shell capable of running the install
> scripts on systems where sh is not bash.

Makes sense.

> +#retain original (but broken) behaviour if SHELL_PATH isn't overridden
> +ifndef SHELL_PATH
> +	SHELL_PATH = sh
> +endif

The Makefile in t/Makefile does:

  SHELL_PATH ?= $(SHELL)

which I think makes more sense (and yes, yours actually keeps the
existing behavior, but it's probably better to inherit from SHELL in
case it is set to something more useful).

>  install-html: html
> -	sh ./install-webdoc.sh $(DESTDIR)$(htmldir)
> +	$(SHELL_PATH) ./install-webdoc.sh $(DESTDIR)$(htmldir)

You need a SHELL_PATH_SQ to handle paths with spaces; see t/Makefile for
an example.

I wonder if both subdirs should simply be pulling from
GIT-BUILD-OPTIONS, though, which would allow this to use the specified
SHELL_PATH:

  $ make SHELL_PATH=whatever
  $ cd Documentation && make

but maybe it is not worth caring about (since it may complicate building
Documentation if you _haven't_ build the actual code).

-Peff

```

## Ben Walton, 2009-03-21 11:38

Subject: Re: [PATCH] documentation: Makefile accounts for SHELL_PATH setting
Message-ID: <1237635198-sup-2111@ntdws12.chass.utoronto.ca>
URL: https://gitlist.dev/e/1237635198-sup-2111%40ntdws12.chass.utoronto.ca
In-Reply-To: <20090321032240.GA31547@coredump.intra.peff.net>

```
Excerpts from Jeff King's message of Fri Mar 20 23:22:40 -0400 2009:
> > +#retain original (but broken) behaviour if SHELL_PATH isn't overridden
> > +ifndef SHELL_PATH
> > +    SHELL_PATH = sh
> > +endif
> 
> The Makefile in t/Makefile does:
> 
>   SHELL_PATH ?= $(SHELL)
> 
> which I think makes more sense (and yes, yours actually keeps the
> existing behavior, but it's probably better to inherit from SHELL in
> case it is set to something more useful).

I used the ifndef/endif setup becuase that's how the PERL_PATH was set
and also becuase I think it's slightly more explicit.  I'm ok with ?=
though too.  I had considered using $(SHELL), but discarded it because
it veered from the current behaviour.  I agree that $(SHELL) is likely
better than sh though.

> >  install-html: html
> > -    sh ./install-webdoc.sh $(DESTDIR)$(htmldir)
> > +    $(SHELL_PATH) ./install-webdoc.sh $(DESTDIR)$(htmldir)
> 
> You need a SHELL_PATH_SQ to handle paths with spaces; see t/Makefile for
> an example.

Ok.  I'll look at this and implement the _SQ bits too to make it safer
and more general.

> I wonder if both subdirs should simply be pulling from
> GIT-BUILD-OPTIONS, though, which would allow this to use the specified
> SHELL_PATH:
> 
>   $ make SHELL_PATH=whatever
>   $ cd Documentation && make
> 
> but maybe it is not worth caring about (since it may complicate building
> Documentation if you _haven't_ build the actual code).

In my case, I'm using the configure script and then running make,
which sees the Documentation/Makefile source in the ../config.mak
files, so there may be some variance between pure make and make +
autoconf in this respect.  I hadn't looked at it in that light.
Should this be reconciled too?

I'm away today, but will try to correct this patch when I get home.

Thanks
-Ben
-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

GPG Key Id: 8E89F6D2; Key Server: pgp.mit.edu
Contact me to arrange for a CAcert assurance meeting.

```

## Jeff King, 2009-03-22 06:19

Subject: Re: [PATCH] documentation: Makefile accounts for SHELL_PATH setting
Message-ID: <20090322061946.GC14765@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090322061946.GC14765%40coredump.intra.peff.net
In-Reply-To: <1237635198-sup-2111@ntdws12.chass.utoronto.ca>

```
On Sat, Mar 21, 2009 at 07:38:35AM -0400, Ben Walton wrote:

> I used the ifndef/endif setup becuase that's how the PERL_PATH was set
> and also becuase I think it's slightly more explicit.  I'm ok with ?=

I can't think of any reason why the two would not be equivalent
functionally. I would generally use ?= because it is more portable, but
we are inextricably bound to gmake at this point, so I don't think that
matters. So I don't have a strong preference.

> > but maybe it is not worth caring about (since it may complicate building
> > Documentation if you _haven't_ build the actual code).
> 
> In my case, I'm using the configure script and then running make,
> which sees the Documentation/Makefile source in the ../config.mak
> files, so there may be some variance between pure make and make +
> autoconf in this respect.  I hadn't looked at it in that light.
> Should this be reconciled too?

Oh, right, I forgot that it pulls in config.mak. So it is really a
non-issue if you are putting SHELL_PATH in your config.mak (or defining
it via autoconf). So nevermind my ramblings in that direction.

I think it should be fine to just resend your patch with:

  1. default to $(SHELL)

  2. quote $(SHELL_PATH) as appropriate

-Peff

```
