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)
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)
This just all your source file name ending with .c ie file1.c, file2.c file3.c etc.
in
$ is a way to define variables in Makefile
$@ is your target, in your case it is "test".
$^ is the list of all the prerequisites of the rule, including the names of the directories in which they were found
$< is the list of all dependencies
ref: https://www.gnu.org/software/make/manual/make.html#Automatic-Variables
This is what these two symbols mean:
test
SRC=$(wildcard '*.c')
)All such variables are explained in the Automatic variables page of the GNU make manual.