DeadHead@cup.portal.com (Bruce M Ong) (02/21/90)
I have to include a file with '$' in its name (i.e. abc.$cf) in a macro definition in Make. For the life of me I couldnt figureout how to escape that specific '$' sign in the make file so make wont try to expand abc.$cf into "abc.f" How can I do this? Any hints from ya gurus will be appreciated! Thanks, bruce email: deadhead@cup.portal.com
gwyn@smoke.BRL.MIL (Doug Gwyn) (02/23/90)
In article <27177@cup.portal.com> DeadHead@cup.portal.com (Bruce M Ong) writes: >I have to include a file with '$' in its name (i.e. abc.$cf) in >a macro definition in Make. Did you try $$ ? Why are you guys posting this kind of question here instead of comp.unix.questions, which was set up expressly for them?
dce@smsc.sony.com (David Elliott) (02/24/90)
In article <12219@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <27177@cup.portal.com> DeadHead@cup.portal.com (Bruce M Ong) writes: >>I have to include a file with '$' in its name (i.e. abc.$cf) in >>a macro definition in Make. > >Did you try $$ ? Did you? >Why are you guys posting this kind of question here instead of >comp.unix.questions, which was set up expressly for them? While I agree in principle, this isn't a simple question. After all, once Make tries to do anything with the filename, it uses the shell ('$' is in the list of characters that force the use of sh), which will eat the $. So, it may take a wizard to figure out the correct answer (assuming there is a correct answer other than "Don't use $ in filenames"). -- David Elliott dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce (408)944-4073 "...it becomes natural, like a third sense." -- Homer Simpson
cpcahil@virtech.uucp (Conor P. Cahill) (02/24/90)
In article <27177@cup.portal.com> DeadHead@cup.portal.com (Bruce M Ong) writes: >I have to include a file with '$' in its name (i.e. abc.$cf) in >a macro definition in Make. For the life of me I couldnt figureout how to >escape that specific '$' sign in the make file so make wont try to expand >abc.$cf into "abc.f" > >How can I do this? Any hints from ya gurus will be appreciated! This all depends upon how you want to use it. If you just want to have the $ appear in the macro you can escape the $ by preceding it with another $. For example: TEMP=$$tmp However, if you want to use this in a command line like: echo $(TEMP) you must also escape the dollar sign for the shell. This can be done by TEMP=\$$tmp echo $(TEMP) or TEMP=$$tmp echo \$(TEMP) If what you are referring to is the inference rules you can do something like the following: .SUFFIXES: .$$a .a .$$a.a: cp '$*.$$a' $@ test.a: Which will copy test.$a to test.a in the current directory if test.$a is newer than test.a. Good luck -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+
tale@cs.rpi.edu (David C Lawrence) (02/24/90)
In article <27177@cup.portal.com> DeadHead@cup.portal.com (Bruce M Ong) writes: > I have to include a file with '$' in its name (i.e. abc.$cf) in > a macro definition in Make. In article <12219@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: > Did you try $$ ? In <1990Feb23.174537.5490@smsc.sony.com> dce@smsc.sony.com (David Elliott): > Did you? Well, I did when I sent Bruce pretty much exactly the same sentence. I made the following Makefile: whonk: whonk.$$ cat whonk.$$ Then did: $ echo This is a stupid filename. > whonk.\$ $ make whonk cat whonk.$ This is a stupid filename. Now I just tried something else, encouraged by your article saying that it doesn't work. $ /bin/make whonk make: Fatal error in reader: '$' at end of string `whonk.$' The first make, which worked, was with GNU Make 3.57. The make which produced the error is the one supplied with SunOS 4.0.3c. Doug: > Why are you guys posting this kind of question here instead of > comp.unix.questions, which was set up expressly for them? David: > While I agree in principle, this isn't a simple question. Perhaps not. As far as GNU Make was concerned it was a trivial exercise. At any rate it is not a UNIX-WIZARDS question. > So, it may take a wizard to figure out the correct answer (assuming > there is a correct answer other than "Don't use $ in filenames"). Well, I (no wizard, admittedly) couldn't figure out the Sun make problem by just playing around with it. I'm certain I could figure out whether it could be done if I could see the source code, but there seems to be this little problem involving the fact that it's all copyright by SMI so only four people on the whole bloody campus can look at it. (I might indeed discover, as a result of this note, that the sources are primarily free BSD and I can look at that (though I likely won't really care). I have no idea what Sun changed around from BSD sources.) Dave -- (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet"))
guy@auspex.auspex.com (Guy Harris) (02/27/90)
>I might indeed discover, as a result of this note, that >the sources are primarily free BSD and I can look at that (though I >likely won't really care). No, you won't discover that. 1) Sun "make" hasn't been a BSD "make" since SunOS 3.0; it became S5-based in 3.0. (Yes, 3.0, not 3.2. It was not done as part of an S5 compatibility push; it was done because the S5 "make" was newer and more powerful.) >I have no idea what Sun changed around from BSD sources.) 2) Sun "make" hasn't been an S5 "make" since SunOS 4.0 - or earlier, if you installed the "SunPro 'make'". The comments on the SCCS ID lines say "remotely from S5" - strong emphasis on the "remotely". 3) The old S5-based "make" is in "/usr/old/make" in SunOS 4.x. When run on your Makefile, it reports: Make: Don't know how to make whonk.. Stop. 4) If you compile the BSD "make", and run it, under SunOS 4.0.3, it says cat whonk.$ This is a stupid filename. 5) If you compile the S5 "make" (temporarily taking out the code for handling archives, which has to change for SunOS and which doesn't come into play here), and run it, it does exactly what "/usr/old/make" does. So the answer is that somebody at AT&T changed "make" so that it doesn't work under the System V "make"; the changes to the Sun "make" also cause it to fail, although for different reasons. Now, to add some more amusement, we rename "whonk.$" to "whonk.$x", and change the Makefile to: whonk: whonk.$$x cat whonk.$$x and then try the various flavors of "make" on that: auspex% bsdmake/make # BSD "make" cat whonk.$x whonk.: No such file or directory *** Exit 1 Stop. auspex% s5make/make # S5R3 "make" Make: Don't know how to make whonk.. Stop. auspex% /usr/old/make # Old S5R2-based SunOS "make" Make: Don't know how to make whonk.. Stop. auspex% make # New SunOS 4.x "SunPro 'make'" make: Fatal error: Don't know how to make target `whonk.' Changing it to: whonk: whonk.$$x cat whonk.\$$x at least gets the BSD "make" to hand the right command to the shell: auspex% bsdmake/make cat whonk.\$x This is a stupid filename. but still doesn't change the behavior of the S5 "make". No, I haven't investigated further; no, I have no plans to.
mykel@gestetner.oz (Michael Landers) (03/02/90)
>In article <12219@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >> Did you try $$ ? [ Alot of rubbish about SunOS 4.x make not working removed ] Did you try $$$$ ? You've just got to be forceful with Suns. Mykel. -- () \\ |\/|ykel Landers (mykel@gestetner.oz) \\ "I don't want to be famous, _||_ Gestetner Laser Systems \\ just rich as shit" - Kip Phone: 612 975 0555 Fax: 612 975 0448 \\
flee@shire.cs.psu.edu (Felix Lee) (03/02/90)
The following oddity works in SunOS 4.x (and presumably, System V): % cat whonk.\$ This is a silly file name. % cat makefile whonk: whonk.$$$$ cat whonk.$$ % make cat whonk.$ This is a silly file name. % Looks like the dependencies list gets evaluated twice. -- Felix Lee flee@shire.cs.psu.edu *!psuvax1!flee
gwc@root.co.uk (Geoff Clare) (03/02/90)
DeadHead@cup.portal.com (Bruce M Ong) writes: |I have to include a file with '$' in its name (i.e. abc.$cf) in |a macro definition in Make. gwyn@brl.arpa (Doug Gwyn) writes: |Did you try $$ ? dce@Sony.COM (David Elliott) writes: | this isn't a simple question. After all, |once Make tries to do anything with the filename, it uses the shell |('$' is in the list of characters that force the use of sh), which |will eat the $. Actually this IS a very simple question. Just make sure the $ is quoted when it is passed to the shell: abc.'$$'cf or 'abc.$$cf' does the trick. -- Geoff Clare, UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH gwc@root.co.uk (Dumb mailers: ...!uunet!root.co.uk!gwc) Tel: +44-1-315-6600 (from 6th May 1990): +44-71-315-6600
gwc@root.co.uk (Geoff Clare) (03/05/90)
In article <1814@root44.co.uk> I wrote: >DeadHead@cup.portal.com (Bruce M Ong) writes: >|I have to include a file with '$' in its name (i.e. abc.$cf) in >|a macro definition in Make. > >gwyn@brl.arpa (Doug Gwyn) writes: >|Did you try $$ ? > >dce@Sony.COM (David Elliott) writes: >| this isn't a simple question. After all, >|once Make tries to do anything with the filename, it uses the shell >|('$' is in the list of characters that force the use of sh), which >|will eat the $. > >Actually this IS a very simple question. Just make sure the $ is quoted >when it is passed to the shell: abc.'$$'cf or 'abc.$$cf' does the trick. I received some mail from David Elliott pointing out that the intention in the original question was for the macro to be usable as normal in dependency lines. My "single quotes" solution will only work where the macro is used in commands - if the macro is used in a dependency line, "make" will look for a file with single quotes in the name. I apologise for overlooking that requirement, however my answer is still basically the same: make sure the $ is quoted when passed to the shell. A way to do this, which allows the macro to work correctly in dependency lines, is to use a shell variable to "hide" the $ in commands, for example: FILES = abc.$$cf abd.$$cf all: $(FILES) files='$(FILES)'; cat $$files -- Geoff Clare, UniSoft Limited, Saunderson House, Hayne Street, London EC1A 9HH gwc@root.co.uk (Dumb mailers: ...!uunet!root.co.uk!gwc) Tel: +44-1-315-6600 (from 6th May 1990): +44-71-315-6600