我有一个makefile,我想从中调用另一个外部bash脚本来完成建筑的另一部分。我最好怎么去做这件事。从make文件运行bash脚本
24
A
回答
24
就像从一个makefile调用任何其他命令:
target: prerequisites
shell_script arg1 arg2 arg3
关于你进一步的解释:
.PHONY: do_script
do_script:
shell_script arg1 arg2 arg3
prerequisites: do_script
target: prerequisites
5
每个在makefile规则的行动是,将在执行的命令子shell。您需要确保每个命令都是独立的,因为每个命令都将在单独的子shell中运行。
出于这个原因,你会经常看到换行符逃脱当笔者想要几个命令在同一子shell中运行:
targetfoo:
command_the_first foo bar baz
command_the_second wibble wobble warble
command_the_third which is rather too long \
to fit on a single line so \
intervening line breaks are escaped
command_the_fourth spam eggs beans
0
也许不是“正确”的方式做到像已经提供的答案,但是我遇到了这个问题,因为我想让我的makefile运行我编写的脚本来生成一个头文件,该文件将为整个软件包提供版本。我在这个软件包中有很多目标,并且不想为它们添加全新的先决条件。把它放在我的makefile的开头为我工作
$(shell ./genVer.sh)
它告诉make只是运行一个shell命令。 ./genVer.sh
是要运行的脚本的路径(与makefile相同的目录)和名称。无论我指定哪个目标(包括clean
,这都是缺点,但最终对我来说不是一个大问题),它都会运行。
相关问题
- 1. 运行BASH脚本文件
- 2. 从bash脚本文件运行docker-compose
- 3. bash脚本从rc.local运行
- 4. 从java运行bash脚本
- 5. 从JVM运行bash脚本
- 6. 从R脚本运行bash脚本
- 7. 从PHP脚本运行bash脚本
- 8. 从bash脚本调用make不会使
- 9. 从bash脚本运行可执行文件
- 10. Bash脚本:从文件打印grep'd行
- 11. 从bash脚本执行R文件
- 12. 从Windows bat文件执行bash脚本
- 13. 多行bash脚本和make文件指令评估的bash变量的串联
- 14. 并行运行bash脚本
- 15. 并行运行bash脚本?
- 16. 快速bash脚本在指定文件夹中运行脚本?
- 17. 从根bash脚本运行非根文件
- 18. 如何从厨师配方运行bash脚本文件
- 19. 运行bash脚本卷曲从网络
- 20. 如何从Java运行bash脚本
- 21. 如何从magento运行bash shell脚本?
- 22. 从bash脚本运行几个命令
- 23. 从incron运行bash脚本的问题
- 24. 从Windows PowerShell运行bash脚本
- 25. 从Applescript内运行bash脚本
- 26. bash脚本从命令行运行但不是从cron运行
- 27. Bash脚本运行php脚本
- 28. awk的运行bash脚本
- 29. 从Octave中的其他脚本文件运行脚本文件
- 30. bash脚本:文本行
但我需要在先决条件 – 2010-03-23 23:47:45
@Matthew之前运行脚本,那么您的makefile设置不正确。制作一个新的'.PHONY'目标,以满足您的先决条件,并在该目标中运行该脚本。 – 2010-03-24 00:15:57
为您的案例编辑更多。 – 2010-03-24 00:17:19