是否有更好的方法从 makefile 中获取设置环境变量的脚本?
FLAG ?= 0
ifeq ($(FLAG),0)
export FLAG=1
/bin/myshell -c '<source scripts here> ; $(MAKE) $@'
else
...targets...
endif
最佳答案
Makefile 默认 shell 是 /bin/sh
,它不实现 source
。
将 shell 更改为 /bin/bash
使其成为可能:
# Makefile
SHELL := /bin/bash
rule:
source env.sh && YourCommand
关于shell - 如何在 Makefile 中获取脚本源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7507810/