gnu make:不明白为什么我的隐式从未被发现

gnu make : doesn't understand why my implicit is never found

我正在尝试使用我自己的隐式规则编译 Cobol 源代码但没有成功。

上下文:

  1. GNU 在 AIX 上制作 3.81
  2. Cobol 源文件位于一个源目录,而编译后的文件位于另一个
  3. Cobol 源文件扩展名为.cbl,编译后的文件没有扩展名即AZ0001.cbl编译后变成AZ0001

这是我的 Makefile:

COBFLAGS=-g -qTEST -q"SPILL(32648)" -q64 -q"WSCLEAR(32)" -qNOSEQ -qLIST -qNUMBER -qSSRANGE -q"LINECOUNT(0)"
SRCDIR=../../ai_cobol/src/main/cbl/lib
CPYDIR=../../ai_cobol/src/main/cpy
TMPCBL=/tmp/tmpcbl

vpath %.cbl $(SRCDIR)

SOURCES = $(wildcard $(SRCDIR)/*.cbl)
CIBLES = $(notdir $(SOURCES))

.SUFFIXES: .cbl

% : %.cbl
        cob2 $(COBFLAGS) -I$(CPYDIR) $< $(ZZDEBUG)

all: init todo

init:
        rm -rf $(TMPCBL) && mkdir -p $(TMPCBL)

todo: $(CIBLES)
        echo ""

启动 Gmake 从未构建我的 cobol 源文件。但是,调试输出显示 gmake 找到了它们:

....
Considering target file `ZZABEND.cbl'.
 Looking for an implicit rule for `ZZABEND.cbl'.
 Trying pattern rule with stem `ZZABEND.cbl'.
 Trying implicit prerequisite `ZZABEND.cbl,v'.
 Trying pattern rule with stem `ZZABEND.cbl'.
 Trying implicit prerequisite `RCS/ZZABEND.cbl,v'.
 Trying pattern rule with stem `ZZABEND.cbl'.
 Trying implicit prerequisite `RCS/ZZABEND.cbl'.
 Trying pattern rule with stem `ZZABEND.cbl'.
 Trying implicit prerequisite `s.ZZABEND.cbl'.
 Trying pattern rule with stem `ZZABEND.cbl'.
 Trying implicit prerequisite `SCCS/s.ZZABEND.cbl'.
 No implicit rule found for `ZZABEND.cbl'.
 Finished prerequisites of target file `ZZABEND.cbl'.
No need to remake target `ZZABEND.cbl'; using VPATH name `../../ai_cobol/src/main/cbl/lib/ZZABEND.cbl'.
Considering target file `ZZASBTPB.cbl'.
 Looking for an implicit rule for `ZZASBTPB.cbl'.
 Trying pattern rule with stem `ZZASBTPB.cbl'.
 Trying implicit prerequisite `ZZASBTPB.cbl,v'.
 Trying pattern rule with stem `ZZASBTPB.cbl'.
 Trying implicit prerequisite `RCS/ZZASBTPB.cbl,v'.
 Trying pattern rule with stem `ZZASBTPB.cbl'.
 Trying implicit prerequisite `RCS/ZZASBTPB.cbl'.
 Trying pattern rule with stem `ZZASBTPB.cbl'.
 Trying implicit prerequisite `s.ZZASBTPB.cbl'.
 Trying pattern rule with stem `ZZASBTPB.cbl'.
 Trying implicit prerequisite `SCCS/s.ZZASBTPB.cbl'.
 No implicit rule found for `ZZASBTPB.cbl'.
 Finished prerequisites of target file `ZZASBTPB.cbl'.
No need to remake target `ZZASBTPB.cbl'; using VPATH name `../../ai_cobol/src/main/cbl/lib/ZZASBTPB.cbl'.
 ......

所以我不明白问题出在哪里.....

您的 'CIBLES' 包含源文件的名称;试试这个改变:

old: CIBLES = $(notdir $(SOURCES))
new: CIBLES = $(basename $(notdir $(SOURCES)))