There are a number of problems.
The target is an executable, not a .c file:
That should be:
The program is dependent on object files. The object files are dependent on source files, but GNU make already knows that, so you don't need to tell it how to compile.
Now, make provides a way of making up object file names, from source file names using text substitution.
So, we need to name the source files:
And you do have to tell it how to link.
1 2
|
$(TARGET): $(SRCS:.c=.o)
$(LINK.c) $^ -o $@
|
$^
is the list of sources,
proj1.o
in this case.
$@
is the name of the target,
proj1
in this case.
Use
$(LINK.cc)
to link C++ programs.
The clean step must also delete the object files:
1 2
|
clean:
rm $(TARGET) $(SRCS:.c=.o)
|