bug-make
[Top][All Lists]
Advanced

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

Idea: Enable .ONESHELL to be per-target


From: David A. Wheeler
Subject: Idea: Enable .ONESHELL to be per-target
Date: Mon, 10 Jun 2019 08:55:35 -0400 (EDT)

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.
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":

~~~~
bar: .ONESHELL ...
<TAB>...commands that will run as a single shell
~~~~

--- David A. Wheeler



reply via email to

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