help-make
[Top][All Lists]
Advanced

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

Re: Shell for evaluating .SHELLFLAGS


From: Afif Elghraoui
Subject: Re: Shell for evaluating .SHELLFLAGS
Date: Tue, 26 May 2015 09:59:12 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0

On 05/26/2015 09:15 AM, David Boyce wrote:
BTW /usr/bin/env creates a redundant process here. The reason people
use /usr/bin/env to translate an execv() (does not use PATH) to an
execvp() (does). But GNU make uses execvp() already; try "make
SHELL=sh” to see that.

-David Boyce


Thanks. That's good to know.

On Tue, May 26, 2015 at 5:14 AM, Paul Smith <address@hidden> wrote:
On Mon, 2015-05-25 at 21:05 -0700, Afif Elghraoui wrote:

SHELL=/usr/bin/env sqlite3
.SHELLFLAGS=-init <(echo ".output $@") $(DB)

I get this error:
/bin/sh: 1: Syntax error: "(" unexpected
Makefile:13: recipe for target 'fq' failed

It looks like .SHELLFLAGS is evaluated with /bin/sh regardless of what
SHELL is set to. Is there any way I could evaluate them with bash?

You're missing the main point: the values of SHELL and SHELLFLAGS aren't
being evaluated by /bin/sh, or bash... they're not being evaluated by
any shell at all!


Fair enough. I guess I was further confused that my error message was coming from /bin/sh.


The entire point of setting SHELL is you're choosing a shell that make
will invoke.  Make does not use a shell to start the shell that you
requested: it invokes the shell you requested directly (using the exec()
system calls).


Got it.

The simplest way to do what you want is create a script (outside of
make) that will operate like this, then set SHELL in your makefile to
that script.  You can use #!/bin/bash at the top of that script to
request it be run in bash, if you like.


That works out really well. My Makefile header became:

SHELL=./sqlite-wrapper.bash
# The DB variable is defined in the top-level Makefile
.SHELLFLAGS=$@ $(DB)

and the wrapper script is:

#!/bin/bash
sqlite3 -init <(cat sqliterc <(echo ".output $1")) $2 "$3"

I added here another functionality I needed. I'm very glad that it works now.


Many thanks and regards
Afif

--
Afif Elghraoui
Laboratory for Pathogenesis of Clinical Tuberculosis Drug Resistance and Persistence
San Diego State University




reply via email to

[Prev in Thread] Current Thread [Next in Thread]