查看Makefile中Shell脚本的输出 [英] See output of shell script in Makefile

查看:87
本文介绍了查看Makefile中Shell脚本的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Makefile中建立目标之前,如何执行Shell脚本,并在运行时查看输出?

How can I execute a shell script before building my targets in a Makefile, and see the output as it runs?

我有一个名为 prepare.sh 的脚本,该脚本生成一堆.pyx文件..pyx文件是我涉及make的构建过程的起点.它来自.pyx-> .c-> .o-> .so

I have a script called prepare.sh that generates a bunch of .pyx files. The .pyx files are the starting point of my build process involving make. It goes from .pyx -> .c -> .o -> .so

我不喜欢在制作之前必须单独运行prepare.sh.我想让它为我运行.

I don't like having to run prepare.sh separately prior to make. I'd like make to run it for me.

我可以使用它,但是看不到命令​​的输出.我想看看.这就是我现在拥有的:

I got it to work but I don't see the output of the command. I'd like to see it. This is what I have now:

PATH := ${PYTHONHOME}/bin:${PATH}

NOTHING:=$(shell ./prepare.sh)

PYXS?=$(wildcard merged/*.pyx)
SOURCES=$(PYXS:.pyx=.c)
OBJECTS=$(SOURCES:.c=.o)
SOBJECTS=$(OBJECTS:.o=.so)

推荐答案

将脚本的输出重定向到stderr.在这种情况下,您还可以删除虚拟 NOTHING 变量:

Redirect the output of your script to stderr. In this case you also can get rid of dummy NOTHING variable:

$(shell ./prepare.sh >&2)

UPD.

另一种选择是在配方之前执行脚本,然后再执行其他操作:

UPD.

Another option is to execute the script inside a recipe which runs prior to everithing else:

.PHONY : prepare
prepare :
    ./prepare.sh

-include prepare

另请参阅:原始Beta的答案(使用此技巧,GNU Make手册)

See also: the original Beta's answer with this hack, GNU Make manual entry explaining how it works.

这篇关于查看Makefile中Shell脚本的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