1

Today I saw something strange in a makefile.

Is that - in -rm a typo, or it means something?

appname = hello
obj = hello.o
gcc = gcc
cflags = -g -Wall

$(appname):$(obj)
    $(gcc) $(cflags) $(obj) -o $(app) -lpthread

# p_test.o:p_test.c
#   $(gcc) $(cflags) -c  hello.c

.PHONY:clean
clean:
    -rm $(obj)

.PHONY:run
run:
    ./hello 1
KcFnMi
  • 5,516
  • 10
  • 62
  • 136

1 Answers1

2

It means to ignore errors, see the fine manual.

Therefore, your make will not fail if $(obj) doesn't exist by the time you issue make clean.