automake环境变量条件 [英] automake Environment Variable Condition

查看:416
本文介绍了automake环境变量条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件Makefile.am,正在用来生成一个Makefile.在生成的Makefile中,我希望具有以下内容:

I have a file Makefile.am I am using to generate a Makefile. In the generated Makefile I want to have something like:

ifndef SOURCECODEPATH
   SOURCECODEPATH := /home/root/source_code_path
endif

这看起来很简单,有人知道我该怎么做吗?

It seems so simple, does anyone know how I can do it?

推荐答案

使用configure.ac中的rel ="noreferrer"> AM_CONDITIONAL 宏.

Use the AM_CONDITIONAL macro in configure.ac.

该脚本设置了一个您可以测试的变量,例如,如果启用了条件,则该变量将被设置为非空:AM_CONDITIONAL([ENABLE_SOURCECODEPATH], [test "x$ac_srcpath" != "x"])

The script sets a variable you can test, e.g., a variable that is set to non-empty if the condition is enabled: AM_CONDITIONAL([ENABLE_SOURCECODEPATH], [test "x$ac_srcpath" != "x"])

然后在Makefile.am中:

if !ENABLE_SOURCECODEPATH
SOURCECODEPATH = ...
endif

但是,由于要明确定义变量(如果未定义),因此无论使用AC_SUBST(SRCPATH, $ac_srcpath),都应该在configure.ac中对其进行定义:

However, since you are explicitly defining the variable if it's not defined, you should probably define it in configure.ac regardless, using AC_SUBST(SRCPATH, $ac_srcpath) :

SOURCECODEPATH = @SRCPATH@ # or $(SRCPATH)

这篇关于automake环境变量条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