URL: <https://savannah.gnu.org/bugs/?68714>
Summary: Pattern Rules: The directory part is removed from
the stem.
Group: make
Submitter: joergboe
Submitted: Fri 25 Sep 2026 06:56:26 PM CEST
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Unlocked
Component Version: 4.4.1
Operating System: POSIX-Based
Fixed Release: None
Triage Status: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Fri 25 Sep 2026 06:56:26 PM CEST By: Anonymous
I'm using a pattern rule to translate source file in several directories. The
Makefile:
builddir = build
$(builddir)/%.obj : src/%.cpp
@echo 'Stem=$*'
touch $(builddir)/$*.obj
First the translation of file src/d1/foo.cpp into build/d1/foo.obj works
fine:
> mkdir -p src/d1; touch src/d1/foo.cpp # creating the source
> mkdir -p build/d1 # creating the target directory
> make build/d1/foo.obj
Stem=d1/foo
touch build/d1/foo.obj
Second the translation of the source fails if the builddir is the current
directory:
> rm -rf build
> mkdir -p ./d1 # build directory is now ./
> make ./d1/foo.obj builddir=.
make: *** No rule to make target 'd1/foo.obj'. Stop.
In the database the implicit rule is changes from
./%.obj: src/%.cpp
to
%.obj: src/%.cpp
This make a difference. The manual says:
'When the target pattern does not contain a slash (and it usually does not),
directory names in the file names are removed from the file name before it is
compared with the target prefix and suffix...'
The implicite rule now tries:
Trying pattern rule '%.obj: src/%.cpp' with stem 'foo'.
Trying implicit prerequisite 'd1/src/foo.cpp'.
In such a case make must not remove the ./ in front of the target and the
directory part must be part of the stem.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68714>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
