Makefile 为什么Make会忽略显式模式规则?

Makefile 为什么Make会忽略显式模式规则?,makefile,ibm-midrange,Makefile,Ibm Midrange,我正在使用GNUMake4.0在IBMi系统上编译代码。Make莫名其妙地选择了错误的规则来构建一种类型的对象 在这个平台上,程序对象是从源代码编译的模块中构建的。还有一个方便快捷的命令,可以直接从一段源代码创建一个程序,方法是从源代码创建一个临时模块,然后从该模块生成一个程序。我遇到的问题是Make使用的是快捷命令(crtbndrpg),而不是两步版本(crtrpgmod+crtpgm),即使目标规则指定程序应该从模块而不是快捷方式生成 有两个makefiles:一个是描述如何创建IBM i对

我正在使用GNUMake4.0在IBMi系统上编译代码。Make莫名其妙地选择了错误的规则来构建一种类型的对象

在这个平台上,程序对象是从源代码编译的模块中构建的。还有一个方便快捷的命令,可以直接从一段源代码创建一个程序,方法是从源代码创建一个临时模块,然后从该模块生成一个程序。我遇到的问题是Make使用的是快捷命令(
crtbndrpg
),而不是两步版本(
crtrpgmod
+
crtpgm
),即使目标规则指定程序应该从模块而不是快捷方式生成

有两个makefiles:一个是描述如何创建IBM i对象的通用Makefile,另一个是描述此项目中所有项的对象依赖关系的特定于项目的Makefile,
include
s是通用Makefile。我的通用生成文件如下所示(为简单起见进行了编辑):

要构建相关对象,请执行以下操作:

bash-4.2$ make AB2001.B.PGM OBJPATH:='/qsys.lib/xp33make.lib' -f xp33make/xpmake -d --no-builtin-rules
应该发生什么:它应该首先使用
crtrpgmod
命令创建模块,它会这样做。然后应使用
crtpgm
命令创建程序。但是,由于某种原因,它没有通过
crtpgm
创建程序,而是尝试使用
crtbndrpg
命令直接从源代码构建程序。我唯一能想到的是Make可能将AB2001.B.MODULE视为一个中间文件,并选择绕过
crtrpgmod
步骤。这是真的吗?我怎样才能让make遵守我的规则,而不是试图过度思考

以下是输出:

GNU Make 4.0
Built for powerpc-ibm-aix5.3.0.0
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'xp33make/xpmake'...
Reading makefile '/home/SMEEP/Source/xp33make/../SDE/IBMiMake' (search path) (no ~ expansion)...
Updating makefiles....
 Considering target file '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  Looking for an implicit rule for '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  No implicit rule found for '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  Finished prerequisites of target file '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
 No need to remake target '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
 Considering target file 'xp33make/xpmake'.
  Looking for an implicit rule for 'xp33make/xpmake'.
  No implicit rule found for 'xp33make/xpmake'.
  Finished prerequisites of target file 'xp33make/xpmake'.
 No need to remake target 'xp33make/xpmake'.
Updating goal targets....
Considering target file 'AB2001.B.PGM'.
 File 'AB2001.B.PGM' does not exist.
 Looking for an implicit rule for 'AB2001.B.PGM'.
 Trying pattern rule with stem 'AB2001.B'.
 Trying implicit prerequisite 'AB2001.B.CLLE'.
 Trying pattern rule with stem 'AB2001.B'.
 Trying implicit prerequisite 'AB2001.B.RPGLE'.
 Found an implicit rule for 'AB2001.B.PGM'.
  Considering target file 'AB2001.B.RPGLE'.
   Looking for an implicit rule for 'AB2001.B.RPGLE'.
   No implicit rule found for 'AB2001.B.RPGLE'.
   Finished prerequisites of target file 'AB2001.B.RPGLE'.
  No need to remake target 'AB2001.B.RPGLE'; using VPATH name '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
  Considering target file 'AB2001.B.MODULE'.
   Looking for an implicit rule for 'AB2001.B.MODULE'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.C'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.CLLE'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.RPGLE'.
   Found prerequisite 'AB2001.B.RPGLE' as VPATH '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'
   Found an implicit rule for 'AB2001.B.MODULE'.
    Pruning file '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
    Pruning file '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
   Finished prerequisites of target file 'AB2001.B.MODULE'.
   Prerequisite '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE' is older than target 'AB2001.B.MODULE'.
   Prerequisite '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE' is older than target 'AB2001.B.MODULE'.
  No need to remake target 'AB2001.B.MODULE'; using VPATH name '/QSYS.LIB/XP33MAKE.LIB/AB2001.B.MODULE'.
 Finished prerequisites of target file 'AB2001.B.PGM'.
