| Summary: | make(1) does not correctly substitute in internal macros like $(@F:.o=.c) | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Jens.Schweikhardt <Jens.Schweikhardt> |
| Component: | bin | Assignee: | Jens Schweikhardt <schweikh> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.2-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
Responsible Changed From-To: freebsd-bugs->will Over to maintainer. Responsible Changed From-To: will->freebsd-bugs I don't have time for make(1) anymore... Here's a patch to the 4.3-REL version of make to fix this problem. It's
been tested with the example case in the PR.
Basically, after expanding F or D, we fall-through to the expansion code,
rather than returning right away.
--- var.c.orig Wed Nov 7 23:13:29 2001
+++ var.c Wed Nov 7 23:12:39 2001
@@ -1622,8 +1622,6 @@
*freePtr = TRUE;
*lengthPtr = tstr-start+1;
*tstr = endc;
- Buf_Destroy(buf, TRUE);
- return(val);
}
break;
}
--
Matt Emmerton
State Changed From-To: open->analyzed Analysis with patch received. Responsible Changed From-To: freebsd-bugs->schweikh I'm the originator and am going to test and integrate the provided patch. Matt, I've tried your patch on a -current system (applied manually, i.e. removed the two lines), but with the test case in the PR this dumps core: schweikh@hal9000:~ $ make bar.o bar.c make in free(): error: chunk is already free zsh: abort (core dumped) make bar.o Can you reproduce this on a -current system? If it's hard for you to checkout from HEAD I can send you the current sources so you can have a look at it. Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) Here's a revised patch against 4.3-REL (silly mistake on my part) that
should do the right thing.
--- var.c.orig Fri Jan 4 00:24:16 2002
+++ var.c Fri Jan 4 00:24:49 2002
@@ -1614,15 +1614,8 @@
} else {
val = VarModify(val, VarTail, (ClientData)0);
}
- /*
- * Resulting string is dynamically allocated, so
- * tell caller to free it.
- */
- *freePtr = TRUE;
*lengthPtr = tstr-start+1;
*tstr = endc;
- Buf_Destroy(buf, TRUE);
- return(val);
}
break;
}
--
Matt Emmerton
Matt,
your modified patch has a problem when no modifiers .x=.y are used:
root@hal9000:/usr/obj/src/current/usr.bin/make # cat Makefile
/tmp/xyz:
echo $(@F)
root@hal9000:/usr/obj/src/current/usr.bin/make # ./make /tmp/xyz
echo /tmp/xyz
/tmp/xyz
It should echo xyz instead. Mark Valentine <mark@thuvia.demon.co.uk> has
sent me a different patch, could you please have a look at it and tell me
what you think about it?
Index: var.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/var.c,v
retrieving revision 1.21
diff -u -r1.21 var.c
--- var.c 2 Dec 2000 20:24:38 -0000 1.21
+++ var.c 11 Jan 2002 18:40:29 -0000
@@ -1599,7 +1599,7 @@
vname[1] = '\0';
v = VarFind(vname, ctxt, 0);
- if (v != (Var *)NULL) {
+ if (v != (Var *)NULL && !haveModifier) {
/*
* No need for nested expansion or anything, as we're
* the only one who sets these things and we sure don't
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
> Matt,
>
> your modified patch has a problem when no modifiers .x=.y are used:
>
> root@hal9000:/usr/obj/src/current/usr.bin/make # cat Makefile
> /tmp/xyz:
> echo $(@F)
> root@hal9000:/usr/obj/src/current/usr.bin/make # ./make /tmp/xyz
> echo /tmp/xyz
> /tmp/xyz
>
> It should echo xyz instead. Mark Valentine <mark@thuvia.demon.co.uk> has
> sent me a different patch, could you please have a look at it and tell me
> what you think about it?
>
> Index: var.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/make/var.c,v
> retrieving revision 1.21
> diff -u -r1.21 var.c
> --- var.c 2 Dec 2000 20:24:38 -0000 1.21
> +++ var.c 11 Jan 2002 18:40:29 -0000
> @@ -1599,7 +1599,7 @@
> vname[1] = '\0';
> v = VarFind(vname, ctxt, 0);
>
> - if (v != (Var *)NULL) {
> + if (v != (Var *)NULL && !haveModifier) {
> /*
> * No need for nested expansion or anything, as we're
> * the only one who sets these things and we sure don't
This patch looks like it does the right thing.
--
Matt Emmerton
State Changed From-To: analyzed->closed Applied the "&& !haveModifier" one-line patch to -current. Thanks Mark! |
hello, world\n It seems, make(1) doesn't understand substitutions in what the POSIX standard calls internal variables ($@, $%, $?, $< and $*). In the following example, the intent is to substitute any *.o in a *.c, i.e. echo foo.c. How-To-Repeat: $ cat Makefile .POSIX: foo.o: echo $(@F:.o=.c) $ /usr/bin/make echo foo.o.o=.c) Syntax error: ")" unexpected *** Error code 2 Stop in /usr/home/sje2bk. GNU make works correctly, as well as Sun's /usr/ccs/bin/make: $ /usr/local/bin/gmake echo foo.c foo.c $ Is this a bug, a feature, lack of interest in POSIX conformance or am I just confused? :-)