Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the makefile symbols $@ and $< mean?

Tags:

makefile

CC=g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=main.cpp hello.cpp factorial.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=hello  all: $(SOURCES) $(EXECUTABLE)  $(EXECUTABLE): $(OBJECTS)     $(CC) $(LDFLAGS) $(OBJECTS) -o $@  .cpp.o:     $(CC) $(CFLAGS) $< -o $@ 

What do the $@ and $< do exactly?

like image 312
Mohit Deshpande Avatar asked Jul 10 '10 17:07

Mohit Deshpande


People also ask

What does the special symbol mean in makefile $@ $<?

Inside actions we can use: $@ to represent the full target name of the current target $? returns the dependencies that are newer than the current target $* returns the text that corresponds to % in the target $< returns the name of the first dependency $^ returns the names of all the dependencies with space as the ...

What does $$ mean in makefile?

This special significance of ' $ ' is why you must write ' $$ ' to have the effect of a single dollar sign in a file name or recipe. Variable references can be used in any context: targets, prerequisites, recipes, most directives, and new variable values.

What is symbol in make?

Lion is the symbol of Make in India. This logo was inspired by the Ashoka Chakra, to represent India's success in all spheres. You can read about the Make In India – Initiatives, Aims, Advantages & Challenges in the given link.


1 Answers

$@ is the name of the target being generated, and $< the first prerequisite (usually a source file). You can find a list of all these special variables in the GNU Make manual.

For example, consider the following declaration:

all: library.cpp main.cpp 

In this case:

  • $@ evaluates to all
  • $< evaluates to library.cpp
  • $^ evaluates to library.cpp main.cpp
like image 115
bdonlan Avatar answered Sep 16 '22 22:09

bdonlan