Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
生成文件能否依赖于shell脚本的结果?_Shell_Makefile - Fatal编程技术网

生成文件能否依赖于shell脚本的结果?

生成文件能否依赖于shell脚本的结果?,shell,makefile,Shell,Makefile,有没有办法将shell脚本的返回值用作Makefile中的依赖项 例如: 生成文件: proj: getsource.sh cc src1.c src2.c ... getsource.sh: checksource.sh wget http://www.something.com/src1.c checksource.sh: #!/bin/sh # bash pseudo code because I can never remember bash's syntax if [

有没有办法将shell脚本的返回值用作Makefile中的依赖项

例如:

生成文件:

proj: getsource.sh
    cc src1.c src2.c ...
getsource.sh: checksource.sh
    wget http://www.something.com/src1.c
checksource.sh:

#!/bin/sh
# bash pseudo code because I can never remember bash's syntax
if [[ -not -exists src1.c ]]
    exit 1
else
    exit 0
...

在不存在源代码的情况下执行时,生成文件将运行getsource.sh目标,然后运行proj目标。如果源存在,它将只运行proj目标。

这样做怎么样:

proj: src1.c src2.c  # ...
    cc src1.c src2.c  # ...

src1.c:
    @echo "retrieving src1.c ..."
    @wget http://www.something.com/src1.c

在网上获取一些信息只是一个简单的例子。如果make具有此功能,我更感兴趣。是否确实希望行为取决于脚本的返回值,而不是其输出?