[Top][All Lists]

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

Re: Idea: Enable .ONESHELL to be per-target

From: Britton Kerin
Subject: Re: Idea: Enable .ONESHELL to be per-target
Date: Mon, 10 Jun 2019 11:47:19 -0800

On Mon, Jun 10, 2019 at 4:56 AM David A. Wheeler <address@hidden> wrote:
> Another idea: Enable .ONESHELL to be per-target.
> Problem: According to the docs .ONESHELL is global in effect,
> so using it in an existing makefile requires a lot of rework.

Strongly seconded, I would definitely use this.  I've been
attracted to it many times but never dared try globally.
Would make use of shell vars much less ugly and full of \
lines etc.

I do think some thought on the syntax might be in order still
though.  With some of these it's not obvious which default
sense would be more useful, e.g.

     # GLobal setting

     tricky_target: .NOTONESHELL:

might be what is really wanted in many cases.

I guess these would taint prereqs, like local vars do.

> In many cases .ONESHELL is primarily only useful only
> for specific rules, and there's no need to rewrite the rest.
> The current rules are also oddly inconsistent with many
> of the other special targets;
> most other special targets allow a list of dependencies where
> it makes sense to support them.
> Solution:
> Let's expand .ONESHELL so that
> if specific prerequisites are identified for it,
> it applies only to those prerequisites.
> If no prerequisites are listed, it would work just like it does now.
> As a result this change is completely backwards compatible.
> Note that this works especially well with target-specific variables,
> so you can even set SHELL and .SHELLFLAGS for a specific target:
> ~~~~
> .ONESHELL: foo
> foo: SHELL = /usr/bin/perl
> foo: .SHELLFLAGS = -e
> foo: ...
> <TAB>commands that will run as a single shell.
> ~~~~
> Note the ".SHELLFLAGS =", which is odd syntactically but should be allowed.
> This also works nicely with "Idea: Allow certain special targets as 
> dependencies":

Yes this would be nice.  And it's consistent with Make philosophy of
trying to be
very terse.  btw I assume these special prereqs would not be visible to $< etc


reply via email to

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