3

makefile:

$(TARGET): $(OBJ)
    $(GCC) $(LDFLAGS) -o $@ $^ 

What $@ and $^ exactly do in make file?

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
suren
  • 1,744
  • 2
  • 12
  • 7

2 Answers2

4

$^ is the set of dependent files used to build something else.

$@ is the name of the target to be built.

See http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html

aschepler
  • 70,891
  • 9
  • 107
  • 161
3

$@ is the name of the target. This is quite useful when the target is a pattern rather than fixed.

$^ is the name of the prerequisite that caused the rule to execute.

PQuinn
  • 992
  • 6
  • 11