如何检查makefile中目标的存在
发布时间:2020-12-16 09:52:23 所属栏目:百科 来源:网络整理
导读:我想在 shell中运行某些操作,具体取决于当前目录中的默认makefile是否包含某个目标. #!/bin/shmake -q some_targetif test $? -le 1 ; then true # do somethingelse false # do something else fi 这是有效的,因为如果目标不存在,GNU make会返回错误代码2,
我想在
shell中运行某些操作,具体取决于当前目录中的默认makefile是否包含某个目标.
#!/bin/sh make -q some_target if test $? -le 1 ; then true # do something else false # do something else fi 这是有效的,因为如果目标不存在,GNU make会返回错误代码2,否则返回0或1.问题是这种方式没有记录.这是男人的一部分: -q,--question ``Question mode''. Do not run any commands,or print anything; just return an exit status that is zero if the specified targets are already up to date,nonzero otherwise. 仅区分零/非零.这样做的正确方法是什么? 解决方法
您应该阅读
the GNU make manual而不是手册页:手册页只是摘要而不是完整的定义.手册说:
The exit status of make is always one of three values: 0 The exit status is zero if make is successful 2 The exit status is two if make encounters any errors. It will print messages describing the particular errors. 1 The exit status is one if you use the ‘-q’ flag and make determines that some target is not already up to date. 由于尝试创建不存在的目标是一个错误,因此在这种情况下,您将始终获得退出代码2. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |