Reputation: 292
I am trying to create a makefile so I can compile multiple C files. this makefile doesn't work as expected and do only compile ex1 when i run make all
and gives error about ex3 (See error log)
CFLAGS=-Wall -g
all:
make ex1
make ex3
clean:
rm -f ex1
rm -f ex3
Error:
make all
make ex1
make[1]: Entering directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
cc -Wall -g ex1.c -o ex1
make[1]: Leaving directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
make ex3
make[1]: Entering directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
make[1]: *** No rule to make target 'ex3'. Stop.
make[1]: Leaving directory '/home/daniel/ownCloud/code/Learn C the hard way/Make'
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 2
Upvotes: 1
Views: 83
Reputation: 1782
it is a bad idea recursively invoke make
. You should write your makefile as follows:
CFLAGS=-Wall -g
all: ex1 ex3
clean:
rm -f ex1 ex3
Upvotes: 1