Autoconf:如何将安装路径放入config.h [英] Autoconf: How to get installation paths into config.h

查看:90
本文介绍了Autoconf:如何将安装路径放入config.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序需要在运行时加载一些文件,这些文件将安装到提供给./configure --datadir=/somewhere

My program needs to load some files at run time, which will be installed into whatever folder is given to ./configure --datadir=/somewhere

由于我的程序需要在运行时知道此文件夹的位置,因此我需要在某处#define符号,以便C代码可以以字符串形式访问路径.

As my program needs to know where this folder is at run time, I need to #define a symbol somewhere so the C code can access the path as a string.

我目前正在通过修改编译器标志来这样做:

I am currently doing this by modifying the compiler flags:

AM_CPPFLAGS = -DDATA_PATH=\"$(pkgdatadir)\"

但是,由于configure脚本已经生成了一个config.h文件,其中包含许多其他内容,所以我希望将符号显示在其中.

However as the configure script already produces a config.h file with a bunch of other things in it, I would like to have the symbol appear in there instead.

有可能吗?

推荐答案

AC_DEFINE_UNQUOTED([DATA_PATH], ["$pkgdatadir"])

尽管修改编译器标志确实是更常用的方法.

Although modifying the compiler flags is really the more usual way to do it.

这篇关于Autoconf:如何将安装路径放入config.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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