config.h.in未被用作模板 [英] config.h.in not being used as a template

查看:263
本文介绍了config.h.in未被用作模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Autotools提供config.h.in. Autoconf手册中的 4.8.1配置标题模板 >. config.h.in看起来像这样:

I'm trying to supply a config.h.in to Autotools. The topic is covered in the Autoconf manual at 4.8.1 Configuration Header Templates. config.h.in looks like so:

/// \file config.h
/// \brief Library configuration file

#ifndef CRYPTOPP_CONFIG_H
#define CRYPTOPP_CONFIG_H

// define this if running on a big-endian CPU
#undef CRYPTOPP_BIG_ENDIAN

// define this if running on a little-endian CPU
#undef CRYPTOPP_LITTLE_ENDIAN

#endif  // CRYPTOPP_CONFIG_H

我们的 configure.ac 包括以下测试内容:

Our configure.ac includes the following for testing:

AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile] [libcryptopp.pc])
AC_CONFIG_SRCDIR([configure.ac])

AC_PROG_LIBTOOL
LT_INIT

AC_PROG_CXX
AC_LANG([C++])
AC_PROG_GREP

autoreconfconfigure运行之后,有一个config.h.问题是,它不遵循模板config.h.in.看起来像是这些工具所产生的新config.h.

After autoreconf and configure runs, there is a config.h. The problem is, it does not follow the template config.h.in. It looks like a new config.h produced by the tools.

当我检查config.log时,我只看到一个提及config.h的地方.我找不到有关正在发生的事情的其他信息:

When I examine config.log I only see one mention of config.h. I can't find additional information about what is going on:

config.status:1172: creating Makefile
config.status:1172: creating libcryptopp.pc
config.status:1172: creating config.h
config.status:1401: executing depfiles commands
config.status:1401: executing libtool commands

问题出在哪里,我该如何解决?

What is the problem and how do I fix it?

推荐答案

autoreconfconfigure运行之后,有一个config.h.问题 是,它不遵循模板config.h.in.看起来像是新的 这些工具产生的config.h.

After autoreconf and configure runs, there is a config.h. The problem is, it does not follow the template config.h.in. It looks like a new config.h produced by the tools.

此时查看您的config.h.in.我想您会感到惊讶.

Take a look at your config.h.in at that point. I think you'll be surprised.

问题在于autoreconf为您运行的程序中有

The issue is that among the programs that autoreconf runs for you is autoheader, which builds a config.h.in based on what it finds in configure.ac (or configure.in). Your subsequent configure then uses the new template, but nothing in particular about that is recorded in the configuration logs because the template already exists at that point.

通常,这种行为很方便,但是如果要提供自己的自定义config.h模板,则必须避免在运行autoreconf(或直接运行autoheader)时替换它.一种方法是完全避免运行这些程序.您可能会运行其他自动工具程序,并且如果您决定避免使用autoreconf,则可能值得花时间编写该脚本.

That behavior is usually a welcome convenience, but if you want to supply your own, custom config.h template then you must avoid it being replaced when autoreconf is run (or when autoheader is run directly). One way to do that is to avoid running those programs at all. You may run other autotools programs, and if you decide to avoid autoreconf then it might be worth your while to script that.

另一方面,Autoconf随附了一些内置的

On the other hand, Autoconf comes with a few built-in macros to modulate autoheader's behavior. In particular, AH_TOP and AH_BOTTOM may be useful to you for adding custom content to the automatically generated content.

另一方面,如果您要提供严格手工编写的自己的模板,并且避免autoheader弄乱它,那么先了解autoheader仅与一起使用是很有用的标头模板在您的configure.ac中命名,并且您可以命名多个模板.因此,您可以添加一个源不引用的虚拟配置标头,以便autoheader可以在不弄乱任何内容的情况下使用它:

On the third hand, if you want to provide your own template, written strictly by hand, and to avoid autoheader mucking with it, then it is useful to know that autoheader works with only the first header template named in your configure.ac, and you can name more than one. Thus, you might add a dummy configuration header that your sources do not reference, so that autoheader can play with that without messing anything up:

AC_CONFIG_HEADERS([config_dummy.h config.h])

Autotools将为其创建该虚拟配置头和模板,但是如果您的源代码从未引用它,则对构建没有影响.

The Autotools will create that dummy config header and a template for it, but if your sources never reference it then that has no effect on the build.

这篇关于config.h.in未被用作模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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