Re: Idea: Allow certain special targets as dependencies

2019-06-10 Thread Britton Kerin
On Sun, Jun 9, 2019 at 7:46 PM Masahiro Yamada
 wrote:
>
> On Mon, Jun 10, 2019 at 10:38 AM Paul Smith  wrote:
> >
> > On Sun, 2019-06-09 at 18:46 -0400, David A. Wheeler wrote:
> > > As syntactic sugar,
> > > I'd like to see selected special targets allowed as dependencies.
> > > When this happens, it's the same thing as if the target was listed
> > > as a dependency of the special target. E.g., you could express
> > > the same thing above as:
> > >
> > > all: .PHONY do-this do-that
> >
> > That's a cool idea.  I can't think of any issues with it.
>
>
> Just talking about Linux Makefiles,
> we need to duplicate phony targets anyway
> since phony targets are assigned to a variable 'PHONY'.
>
> For example, like this
> https://github.com/torvalds/linux/blob/v5.2-rc4/Makefile#L501
>
> (BTW, I think this idea was provided by Paul.)
>
>
>
> Besides, this might be an unrelated topic,
> is it a good idea to support .PHONY for pattern rules?

I definitely recall wanting this at  some point.  After a few
minutes search I can't find when, where, or why though :)

Britton

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: Idea: Allow certain special targets as dependencies

2019-06-10 Thread Britton Kerin
On Sun, Jun 9, 2019 at 2:47 PM David A. Wheeler  wrote:
>
> Idea: Allow certain special targets as dependencies
>
> Problem:
> It's often the case that a target also needs to be a special target. E.g.:
> .PHONY: all
> all: do-this do-that
>
> Obviously this *works*, but it consumes many extra lines &
> requires duplication of target names.  For example,
> if you misspell the "duplicated" names bad things happen.
> For short makefiles this isn't a big deal, but with lots of rules
> it gets annoying.
>
> Solution:
> As syntactic sugar,
> I'd like to see selected special targets allowed as dependencies.
> When this happens, it's the same thing as if the target was listed
> as a dependency of the special target. E.g., you could express
> the same thing above as:
>
> all: .PHONY do-this do-that
>
> This doesn't add new *functionality* to a makefile, but if you're
> creating a GNU make specific makefile anyway the savings of
> lines can be significant.  It also eliminates a source of errors.

I also find having to write .PHONY: all over annoying.  Not sure
the proposed syntax is the best (not that I have any particular
problem with it, just wonder if there are any good alternatives).

> I propose that this abbreviation with the following special targets:
> .PHONY
> .PRECIOUS
> .INTERMEDIATE
> .SECONDARY
> .IGNORE
> .SILENT
> .NOTPARALLEL
> .ONESHELL

Aren't e.g. NOTPARALLEL and ONESHELL global in effect at
the moment?  Is the proposal to allow making them target-local
or does make already allow that somehow and I'm not aware?

The manual says for ONESHELL:

ONESHELL
If .ONESHELL is mentioned as a target, then when a target is built all
lines of the recipe will be given to a single invocation of the shell
rather than each line being invoked separately (see Recipe Execution).

The documentation for other special built-in targets mentions their
sensitivity to supplied prereqs (e.g. .PHONY).  Maybe the docs
need fixed here.


Britton

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: Idea: Allow certain special targets as dependencies

2019-06-09 Thread Masahiro Yamada
On Mon, Jun 10, 2019 at 10:38 AM Paul Smith  wrote:
>
> On Sun, 2019-06-09 at 18:46 -0400, David A. Wheeler wrote:
> > As syntactic sugar,
> > I'd like to see selected special targets allowed as dependencies.
> > When this happens, it's the same thing as if the target was listed
> > as a dependency of the special target. E.g., you could express
> > the same thing above as:
> >
> > all: .PHONY do-this do-that
>
> That's a cool idea.  I can't think of any issues with it.


Just talking about Linux Makefiles,
we need to duplicate phony targets anyway
since phony targets are assigned to a variable 'PHONY'.

For example, like this
https://github.com/torvalds/linux/blob/v5.2-rc4/Makefile#L501

(BTW, I think this idea was provided by Paul.)



Besides, this might be an unrelated topic,
is it a good idea to support .PHONY for pattern rules?

We cannot write like this:

.PHONY: %config


Linux Makefiles use 'FORCE' as an alternative solution.  See
https://github.com/torvalds/linux/blob/v5.2-rc4/Makefile#L556
https://github.com/torvalds/linux/blob/v5.2-rc4/Makefile#L1419


'FORCE' is an idiom used in Linux Makefiles
to run the target forcibly, but
I think it is slightly different from .PHONY.


-- 
Best Regards
Masahiro Yamada

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Re: Idea: Allow certain special targets as dependencies

2019-06-09 Thread Paul Smith
On Sun, 2019-06-09 at 18:46 -0400, David A. Wheeler wrote:
> As syntactic sugar,
> I'd like to see selected special targets allowed as dependencies.
> When this happens, it's the same thing as if the target was listed
> as a dependency of the special target. E.g., you could express
> the same thing above as:
> 
> all: .PHONY do-this do-that

That's a cool idea.  I can't think of any issues with it.


___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make


Idea: Allow certain special targets as dependencies

2019-06-09 Thread David A. Wheeler
Idea: Allow certain special targets as dependencies

Problem:
It's often the case that a target also needs to be a special target. E.g.:
.PHONY: all
all: do-this do-that

Obviously this *works*, but it consumes many extra lines &
requires duplication of target names.  For example,
if you misspell the "duplicated" names bad things happen.
For short makefiles this isn't a big deal, but with lots of rules
it gets annoying.

Solution:
As syntactic sugar,
I'd like to see selected special targets allowed as dependencies.
When this happens, it's the same thing as if the target was listed
as a dependency of the special target. E.g., you could express
the same thing above as:

all: .PHONY do-this do-that

This doesn't add new *functionality* to a makefile, but if you're
creating a GNU make specific makefile anyway the savings of
lines can be significant.  It also eliminates a source of errors.

I propose that this abbreviation with the following special targets:
.PHONY
.PRECIOUS
.INTERMEDIATE
.SECONDARY
.IGNORE
.SILENT
.NOTPARALLEL
.ONESHELL

--- David A. Wheeler

___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make