误解路径,失败“没有规则制定目标”

时间:2013-07-31 04:40:31

标签: linux makefile

我正在尝试从源代码构建trace-cmd.git;最糟糕的是,我已经在同一台机器上构建了一次,成功;但是没有留下任何记录,也无法分辨在此期间会发生什么。

所以现在我正在尝试重建,我感到害怕:

trace-cmd$ make
make: *** No rule to make target `/media/disk/trace-cmd/event-parse.c', needed by `event-parse.o'.  Stop.

好的,让我们看一下调试的内容:

trace-cmd$ make -d
...
    Successfully remade target file `trace_python_dir'.
    Pruning file `tc_version.h'.
    Considering target file `libparsevent.a'.
      Considering target file `event-parse.o'.
        Pruning file `/media/disk/src/trace-cmd/event-parse.c'.        ## THIS EXISTS!
        Pruning file `.event-parse.d'.
        Considering target file `/media/disk/trace-cmd/event-parse.c'. ## THIS DOESN'T???
         File `/media/disk/trace-cmd/event-parse.c' does not exist.
        ...
          Trying pattern rule with stem `event-parse.w'.
          Trying implicit prerequisite `/media/disk/trace-cmd/SCCS/s.event-parse.w'.
         Trying pattern rule with stem `event-parse'.
         Rejecting impossible implicit prerequisite `/media/disk/trace-cmd/event-parse.w'.
         No implicit rule found for `/media/disk/trace-cmd/event-parse.c'.
         Finished prerequisites of target file `/media/disk/trace-cmd/event-parse.c'.
        Must remake target `/media/disk/trace-cmd/event-parse.c'.
make: *** No rule to make target `/media/disk/trace-cmd/event-parse.c', needed by `event-parse.o'.  Stop.

好的,发生了什么事?当然实际文件存在:

trace-cmd$ ls -la /media/disk/src/trace-cmd/event-parse.c
-rw-r--r-- 1 user user 121563 2013-03-20 19:03 /media/disk/src/trace-cmd/event-parse.c

...但这是/media/disk/src/trace-cmd/event-parse.c !!和

  • make已经找到了一次;
  • 然而make由于某种原因决定将/src/从路径中删除,

...而且该文件显然不存在:

trace-cmd$ ls /media/disk/trace-cmd/event-parse.c
ls: cannot access /media/disk/trace-cmd/event-parse.c: No such file or directory

有人可以解释一下,因为可能的原因make决定放弃路径的一部分,以便它找不到文件,它最初有正确的引用?

1 个答案:

答案 0 :(得分:1)

知道了 - 我以为我专注于那个.event-parse.d文件:

trace-cmd$ head -n 4 .event-parse.d 
event-parse.o: /media/disk/trace-cmd/event-parse.c \
 /usr/include/stdio.h /usr/include/features.h /usr/include/bits/predefs.h \
 /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
 /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \

......事实上,那是错误的道路......如果我删除这个.d文件会怎样?

trace-cmd$ rm .event-parse.d 
trace-cmd$ make
  COMPILE FPIC           event-parse.o
make: *** No rule to make target `/media/disk/trace-cmd/trace-seq.c', needed by `trace-seq.o'.  Stop.

哦,我的。必须有更多:

trace-cmd$ ls .*.d
.event-parse.d      .plugin_kmem.d          .trace-filter.d      .trace-options.d    .trace-seq.d
.kbuffer-parse.d    .plugin_kvm.d           .trace-ftrace.d      .trace-output.d     .trace-split.d
.kernel-shark.d     .plugin_mac80211.d      .trace-graph.d       .trace-plot-cpu.d   .trace-stack.d
...

......确实有;显然是来自以前编译的缓存文件,其中我确实在另一个目录中编译。如果我全部删除它们:

trace-cmd$ rm .*.d
trace-cmd$ make
...
gcc --shared event-parse.o trace-seq.o parse-filter.o parse-utils.o trace-util.o trace-input.o trace-ftrace.o trace-output.o trace-recorder.o trace-restore.o trace-usage.o trace-blk-hack.o kbuffer-parse.o ctracecmd_wrap.o -o ctracecmd.so
Note: to build the gui, type "make gui"
      to build man pages, type "make doc"
嗯,看似有效;我又恢复了快乐{​​{1}}
干杯!