Reputation:
Consider the following makefile:
TARGET=fmake
TARGET2=test_second
fmake: $(TARGET2).c foo.c\
$(TARGET).c test.h clean
$(CC) -o $(TARGET) $(TARGET).c foo.c
$(CC) -o $(TARGET2) $(TARGET2).c
foo.c:
echo Some text
clean:
rm -f fmake test_second
CC=$(VAR2)
VAR2=gcc
After the make
bash command the following display
rm -f fmake test_second
gcc -o fmake fmake.c foo.c
gcc -o test_second test_second.c
As said here foo.c doesn't processed because there is no dependencies for this target. But both foo.c
and clean
have no dependencies, but clean is processed
. Why?
Upvotes: 0
Views: 36
Reputation: 272802
Because a file called foo.c
exists, whereas no file called clean
exists. So Make thinks that one needs to be made. Note that clean
should really be declared as a phony target.
Upvotes: 2