What does @: (in colon) mean in a Makefile?

What does the following do in a makefile?

rule: $(deps) @: 

I can not find this in the instruction manual.

+83
makefile gnu-make
Dec 22 '11 at 23:21
source share
2 answers

This means that "do not send this command on exit." So this rule says: "Run the shell command : and not echo output.

Of course, the shell command : is non-op, so it says "do nothing and don't tell anything."

Why?

The trick here is that you have an obscure combination of two different syntaxes. The syntax for make (1) is to use an action starting with @, which simply does not mean repeating the command. So, a rule like

 always: @echo this always happens 

won't highlight

  echo this always happens this always happens 

Now any shell command can be part of the rule action, including : Bash help explains this, as elsewhere:

 $ help : :: : Null command. No effect; the command does nothing. Exit Status: Always succeeds. 
+111
Dec 22 '11 at 23:23
source share

For those who are wondering why you can do this, it is useful if you want to pretend that something has been done so that Make does not display โ€œNothing to be done forโ€ your goal.

One example: if you have a fake goal that you always fulfill, and in it you have a bunch of conventions in the team. You want to have at least something in case these conditions arise false and nothing is done.

For example (from Linux scripts / Makefile.clean):

 __clean: $(subdir-ymn) ifneq ($(strip $(__clean-files)),) +$(call cmd,clean) endif ifneq ($(strip $(__clean-dirs)),) +$(call cmd,cleandir) endif ifneq ($(strip $(clean-rule)),) +$(clean-rule) endif @: 
+27
May 29 '13 at 16:04
source share



All Articles