bug-make
[Top][All Lists]
Advanced

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

Re: Bug#72071: make/the default rules do not escape filenames correctly


From: Manoj Srivastava
Subject: Re: Bug#72071: make/the default rules do not escape filenames correctly
Date: 27 Sep 2000 13:09:04 -0500
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

Hi,

        [Please retain the CC to address@hidden so
        that the Debian Bug Tracking system can record your input]

        The following report was submitted by a Debian user. It has
 been independently verified.

        manoj

  If a filename contains a space or a dollar, make/its default rules
fail to escape or quote the name correctly when invoking the compiler. 

  Here's how to reproduce this problem:
cat >Makefile <<__EOF__
all: pound dollar space
        @echo "It all works!"

pound: pound\#file.o
        @echo "Pounds work"

dollar: dollar$$file.o
        @echo "Dollars work"

space: space\ file.o
        @echo "Spaces work"

clean:
        @rm *.o
__EOF__
cat /dev/null >'pound#file.c'
cat /dev/null >'dollar$file.c'
cat /dev/null >'space file.c'
make -k
cc    -c -o pound#file.o pound#file.c
Pounds work
cc    -c -o dollar$file.o dollar$file.c
cc: dollar.c: No such file or directory
cc: No input files
make: *** [dollar$file.o] Error 1
cc    -c -o space file.o space file.c
cc: cannot specify -o with -c or -S and multiple compilations
make: *** [space file.o] Error 1
make: Target `all' not remade because of errors.

(beware the tabs of course ;-))

Things to note:
 * 'cc dollar$file.o', $file is not set so cc tries to read 'dollar.c'
and fails. The $ should have been escaped but there is no way to escape
it in the Makefile that will work.

 * 'cc space file.c', same thing, the space is not escaped so cc tries
to read 'space.c' and fails. Adding an additional \ in the Makefile
results in make complaining it cannot find 'space\ file.c'. 

 * Putting single or double quotes around the troublesome filenames does
not work: make takes them to be part of the file name.

 * Escaping the pound sign works. I'm not sure how make invokes cc (via
fork()/exec(), system(), sh?), but it seems no shell is
involved since '#' would make the start of the comments.

 * '$' behaves strangely. It is interpreted by make before
anything else, including '\'. So '\$' does not work and one must use
'$$' (which is documented). This is a bit confusing. Would it break many
makefiles if '\' were interpreted first so that '\$' is equivalent to
'$$'?

 * Workaround: adding rules like the one below solve this problem:
.c.o:
        cc -c -o '$*.o' '$<'

 * Optional question: how would one write a generic command to link a
bunch of object files containing spaces together? It seems "'$^'" would
not work.


-- 
 If I were a grave-digger or even a hangman, there are some people I
 could work for with a great deal of enjoyment. Douglas Jerrold
Manoj Srivastava   <address@hidden>  <http://www.debian.org/%7Esrivasta/>
1024R/C7261095 print CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C



reply via email to

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