Reputation: 447
I have the following makefile:
CC=gcc
CFLAGS=-std=c89
driver: driver
$(CC) -o driver driver.c
clean:
rm -f driver
Running make produces the driver executable. Now, if I modify the driver.c file and run
make again it does compile the new .c file but doesn't replace the one already there
Is that an expected behavior, or am I missing something here?
Upvotes: 0
Views: 34
Reputation: 222941
driver: driver
says driver
depends on itself. That is not correct. You want driver: driver.c
to say driver
depends on driver.c
.
(And that is fine for a very simple project with one executable that depends on one source files. In more complex projects, you will want executables to depend on object files and possibly other types of files and will want object files to depend on source files and possibly headers and possibly other files.)
Upvotes: 4