Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the meaning for . (dot) before the target in makefile

Tags:

makefile

In a make file i found the code snip like below. Is there any difference between create_file and run_debug ? i mean the use of . (dot) before create_file introduce any functionality like PHONY?

all:debug run_debug
setup: .create_file

.create_file:
      cd /home/user1
      touch file.txt

 run_debug:
      @echo Building debug
      cd /home/user1/debug
like image 817
BEPP Avatar asked Sep 09 '15 13:09

BEPP


2 Answers

As far as I know it has only one purpose (and in this makefile that purpose is obviated by the makefile construction).

From How make Processes a Makefile:

By default, make starts with the first target (not targets whose names start with ‘.’). This is called the default goal.

So a leading . means that make will not consider that target as a valid default goal.

But, as written, the all target is the first target in this makefile so that will be the default goal so the leading dot here doesn't actually do anything.

That said all three of the setup, run_debug and .create_file targets should be marked as .PHONY and may have much better ways of being written/etc.

like image 95
Etan Reisner Avatar answered Nov 16 '22 15:11

Etan Reisner


In addition to the default goal use, I also found it convenient that targets beginning with a . are not displayed in auto-completion, i.e. typing make + Tab

So I prefix targets that are not meant for the end user with a .

like image 41
Agis Avatar answered Nov 16 '22 15:11

Agis