[Top][All Lists]

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

Targets beginning with a dot are special?

From: PRC
Subject: Targets beginning with a dot are special?
Date: Fri, 11 Jan 2008 13:36:22 +0800

Here is my makefile script:

TARGET1 = .target1
TARGET2 = .target2

.PHONY : all $(TARGET1) $(TARGET2) .mkdir

$(TARGET1): .mkdir $(OBJDIR)/1.o
    @cat $(OBJDIR)/1.o

$(TARGET2): .mkdir $(OBJDIR)/2.o
    @cat $(OBJDIR)/1.o

    @if [ ! -d $(OBJDIR) ]; then \
        mkdir $(OBJDIR) 2>/dev/null; \
        if [ ! -d $(OBJDIR) ]; then \
            exit 1; \
        fi \

    echo This is $@ > $@

    echo This is $@ > $@

$make -d -r -f 1.mak  

GNU Make 3.80
Copyright (C) 2002  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
Reading makefiles...
Reading makefile `1.mak'...
Updating makefiles....
 Considering target file `1.mak'.
  Looking for an implicit rule for `1.mak'.
  No implicit rule found for `1.mak'.
  Finished prerequisites of target file `1.mak'.
 No need to remake target `1.mak'.
Updating goal targets....
Considering target file `obj-dir/1.o'.
 File `obj-dir/1.o' does not exist.
 Finished prerequisites of target file `obj-dir/1.o'.
Must remake target `obj-dir/1.o'.
echo This is obj-dir/1.o > obj-dir/1.o
Putting child 0x080746a8 (obj-dir/1.o) PID 12691 on the chain.
Live child 0x080746a8 (obj-dir/1.o) PID 12691 
/bin/sh: obj-dir/1.o: No such file or directory
Got a SIGCHLD; 1 unreaped children.
Reaping losing child 0x080746a8 PID 12691 
make: *** [obj-dir/1.o] Error 1
Removing child 0x080746a8 PID 12691 from chain.

It seems `make' uses the rule `$(OBJDIR)/1.o:' as default for this
makefile script, not the first rule `$(TARGET1): .mkdir $(OBJDIR)/1.o'.

If I do a little change to the makefile (removing the leading dot from the 
target name):
TARGET1 = target1
TARGET2 = target2

`make' executes the first rule `$(TARGET1): .mkdir $(OBJDIR)/1.o' as expected.

So I guess `make' considers the targets beginning with a dot hidden, just as 
`bash' does.
Is it that? Does the manual document this? I just can't find the answer in the 
Maybe I haven't read the manual carefully enough.


reply via email to

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