【问题标题】:That dash in the command `-rm` in the makefile means something? [duplicate]makefile 中的命令 `-rm` 中的破折号意味着什么? [复制]
【发布时间】:2018-10-10 13:39:44
【问题描述】:

今天我在 makefile 中看到了一些奇怪的东西。

-rm 中的 - 是拼写错误,还是意味着什么?

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

【问题讨论】:

    标签: makefile gnu-make


    【解决方案1】:

    表示忽略错误,见the fine manual。

    因此,如果在您发出make clean 时$(obj) 不存在,您的make 不会失败。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 2019-12-03
      • 1970-01-01
      • 1970-01-01
      • 2017-02-13
      • 1970-01-01
      • 2012-05-02
      相关资源
      最近更新 更多