tags:

views:

50

answers:

2
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?

+5  A: 

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

bdonlan
+4  A: 

The $@ and @< are special macros.

$@ is the file name of the target $< is the name of the first dependency

Eric U.