gpt4 book ai didi

shell - 如何在 Makefile 中获取脚本源?

转载 作者:行者123 更新时间:2023-12-03 05:23:27 24 4
gpt4 key购买 nike

是否有更好的方法从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com