欢迎光临
我们一直在努力

linux – Makefile命令替换问题

本站教程收集整理的这篇文章主要介绍了linux – Makefile命令替换问题,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

给定不同的配置文件时,rebar不会自动重建文件.所以,我试图在Makefile级别上执行此操作:

REBAR=./rebar
REBAR_DEBUG=$(REBAR) -C rebar.debug.config
REBAR_COMPILE=$(REBAR) get-deps compile
LAST_CONfig:=$(cat config.tmp)
plt=dialyzer/sqlite3.plt

all: config_normal compile

compile:
    $(REBAR_COMPILE)

test:
    $(REBAR_COMPILE) eunit

clean:
    -rm -rf deps ebin priv doc/* .eunit c_src/*.o

docs:
    $(REBAR_COMPILE) doc

static: config_debug
    $(REBAR_DEBUG) get-deps compile
ifeq ($(wildcard $(plt)),)
    dialyzer --build_plt --apps kernel stdlib erts --output_plt $(plt) 
else
    dialyzer --plt $(plt) -r 便宜美国vps ebin
endif

cross_compile: config_cross
    $(REBAR_COMPILE) -C rebar.cross_compile.config

valgrind: clean
    $(REBAR_DEBUG) get-deps compile
    valgrind --tool=memcheck --leak-check=yes --num-callers=20 ./test.sh

ifeq ($(LAST_CONfig),normal)
config_normal:
    echo "$(LAST_CONfig) == normal"
else
config_normal: clean
    echo "$(LAST_CONfig) != normal"
    rm -f config.tmp
    echo "normal" > config.tmp
endif

ifeq ($(LAST_CONfig),debug)
config_debug: ;
else
config_debug: clean
    rm -f config.tmp
    echo "debug" > config.tmp
endif

ifeq ($(LAST_CONfig),cross)
config_cross: ;
else
config_cross: clean
    rm -f config.tmp
    echo "cross" > config.tmp
endif

.PHONY: all compile test clean docs static valgrind config_normal config_debug config_cross

意图很明显:当我使用需要某个配置文件的目标时,检查上次是否使用了相同的文件;运行干净并记录我们现在使用的配置.

但它不起作用,文件不断重新编译:

aromanov@alexey-desktop:~/workspace/gmcontroller/lib/sqlite3$make
rm -rf deps ebin priv doc/* .eunit c_src/*.o
echo " != normal"
 != normal
rm -f config.tmp
echo "normal" > config.tmp
./rebar get-deps compile
==> sqlite3 (get-deps)
==> sqlite3 (compilE)
Compiled src/sqlite3_lib.erl
Compiled src/sqlite3.erl
Compiling c_src/sqlite3_drv.c

尽管config.tmp包含“normal”:

aromanov@alexey-desktop:~/workspace/gmcontroller/lib/sqlite3$LAST_CONfig=$(cat config.tmp); echo $LAST_CONfig
normal

我错过了什么?

解决方法

您缺少需要使用
sHell的部分,以便在定义变量时实际调用外部程序.

LAST_CONfig:=$(sHell cat config.tmp)

本站总结

以上是本站教程为你收集整理的linux – Makefile命令替换问题全部内容,希望文章能够帮你解决linux – Makefile命令替换问题所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。