Must remake target 'AB2001.B.PGM'.
system "crtbndrpg pgm(XP33MAKE/AB2001.B) srcstmf('/home/SMEEP/Source/xp33make/AB2001.B.RPGLE')" >/home/SMEEP/Source/xp33make/Logs/2016-11-14_11.42.55-Mon/AB2001.B.RPGLE.log 2>&1
Putting child 30016df0 (AB2001.B.PGM) PID 1155363 on the chain.
Live child 30016df0 (AB2001.B.PGM) PID 1155363 
Reaping losing child 30016df0 PID 1155363 
/home/SMEEP/Source/xp33make/../SDE/IBMiMake:476: recipe for target 'AB2001.B.PGM' failed
Removing child 30016df0 PID 1155363 from chain.
GNU Make 4.0
专为powerpc-ibm-aix5.3.0.0构建
版权所有(C)1988年至2013年自由软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。
正在读取生成文件。。。
正在读取makefile“xp33make/xpmake”。。。
正在读取makefile'/home/SMEEP/Source/xp33make//SDE/IBMiMake'(搜索路径)(无扩展)。。。
正在更新生成文件。。。。
考虑目标文件“/home/SMEEP/Source/xp33make/./SDE/IBMiMake”。
正在查找“/home/SMEEP/Source/xp33make/./SDE/IBMiMake”的隐式规则。
未找到“/home/SMEEP/Source/xp33make/./SDE/IBMiMake”的隐式规则。
已完成目标文件“/home/SMEEP/Source/xp33make/./SDE/IBMiMake”的先决条件。
无需重新制作目标“/home/SMEEP/Source/xp33make/。/SDE/IBMiMake”。
正在考虑目标文件“xp33make/xpmake”。
正在查找“xp33make/xpmake”的隐式规则。
未找到“xp33make/xpmake”的隐式规则。
已完成目标文件“xp33make/xpmake”的先决条件。
无需重新制作目标“xp33make/xpmake”。
更新目标。。。。
正在考虑目标文件“AB2001.B.PGM”。
文件“AB2001.B.PGM”不存在。
正在寻找“AB2001.B.PGM”的隐式规则。
尝试使用词干“AB2001.B”的模式规则。
正在尝试“AB2001.B.CLLE”。
尝试使用词干“AB2001.B”的模式规则。
正在尝试“AB2001.B.RPGLE”。
找到“AB2001.B.PGM”的隐式规则。
正在考虑目标文件“AB2001.B.RPGLE”。
正在查找“AB2001.B.RPGLE”的隐式规则。
未找到“AB2001.B.RPGLE”的隐式规则。
已完成目标文件“AB2001.B.RPGLE”的先决条件。
无需重新制作目标“AB2001.B.RPGLE”;使用VPATH名称“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”。
正在考虑目标文件“AB2001.B.MODULE”。
正在查找“AB2001.B.MODULE”的隐式规则。
尝试使用词干“AB2001.B”的模式规则。
正在尝试“AB2001.B.C”。
尝试使用词干“AB2001.B”的模式规则。
正在尝试“AB2001.B.CLLE”。
尝试使用词干“AB2001.B”的模式规则。
正在尝试“AB2001.B.RPGLE”。
找到的先决条件“AB2001.B.RPGLE”为VPATH“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”
找到“AB2001.B.MODULE”的隐式规则。
正在修剪文件“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”。
正在修剪文件“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”。
已完成目标文件“AB2001.B.MODULE”的先决条件。
先决条件“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”早于目标“AB2001.B.MODULE”。
先决条件“/home/SMEEP/Source/xp33make/AB2001.B.RPGLE”早于目标“AB2001.B.MODULE”。
无需重新制作目标“AB2001.B.MODULE”;使用VPATH名称“/QSYS.LIB/XP33MAKE.LIB/AB2001.B.MODULE”。
已完成目标文件“AB2001.B.PGM”的先决条件。
必须重新制作目标“AB2001.B.PGM”。
系统“crtbndrpg pgm(XP33MAKE/AB2001.B)srcstmf('/home/SMEEP/Source/XP33MAKE/AB2001.B.RPGLE')”>/home/SMEEP/Source/XP33MAKE/Logs/2016-11-14_11.42.55-Mon/AB2001.B.RPGLE.log 2>&1
将子级30016df0(AB2001.B.PGM)PID 1155363放置在链上。
活孩子30016df0(AB2001.B.PGM)PID 1155363
收获丢失的孩子30016df0 PID 1155363
/home/SMEEP/Source/xp33make/。/SDE/IBMiMake:476:目标'AB2001.B.PGM'的配方失败
从链条上拆下子30016df0 PID 1155363。

