[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gmake: How to delete Pref3$1.class

From: Paul D. Smith
Subject: Re: gmake: How to delete Pref3$1.class
Date: Sun, 22 Feb 2004 13:02:21 -0500

%% address@hidden (Alexander Farber) writes:

  af> I'd like to have Pref3$1.class as a target, but also 
  af> as a prerequisite (and thus pass it to a shell command)

Like I said, you have to quote the $ _BOTH_ from make _AND_ from the

  af> For example here the "rm -f" doesn't work, because shell
  af> (the "rm -f") will expand Pref3$1.class to Pref3.class:

  af>   INNER   = Pref3$$1.class
  af>   CLASSES = $( $(INNER)

  af>   $(INNER): Pref3.class

  af>   %.class:
  af>           javac -deprecation -J-Dfile.encoding=KOI8_R $<

Here $< expands to Pref3$$1.class which is evaluated by make, so the
string that is passed to the shell is Pref3$1.class.  But then the shell
_also_ evaluates it before it invokes javac, so the filename that javac
sees is just Pref3.class.

  af>   clean:
  af>           rm -f $(CLASSES) tags Pref3.jar

  af> And here "rm -f" works, but I couldn't say: gmake 'Pref3$1.class'" 
  af> in shell because the target's name is actually "Pref3\$1.class":

  af>   INNER   = Pref3\$$1.class
  af>   CLASSES = $( $(INNER)

  af>   $(INNER): Pref3.class

  af>   %.class:
  af>           javac -deprecation -J-Dfile.encoding=KOI8_R $<

  af>   clean:
  af>           rm -f $(CLASSES) tags Pref3.jar

You don't put the quote in the file name, because as you point out now
make has a completely incorrect idea of the name of the file.  Not only
will a direct make invocation not work, but you will always rebuild the
target because as far as make is concerned the filename has a "\" in it,
and your rule never updates that target.

Instead, as I described in my previous mail, you put the quoting in the
command line, maybe like this:

        INNER   = Pref3$$1.class
        CLASSES = $( $(INNER)

        $(INNER): Pref3.class

                javac -deprecation -J-Dfile.encoding=KOI8_R '$<'

                rm -f $(foreach c,$(CLASSES),'$(c)') tags 

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

[Prev in Thread] Current Thread [Next in Thread]