[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #52028] Preventing infinite recursions when make is invoked from re
From: |
anonymous |
Subject: |
[bug #52028] Preventing infinite recursions when make is invoked from recipes |
Date: |
Fri, 15 Sep 2017 01:47:31 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0 |
URL:
<http://savannah.gnu.org/bugs/?52028>
Summary: Preventing infinite recursions when make is invoked
from recipes
Project: make
Submitted by: None
Submitted on: Fri 15 Sep 2017 05:47:30 AM UTC
Severity: 3 - Normal
Item Group: Enhancement
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Component Version: 4.1
Operating System: POSIX-Based
Fixed Release: None
Triage Status: None
_______________________________________________________
Details:
Consider this Makefile:
a :
echo a1
$(MAKE) b
echo a2
b :
echo b1
$(MAKE) a
echo b2
Building either a or b will cause infinite recursion.
It is possible to work around this with a template, similar to the following:
SHELL := bash
exportable = $(shell echo $(1) | sed 's%[^[:alnum:]_]%_%g')
define make
$(eval d := $(strip $(call exportable,$(1))))
$(eval f := $(if $(strip $(2)), -f $(realpath $(strip $2))))
if [ "$$_making_$(d)" != "$@" ]; then \
export _making_$(d)="$@"; \
$(MAKE) $(f) "$(strip $(1))"; \
fi
a :
echo a1
$(call make,b)
echo a2
b :
echo b1
$(call make,a)
echo b2
Running with -s produces:
a1
b1
a1
a2
b2
a2
Making b instead:
b1
a1
b1
b2
a2
b2
This is an enhancement/optional feature request:
Add a command $(make ...) or modify interpretation of $(MAKE) in recipes,
which functions in a way similar to the work around template provided.
The template is highly non-portable, uses regular expressions and invokes a
shell, pollutes environment variables without cleaning up, and it is very hard
to understand (it took several hours of experimenting to come up with).
Reasons to deny the request that I can think of:
It may be considered "bad design" to specify dependencies within a recipe. The
above example is basically a circular dependency.
Counter arguments:
GNU Make allows recursion which therefore exposes an infinite recursion bug. A
circular dependency specified normally will not cause an infinite recursion.
GNU Make should treat these the same way.
The dependency specified by a recursive make is different to a normal
dependency in that it allows for control over ordering of recipe instructions.
This may open up more patterns for make to be used more heuristically
(dependencies do not need to be rigidly pre-determined).
I'd quite like to try implementing this feature because I have specific use
cases for it.
Sam Moore
<address@hidden>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52028>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #52028] Preventing infinite recursions when make is invoked from recipes,
anonymous <=