您的示例仍然很难阅读:创建一个最小的示例通常是最好的(也就是说,构建一个使用
touch
等创建文件的示例,并且不依赖于您的环境)

另外,在配方中使用
$(eval…
来创建make变量赋值有点混乱。不要认为仅仅因为你在菜谱中这么做就涉及到某种范围:这些变量仍然是全局分配的

无论如何,问题是您有两种方法来构建与
%匹配的目标。PGM

%.PGM: %.RPGLE
%.PGM:
显然,您希望使用第二个模式,但如果匹配模式规则的词干长度相等(此处两者具有相同的词干,
.PGM
),则
make
将始终选择您定义的第一个模式,因此如果可以,它将始终选择第一个

GNU Make 4.0
Built for powerpc-ibm-aix5.3.0.0
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'xp33make/xpmake'...
Reading makefile '/home/SMEEP/Source/xp33make/../SDE/IBMiMake' (search path) (no ~ expansion)...
Updating makefiles....
 Considering target file '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  Looking for an implicit rule for '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  No implicit rule found for '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
  Finished prerequisites of target file '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
 No need to remake target '/home/SMEEP/Source/xp33make/../SDE/IBMiMake'.
 Considering target file 'xp33make/xpmake'.
  Looking for an implicit rule for 'xp33make/xpmake'.
  No implicit rule found for 'xp33make/xpmake'.
  Finished prerequisites of target file 'xp33make/xpmake'.
 No need to remake target 'xp33make/xpmake'.
Updating goal targets....
Considering target file 'AB2001.B.PGM'.
 File 'AB2001.B.PGM' does not exist.
 Looking for an implicit rule for 'AB2001.B.PGM'.
 Trying pattern rule with stem 'AB2001.B'.
 Trying implicit prerequisite 'AB2001.B.CLLE'.
 Trying pattern rule with stem 'AB2001.B'.
 Trying implicit prerequisite 'AB2001.B.RPGLE'.
 Found an implicit rule for 'AB2001.B.PGM'.
  Considering target file 'AB2001.B.RPGLE'.
   Looking for an implicit rule for 'AB2001.B.RPGLE'.
   No implicit rule found for 'AB2001.B.RPGLE'.
   Finished prerequisites of target file 'AB2001.B.RPGLE'.
  No need to remake target 'AB2001.B.RPGLE'; using VPATH name '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
  Considering target file 'AB2001.B.MODULE'.
   Looking for an implicit rule for 'AB2001.B.MODULE'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.C'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.CLLE'.
   Trying pattern rule with stem 'AB2001.B'.
   Trying implicit prerequisite 'AB2001.B.RPGLE'.
   Found prerequisite 'AB2001.B.RPGLE' as VPATH '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'
   Found an implicit rule for 'AB2001.B.MODULE'.
    Pruning file '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
    Pruning file '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE'.
   Finished prerequisites of target file 'AB2001.B.MODULE'.
   Prerequisite '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE' is older than target 'AB2001.B.MODULE'.
   Prerequisite '/home/SMEEP/Source/xp33make/AB2001.B.RPGLE' is older than target 'AB2001.B.MODULE'.
  No need to remake target 'AB2001.B.MODULE'; using VPATH name '/QSYS.LIB/XP33MAKE.LIB/AB2001.B.MODULE'.
 Finished prerequisites of target file 'AB2001.B.PGM'.
Must remake target 'AB2001.B.PGM'.
system "crtbndrpg pgm(XP33MAKE/AB2001.B) srcstmf('/home/SMEEP/Source/xp33make/AB2001.B.RPGLE')" >/home/SMEEP/Source/xp33make/Logs/2016-11-14_11.42.55-Mon/AB2001.B.RPGLE.log 2>&1
Putting child 30016df0 (AB2001.B.PGM) PID 1155363 on the chain.
Live child 30016df0 (AB2001.B.PGM) PID 1155363 
Reaping losing child 30016df0 PID 1155363 
/home/SMEEP/Source/xp33make/../SDE/IBMiMake:476: recipe for target 'AB2001.B.PGM' failed
Removing child 30016df0 PID 1155363 from chain.
%.PGM: %.RPGLE
%.PGM: