Answer the question
In order to leave comments, you need to log in
How to make make not swear if there are no files?
I made this makefile, set the goal "clean":
# .PHONY: all clean
all: hello.o main.o
gcc -o hello main.o hello.o
hello.o: hello.c
gcc -o hello.o -c hello.c
main.o: main.c
gcc -o main.o -c main.c
clean:
-rm ./*.o 2>/dev/null
$ make all
gcc -o hello.o -c hello.c
gcc -o main.o -c main.c
gcc -o hello main.o hello.o
$ make clean
rm ./*.o 2>/dev/null
$ make clean
rm ./*.o 2>/dev/null
makefile:9: recipe for target 'clean' failed
make: [clean] Error 1 (игнорирование)
Answer the question
In order to leave comments, you need to log in
It's not make that swears, but rm
Add -f to rm and everything will be ok
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question