[Top][All Lists]

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

make: Targets in not-yet-existing directories processed improperly

From: Manoj Srivastava
Subject: make: Targets in not-yet-existing directories processed improperly
Date: Fri, 08 Nov 2002 22:44:40 -0600
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) (i386-pc-linux-gnu)

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

          This has been reported by a debian user. I am not sure if
 this is a defect in make, but I can't find a rationale for the
 difference in behaviour. If this is not a bug, a clarification about
 what is happening would be appreciated.


When I create a Makefile with pattern rules for compiling to a directory
different from where the source lies, together with rules for creating
these directories, I get very strange results:

### Example Makefile
all: obj/.stamp obj/test

obj/test: obj/test.o

        mkdir -p obj
        touch obj/.stamp

obj/%: obj/%.o
        $(CC) $(LDFLAGS) -o $@ $^

obj/%.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $^
### End of Example

Now, when the "obj" directory already exists, everything runs fine.
If it doesn't exist, it gets created and the program also compiled
correctly, but obj/test.o is deleted afterwards, because make considers
it an intermediate file. It seems that the cause is the "obj/test: obj/test.o"
rule being ignored if "obj" itself doesn't exist.

 ...  r-q1
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]