Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

makefile aliases

Tags:

makefile

Please explain $@ $^ $ in the makefile below

LIBS  = -lkernel32 -luser32 -lgdi32 -lopengl32
CFLAGS = -Wall

# (This should be the actual list of C files)
SRC=$(wildcard '*.c')

test: $(SRC)
    gcc -o $@ $^ $(CFLAGS) $(LIBS)
like image 959
vehomzzz Avatar asked May 23 '26 21:05

vehomzzz


1 Answers

This is what these two symbols mean:

  • $@ is the target i.e. test
  • $^ is the list of pre-requisites for the rule (which in this case is the expanded wild card list as specified in SRC=$(wildcard '*.c'))

All such variables are explained in the Automatic variables page of the GNU make manual.

like image 119
t0mm13b Avatar answered May 26 '26 19:05

t0mm13b