Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colon and $ in makefile

Tags:

makefile

What does TEMP0_FILES below compute to? SOURCE_FILES can equal to multiple source files. Please tell me the purpose of the following syntax :.cpp=.o

SOURCE_FILES = main.cpp

TEMP0_FILES = $(SOURCE_FILES:.cpp=.o)
like image 964
Arjun Singri Avatar asked Apr 24 '09 03:04

Arjun Singri


People also ask

What is :: In makefile?

Double-colon rules are rules written with '::' instead of ':' after the target names. They are handled differently from ordinary rules when the same target appears in more than one rule. When a target appears in multiple rules, all the rules must be the same type: all ordinary, or all double-colon.

What does AT symbol in a makefile?

The @ symbol is commonly seen at the beginning of an action lines and means that the action line itself is not be be echoed on the screen as it is executed. Macros are commonly used in makefiles to decrease the amount of typing required.

What is the difference between and := in makefile?

= defines a recursively-expanded variable. := defines a simply-expanded variable.


1 Answers

The : syntax causes a substitution to occur on the variable. In this case it will replace ".cpp" with ".o" in all of the items in the SOURCE_FILES variable.

TEMP0_FILES will be "main.o"

If SOURCE_FILES is "main.cpp otherfile.cpp otherfile2.cpp" TEMP0_FILES will become: "main.o otherfile.o otherfile2.o" etc.

like image 172
Andy White Avatar answered Oct 04 '22 00:10

Andy White