ct@dde.uucp (Claus Tondering) (12/30/88)
Consider the following makefile: ALPHA = foo BETA = $(ALPHA) bar all: echo $(BETA) Running make with this makefile will result in the execution of the command "echo foo bar", which is OK. Now, consider the following makefile: ALPHA = foo BETA = $(ALPHA) bar all: echo $(BETA:bar=hello) Running make with this makefile will result in the execution of the command "echo $(ALPHA) hello", which is certainly not what I would expect. Why is ALPHA not substituted in the last example? Bug or feature? -- Claus Tondering Dansk Data Elektronik A/S, Herlev, Denmark E-mail: ct@dde.dk or ...!uunet!mcvax!dkuug!dde!ct
leo@philmds.UUCP (Leo de Wit) (01/01/89)
In article <502@Aragorn.dde.uucp> ct@dde.uucp (Claus Tondering) writes: [first example omitted ...] |Now, consider the following makefile: | |ALPHA = foo |BETA = $(ALPHA) bar | |all: | echo $(BETA:bar=hello) | |Running make with this makefile will result in the execution of the |command "echo $(ALPHA) hello", which is certainly not what I would |expect. | |Why is ALPHA not substituted in the last example? Bug or feature? What would you expect? "$(BETA:bar=hello)" is certainly not Make syntax. Make doesn't know about sh or csh variable substitution, if that was your intention. Leo.
friedl@vsi.COM (Stephen J. Friedl) (01/02/89)
In article <904@philmds.UUCP>, leo@philmds.UUCP (Leo de Wit) writes: > What would you expect? "$(BETA:bar=hello)" is certainly not Make syntax. > Make doesn't know about sh or csh variable substitution, if that was > your intention. New versions of make (augmake?) *do* allow this kind of substitution. You can do: SRC = $(OBJS:.o=.c) and it effectively does 's/\.o/.c/g' on each word in ${OBJS}. It's very handy... Steve -- Stephen J. Friedl 3B2-kind-of-guy friedl@vsi.com V-Systems, Inc. I speak for me only attmail!vsi!friedl Santa Ana, CA USA +1 714 545 6442 {backbones}!vsi!friedl -------Nancy Reagan on Usenix in San Diego: "Just say *go*"-------
andre@targon.UUCP (andre) (01/02/89)
In article <904@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) writes: }In article <502@Aragorn.dde.uucp> ct@dde.uucp (Claus Tondering) writes: } [first example omitted ...] }|Now, consider the following makefile: }| }|ALPHA = foo }|BETA = $(ALPHA) bar }| }|all: }| echo $(BETA:bar=hello) }| }|Running make with this makefile will result in the execution of the }|command "echo $(ALPHA) hello", which is certainly not what I would }|expect. }| }|Why is ALPHA not substituted in the last example? Bug or feature? }What would you expect? "$(BETA:bar=hello)" is certainly not Make syntax. }Make doesn't know about sh or csh variable substitution, if that was }your intention. > Leo. The $(VAR:foo=bar) notation is perfectly normal make syntax. It means while expanding VAR, substitute foo by bar. This is mostly used as SRC=a.c b.c c.c OBJ=$(SRC:.c=.o) Back to the original question, Yes it is a bug. What I think that happenes is the following. To save space make does not expand variables when they are assinged to one another. When a variable is needed, expansion occurs. The trouble is that when a substitution is detected, further expansion is not checked for as is done for normal expansion. The same problem occurs in the public domain make that was posted a while back. The substitution funstion was not glad with what it had done and left the $VAR occurences that were still in the string. I suspect that the standard make has the same problem. Hope this helps. One thing to ponder, should make be able to handle this? STR=h w HI=hello TEXT=STR H=h HELLO=$HI all: echo $($($TEXT:w=world):$H=$HELLO) And the result of this is: echo :h=hELLO) -- ~----~ |m AAA DDDD It's not the kill, but the thrill of the chase. ~|d1|~@-- AA AAvv vvDD DD Segment registers are for worms. ~----~ & AAAAAAAvv vvDD DD ~~~~~~ -- AAA AAAvvvDDDDDD Andre van Dalen, uunet!mcvax!targon!andre
chris@mimsy.UUCP (Chris Torek) (01/03/89)
In article <987@vsi.COM> friedl@vsi.COM (Stephen J. Friedl) writes: > New versions of make (augmake?) *do* allow this kind of >substitution. You can do: > >SRC = $(OBJS:.o=.c) > >and it effectively does 's/\.o/.c/g' on each word in ${OBJS}. > > It's very handy... Indeed. Since 4BSD still has a boring old make, I use a script wrapped around `sed' to do the job: OBJS= ... SRCS= `chgsuf .o .c` ${OBJS} lint: ${SRCS} lint ${LINTFL} ${SRCS} The addsuf and chgsuf scripts (in /usr/local/bin) are trivial. (Note that these break if the new suffix contains an `&'. Sorry :-) ) #! /bin/sh # # addsuf - add suffix to each argument # assumes no embedded spaces in arguments case $# in 0) echo "usage: addsuf suffix files" 1>&2; exit 1;; esac suf="$1" shift echo ${1+"$@"} | sed -e "s/ /$suf /g" -e "s/$/$suf/" #! /bin/sh # # chgsuf - change suffix in each argument # assumes no embedded spaces in arguments # oldsuf is a string, not an R.E. case $# in 0|1) echo "usage: chgsuf oldsuf newsuf files" 1>&2; exit 1;; esac sed="sed -e s/[/.^[\*]/\\\\&/g" oldsuf="`echo \"$1\" | $sed`" newsuf="`echo \"$2\" | $sed`" shift; shift echo ${1+"$@"} | sed -e "s/$oldsuf /$newsuf /g" -e "s/$oldsuf$/$newsuf/" -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
bill@twwells.uucp (T. William Wells) (01/05/89)
In article <502@Aragorn.dde.uucp> ct@dde.uucp (Claus Tondering) writes:
: ALPHA = foo
: BETA = $(ALPHA) bar
:
: all:
: echo $(BETA:bar=hello)
:
: Running make with this makefile will result in the execution of the
: command "echo $(ALPHA) hello", which is certainly not what I would
: expect.
:
: Why is ALPHA not substituted in the last example? Bug or feature?
Brain damage. Someone is doing the substitution before the expansion.
This is clearly wrong. Not only that, but it works on my Sun and I
believe that it worked on the VAX we used to have, the latter
definitely not Berkeley based. However, it definitely fails on my
Microport system; I got bit by this just the other day. I know where
I can get a PD make; if it is any good I'm going to toss the one I
have. Grrrrr......
---
Bill
{ uunet!proxftl | novavax } !twwells!bill
davidsen@steinmetz.ge.com (William E. Davidsen Jr) (01/06/89)
I have that thing called 'cake,' but I never took the time to get it working. Is that the one you mean? -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
guy@auspex.UUCP (Guy Harris) (01/07/89)
>Brain damage. Someone is doing the substitution before the expansion. >This is clearly wrong. Not only that, but it works on my Sun and I >believe that it worked on the VAX we used to have, the latter >definitely not Berkeley based. However, it definitely fails on my >Microport system; I got bit by this just the other day. I tried this under SunOS 4.0; the standard "make", which (as the comments on the SCCS ID lines say) is "Remotely from S5", does what seems to be considered the Right Thing, but "/usr/old/make" (which is basically the S5R2 "make") doesn't. My guess is that all flavors of the S5 "make" (it didn't change much between S5 releases, as I remember) don't Do The Right Thing, and that in the process of doing the "SunPro 'make'", which is the standard make in SunOS 4.0 and can be installed as "make" in 3.5 (and maybe 3.4), this was fixed. I seem to remember, in fact, that this *was* one of the things changed, in order to increase "make"s flexibility.
allbery@ncoast.UUCP (Brandon S. Allbery) (01/08/89)
As quoted from <904@philmds.UUCP> by leo@philmds.UUCP (Leo de Wit): +--------------- | In article <502@Aragorn.dde.uucp> ct@dde.uucp (Claus Tondering) writes: | +--------------- | |ALPHA = foo | |BETA = $(ALPHA) bar | | | |all: | | echo $(BETA:bar=hello) | | | |Running make with this makefile will result in the execution of the | |command "echo $(ALPHA) hello", which is certainly not what I would | |expect. | | | |Why is ALPHA not substituted in the last example? Bug or feature? | | What would you expect? "$(BETA:bar=hello)" is certainly not Make syntax. | Make doesn't know about sh or csh variable substitution, if that was | your intention. +--------------- Beg pardon, but did you examine the Newsgroups: line? The System III/System V (and, I believe, recent SunOS) "make", sometimes called "augmake", *does* support this. It's fairly limited, however; it only substitutes at the end of words, and there are no wildcards. I have noticed that *some* recursive substitutions fail; I don't know why. It doesn't seem to matter whether substitutions are involved or not. (I had the biggest problem with imported environment variables.) ++Brandon -- Brandon S. Allbery, comp.sources.misc moderator and one admin of ncoast PA UN*X uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu ncoast is registering as "ncoast.org" -- watch for the official announcement! Send comp.sources.misc submissions to comp-sources-misc@<backbone>.
bill@twwells.uucp (T. William Wells) (01/08/89)
In article <12890@steinmetz.ge.com> davidsen@crdos1.UUCP (bill davidsen) writes:
: I have that thing called 'cake,' but I never took the time to get it
: working. Is that the one you mean?
I presume you're talking to me?
No, I don't mean cake. That's a completely different beast.
I've seen several versions of make out there. Sometime when I have a
few spare hours I'm going to snarf some of them and see which, if
any, are any good.
---
Bill
{ uunet!proxftl | novavax } !twwells!bill
bww@k.gp.cs.cmu.edu (Bradley White) (01/09/89)
In article <488@targon.UUCP>, andre@targon.UUCP (andre) writes: > One thing to ponder, should make be able to handle this? > > STR=h w > HI=hello > TEXT=STR > H=h > HELLO=$HI > > all: > echo $($($TEXT:w=world):$H=$HELLO) > > And the result of this is: > echo :h=hELLO) > Changing the last line to read echo $($TEXT:w=world):$H=$HELLO) as I think you intended, the CMU CS version of make says: % make -n echo :h=hELLO) Of course, this isn't very interesting: $T is null, $(EXT) is null, (so the substitution doesn't apply), and that concatenated with the string ":h=hELLO)" simply gives that string. Something slightly more challenging is: echo $($(TEXT):w=$(HELLO)) % make -n echo h hI And something a lot more challenging (the syntax should hopefully be self-explanatory): PROGS = foo bar OFILES = $(PROGS/*/$(&_OFILES?$(&_OFILES):&.o)) foo_OFILES = foo1.o foo2.o all: echo $(OFILES) % make -n echo foo1.o foo2.o bar.o Using such powerful translations has allowed us to create a fully parameterized set of rules, that is included by every Makefile in the system, and that provides the standard target names "all", "install", "clean", and "lint". For example, here is our Makefile for /bin/sh: IDIR = /bin/ PROGRAMS = sh OFILES = setbrk.o builtin.o blok.o stak.o cmd.o\ fault.o main.o word.o string.o name.o args.o\ xec.o service.o error.o io.o print.o macro.o\ expand.o ctype.o msg.o include ../../Makefile-common -- Bradley White <bww@cs.cmu.edu> +1-412-268-3060 CMU Computer Science Department 40 26'33"N 79 56'48"W --
kent@happym.UUCP (Kent Forschmiedt) (01/11/89)
|| In article <502@Aragorn.dde.uucp> ct@dde.uucp (Claus Tondering) writes: || +--------------- || |ALPHA = foo || |BETA = $(ALPHA) bar || | || |all: || | echo $(BETA:bar=hello) || | || |Running make with this makefile will result in the execution of the || |command "echo $(ALPHA) hello", which is certainly not what I would || |expect. The make in Motorola's V/68 R2V2.3 exhibits this bug. It is almost certainly unmodified, directly from AT&T's SVR2 tape. -- kent@happym.wa.com, tikal!camco!happym!kent, Happy Man Corp 206-282-9598
davidsen@steinmetz.ge.com (William E. Davidsen Jr) (01/12/89)
In article <304@twwells.uucp> bill@twwells.UUCP (T. William Wells) writes: | I've seen several versions of make out there. Sometime when I have a | few spare hours I'm going to snarf some of them and see which, if | any, are any good. If you ever find time let us know. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me