Re: bug report

2021-03-03 Thread Philip Guenther
On Wed, Mar 3, 2021 at 1:00 PM Goran V.  wrote:

> Am Mittwoch, den 03.03.2021, 15:41 -0500 schrieb Paul Smith:
> > If by "a feature like that" you mean a way to create multiple pattern
> > rules with a single rule definition in the makefile, then obviously
> > this would require some new syntax but assuming that syntax existed I
> > don't see why it would break anything.
>
> Yes, that is what I mean with "a feature like that". But I must say
> that I'm in no position to propose a patch as make is huge,
> http://git.savannah.gnu.org/cgit/make.git/tree/ .
>

This can be emulated in current GNU make via a function and a variable to
hold the commands.

To get the effect you wanted, you would define this function in one place,
before any use of it:

independent_patterns = $(foreach target, $1, $(eval ${target}: ${2};
$(value $(strip $3


Then, instead of writing what you tried:

$(BUILD)/$(FRONTEND)/%.html \
$(BUILD)/$(FRONTEND)/%.js   \
$(BUILD)/$(FRONTEND)/%.css  \
$(BUILD)/$(FRONTEND)/%.svg  \
$(BUILD)/$(FRONTEND)/%.ico:
@echo -n "$(FRONTEND) - building $@"
@$(MD) $(BUILD)/$(FRONTEND)
@cp $(FRONTEND)/$(@F) $@
@echo " ...done"

You would write this:

define cmds
@echo -n "$(FRONTEND) - building $@"
@$(MD) $(BUILD)/$(FRONTEND)
@cp $(FRONTEND)/$(@F) $@
@echo " ...done"
endef
$(call independent_patterns, \
$(BUILD)/$(FRONTEND)/%.html \
$(BUILD)/$(FRONTEND)/%.js   \
$(BUILD)/$(FRONTEND)/%.css  \
$(BUILD)/$(FRONTEND)/%.svg  \
$(BUILD)/$(FRONTEND)/%.ico, , cmds)


Not the most obvious, friendly syntax, but it appears to do what you're
trying to accomplish.


Philip Guenther


[bug #60165] Multiple pattern rules with single rule

2021-03-03 Thread anonymous
URL:
  

 Summary: Multiple pattern rules with single rule
 Project: make
Submitted by: None
Submitted on: Wed 03 Mar 2021 09:24:53 PM UTC
Severity: 3 - Normal
  Item Group: Enhancement
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: None
Operating System: None
   Fixed Release: None
   Triage Status: None

___

Details:

To shorten the code, I would like to create multiple pattern rules with a
single rule.

E.g. the code below is not working as desired.

$(BUILD)/$(FRONTEND)/%.html \
$(BUILD)/$(FRONTEND)/%.js   \
$(BUILD)/$(FRONTEND)/%.css  \
$(BUILD)/$(FRONTEND)/%.svg  \
$(BUILD)/$(FRONTEND)/%.ico:
@echo -n "$(FRONTEND) - building $@"
@$(MD) $(BUILD)/$(FRONTEND)
@cp $(FRONTEND)/$(@F) $@
@echo " ...done"

.PHONY:
login: $(BUILD)/$(FRONTEND)/login.html \
   $(BUILD)/$(FRONTEND)/login.js $(BUILD)/$(FRONTEND)/options.js
$(BUILD)/$(FRONTEND)/node.js \
   $(BUILD)/$(FRONTEND)/login.css $(BUILD)/$(FRONTEND)/common.css \
   $(BUILD)/$(FRONTEND)/logo.svg \
   $(BUILD)/$(FRONTEND)/favicon.ico
@echo -n "$(FRONTEND) - building login"
@echo " ...done"

# result
# q@odysseus:~/ff$ make login
# frontend - building build/frontend/login.html ...done
# frontend - building build/frontend/options.js ...done
# frontend - building build/frontend/node.js ...done
# frontend - building build/frontend/common.css ...done
# frontend - building build/frontend/logo.svg ...done
# frontend - building build/frontend/favicon.ico ...done
# frontend - building login ...done
# q@odysseus:~/ff$ make login
# frontend - building build/frontend/login.js ...done
# frontend - building login ...done
# q@odysseus:~/ff$ make login
# frontend - building build/frontend/login.css ...done
# frontend - building login ...done




___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




Re: bug report

2021-03-03 Thread Paul Smith
On Wed, 2021-03-03 at 22:00 +0100, Goran V. wrote:
> Am Mittwoch, den 03.03.2021, 15:41 -0500 schrieb Paul Smith:
> Yes, that is what I mean with "a feature like that". But I must say
> that I'm in no position to propose a patch as make is huge, 
> http://git.savannah.gnu.org/cgit/make.git/tree/ .

Heh.  I think make is a pretty modestly-sized program.  I guess it's
all what you're used to :).

> I can only ask you to add that feature if you see any benefit in it?

If you'd like to propose an enhancement the best way to do it is here:

https://savannah.gnu.org/bugs/?group=make=additem

Cheers!




Re: bug report

2021-03-03 Thread Goran V.
Am Mittwoch, den 03.03.2021, 15:41 -0500 schrieb Paul Smith:
> If by "a feature like that" you mean a way to create multiple pattern
> rules with a single rule definition in the makefile, then obviously
> this would require some new syntax but assuming that syntax existed I
> don't see why it would break anything.

Yes, that is what I mean with "a feature like that". But I must say
that I'm in no position to propose a patch as make is huge, 
http://git.savannah.gnu.org/cgit/make.git/tree/ .

I can only ask you to add that feature if you see any benefit in it?




Re: bug report

2021-03-03 Thread Paul Smith
On Wed, 2021-03-03 at 21:32 +0100, Goran V. wrote:
> Maybe I was wrong to call this a bug but would a feature like that
> break anything?

If by "a feature like that" you mean a way to create multiple pattern
rules with a single rule definition in the makefile, then obviously
this would require some new syntax but assuming that syntax existed I
don't see why it would break anything.




Re: bug report

2021-03-03 Thread Goran V.
Maybe I was wrong to call this a bug but would a feature like that
break anything?

Am Mittwoch, den 03.03.2021, 13:55 -0500 schrieb Paul Smith:
> On Wed, 2021-03-03 at 17:31 +0100, Goran V. wrote:
> > $(BUILD)/$(FRONTEND)/%.html \
> > $(BUILD)/$(FRONTEND)/%.js   \
> > $(BUILD)/$(FRONTEND)/%.css  \
> > $(BUILD)/$(FRONTEND)/%.svg  \
> > $(BUILD)/$(FRONTEND)/%.ico:
> > @echo -n "$(FRONTEND) - building $@"
> > @$(MD) $(BUILD)/$(FRONTEND)
> > @cp $(FRONTEND)/$(@F) $@
> > @echo " ...done"
> 
> I think you're misunderstanding what a pattern rule with multiple
> targets means to GNU make.
> 
> See: 
> https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
> (last paragraph).
> 
> It means that one invocation of the recipe will create ALL the
> targets.
>  That's why make believes it's already considered all the other
> targets
> that are listed as patterns here, even though it only ran the recipe
> one time.
> 
> Note this is the opposite of what an explicit rule with multiple
> targets means: that defines multiple unique rules, one for each
> target.
> 




Re: [PATCH] More correctly describe the scope of variables

2021-03-03 Thread Jouke Witteveen
On Fri, Jan 29, 2021 at 8:37 AM Jouke Witteveen  wrote:
> On Fri, Dec 25, 2020 at 7:00 PM Jouke Witteveen  wrote:
> >
> > * NEWS: Use "local" instead of the incorrect "lexically-scoped".
> > * doc/make.texi: Refer to let/foreach variables as local variables.
> > ---
> > This is an erratum on the addition of $(let ...). During an early review
> > of $(let ...), thutt cautioned that it did not implement "full semantic
> > scoping" [sic]. While I did not understand fully what they meant by
> > that, I countered that it was not intended to determine a scope based on
> > for example which file a definition of a rule occurred in, but simply by
> > the parentheses delimiting the let expression. Only in that sense was it
> > lexical scoping. Technically, make variables are dynamically scoped.
> >
> > This patch replaces "lexically scoped" not by "dynamically scoped", but
> > by "local", since that is the whole point after all. It also includes
> > variables with local scope (from let and foreach) in several other
> > places where variables are discussed, and makes explicit that variables
> > in make are dynamically scoped.
>
> I think this is ready to go in and that it would be wise to not
> release with the unchanged NEWS.
> Was this patch simply missed due to end-of-year activities?

Another month, another reminder.

Cheers,
- Jouke



Re: bug report

2021-03-03 Thread Paul Smith
On Wed, 2021-03-03 at 17:31 +0100, Goran V. wrote:
> $(BUILD)/$(FRONTEND)/%.html \
> $(BUILD)/$(FRONTEND)/%.js   \
> $(BUILD)/$(FRONTEND)/%.css  \
> $(BUILD)/$(FRONTEND)/%.svg  \
> $(BUILD)/$(FRONTEND)/%.ico:
> @echo -n "$(FRONTEND) - building $@"
> @$(MD) $(BUILD)/$(FRONTEND)
> @cp $(FRONTEND)/$(@F) $@
> @echo " ...done"

I think you're misunderstanding what a pattern rule with multiple
targets means to GNU make.

See: https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
(last paragraph).

It means that one invocation of the recipe will create ALL the targets.
 That's why make believes it's already considered all the other targets
that are listed as patterns here, even though it only ran the recipe
one time.

Note this is the opposite of what an explicit rule with multiple
targets means: that defines multiple unique rules, one for each target.




bug report

2021-03-03 Thread Goran V.
I wrote a makefile with

$(BUILD)/$(FRONTEND)/%.html \
$(BUILD)/$(FRONTEND)/%.js   \
$(BUILD)/$(FRONTEND)/%.css  \
$(BUILD)/$(FRONTEND)/%.svg  \
$(BUILD)/$(FRONTEND)/%.ico:
@echo -n "$(FRONTEND) - building $@"
@$(MD) $(BUILD)/$(FRONTEND)
@cp $(FRONTEND)/$(@F) $@
@echo " ...done"

.PHONY:
login: $(BUILD)/$(FRONTEND)/login.html \
   $(BUILD)/$(FRONTEND)/login.js $(BUILD)/$(FRONTEND)/options.js
$(BUILD)/$(FRONTEND)/node.js \
   $(BUILD)/$(FRONTEND)/login.css $(BUILD)/$(FRONTEND)/common.css \
   $(BUILD)/$(FRONTEND)/logo.svg \
   $(BUILD)/$(FRONTEND)/favicon.ico
@echo -n "$(FRONTEND) - building login"
@echo " ...done"

I get no errors but only if I repeat the command 3 times (3 files with
same prefix) I got the result.

q@odysseus:~/ff$ make login
frontend - building build/frontend/login.html ...done
frontend - building build/frontend/options.js ...done
frontend - building build/frontend/node.js ...done
frontend - building build/frontend/common.css ...done
frontend - building build/frontend/logo.svg ...done
frontend - building build/frontend/favicon.ico ...done
frontend - building login ...done
q@odysseus:~/ff$ make login
frontend - building build/frontend/login.js ...done
frontend - building login ...done
q@odysseus:~/ff$ make login
frontend - building build/frontend/login.css ...done
frontend - building login ...done

With help and instructions from ##workingsets I got further to

make -k -d login
   Successfully remade target file `build/foo/login.html'.
   Considering target file `build/foo/login.js'.
   File `build/foo/login.js' was considered already.

but `build/foo/login.js' was NOT considered already.

Any hints? Is this a feature or a bug?

Thanks
Goran