[Top][All Lists]

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

goals starting with a period followed by a slash

From: Stefan Tauner
Subject: goals starting with a period followed by a slash
Date: Thu, 2 Feb 2017 16:53:03 +0100


I was trying to avoid a recipe becoming the default goal by adding a .
in front of its name. This worked as long as the target is just a name
and not a complete path. This is because the code - ever since the
initial commit in 1992 - checks for slashes in the target and ignores
the dot/period if it finds one.

read.c:1329 ff.:
                /* See if this target's name does not start with a '.',
                   unless it contains a slash.  */
                if (*name == '.' && strchr (name, '/') == 0
                    && strchr (name, '\\') == 0

I don't know why it behaves differently with slashes in the goal and
would love to hear a rationale for that (and it being mentioned in the
documentation ;)
The current documentation reads as follows (emphasis mine):
> By default, the goal is the first target in the makefile (*not
> counting targets that start with a period*).

Also, I think there is a bug related to this that truncates the target
name in the front. Suppose the following makefile:

        touch $@

        touch $@

According to the documentation simply running "make" should execute the
"useless" recipe and create a file named "useless" in the CWD. However,
since the check above sees the dot goal as a legitimate target it tries
to execute it... however something with the target name is wrong. The
actual output shows that the first slash is slashed (pun intended) from
the target name (make -d and -p confirms that too):

$ make
touch tmp/dot
touch: cannot touch 'tmp/dot': No such file or directory
make: *** [makefile:2: tmp/dot] Error 1

I have not tried to determine the exact cause of this or do further

Dipl.-Ing. Stefan Tauner
Research and Development
Embedded Systems Department

University of Applied Sciences Technikum Wien
Hoechstaedtplatz 6, 1200 Vienna, Austria
T: +43 1 333 40 77-316
E: address@hidden
I: embsys.technikum-wien.at
I: www.technikum-wien.at

reply via email to

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