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

标签 shell makefile

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

相关文章:

makefile - 找不到 cl.h - 如何在生成文件中链接

android - 将 Android NDK make 文件重构为模块

可访问互联网时用于通知的 Bash 脚本

javascript - Mongo shell javascript 数组扩展

python - python 在 bash 中可以像这样吗?

c++ - Makefile 中的 foreach 找不到所有文件

makefile - mt19937 不是 std 的成员 可能的 makefile 问题

ios - 如何将VAMP插件编译到iOS ARMV7

linux - 尝试 'tail' 最新日志文件时出现问题

xml - 使用 shell 脚本(centos 环境)从 postgresql artifacoty 获取最新版本的 postgresql 版本