【问题标题】:Standalone, minimal configure script for portable code可移植代码的独立、最小配置脚本
【发布时间】:2015-02-20 01:00:02
【问题描述】:

我遇到了我编写的想要分发的代码的可移植性问题,但事实并非如此。我发送的 Makefile 需要进行大量编辑,然后用户才能为他们的系统编译和优化代码,这是我想避免的(显然)。我最近一直在研究 automake 和 autoconf,我已经能够成功地生成一个配置脚本来为我的系统生成 Makefile。问题是我似乎无法让它在没有安装 autoconf 或 automake 或只是不同版本的机器上工作。所以我不必把它全部放在这里,我已经能够用一个更简单的“hello world”程序复制这些结果

你好.c

#include <iostream>
using namespace std;
int main(){
  cout << "Hello World" << endl;
  return 0;
}

Makefile.am

bin_PROGRAMS=hello
hello_SOURCES=hello.c

然后我运行自动扫描。我不是特别关心这里的版本,所以我只是将configure.scan 移动到configure.ac。然后我运行自动制作。只是为了完整起见,我收到以下错误:

configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
configure.ac: that aclocal.m4 is present in the top-level directory,
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)
Makefile.am: error: required file './INSTALL' not found
Makefile.am:   'automake --add-missing' can install 'INSTALL'
Makefile.am: error: required file './NEWS' not found
Makefile.am: error: required file './README' not found
Makefile.am: error: required file './AUTHORS' not found
Makefile.am: error: required file './ChangeLog' not found
Makefile.am: error: required file './COPYING' not found
Makefile.am:   'automake --add-missing' can install 'COPYING'
configure.ac:7: error: required file 'config.h.in' not found
Makefile.am: error: required file './depcomp' not found
Makefile.am:   'automake --add-missing' can install 'depcomp'
/usr/share/automake-1.13/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL
/usr/share/automake-1.13/am/depend2.am:   The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC'
/usr/share/automake-1.13/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again
/usr/share/automake-1.13/am/depend2.am: error: AMDEP does not appear in AM_CONDITIONAL
/usr/share/automake-1.13/am/depend2.am:   The usual way to define 'AMDEP' is to add one of the compiler tests
/usr/share/automake-1.13/am/depend2.am:     AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,
/usr/share/automake-1.13/am/depend2.am:     AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC
/usr/share/automake-1.13/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again 

所以我修复了错误:

touch NEWS README AUTHORS ChangeLog
automake --add-missing
add `AM_INIT_AUTOMAKE(hello, 1.0)` to configure.ac
aclocal
autoheader
automake

然后我得到的唯一错误是 automake 不喜欢我传递给AM_INIT_AUTOMAKE 的参数数量。然后我运行autoconfconfigure。配置脚本完成它的工作并生成一个可用的生成文件。现在的问题是当我尝试将其移至其他系统时。

我可以运行配置脚本,但是当我尝试make 时出现以下错误

cd . && /bin/sh /home/dbwy/autohell/missing automake-1.13 --gnu
/home/dbwy/autohell/missing: line 81: automake-1.13: command not found
WARNING: 'automake-1.13' is missing on your system.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [Makefile.in] Error 1

所以我的问题似乎在于configure 生成的Makefile 隐式依赖于automake。根据我过去使用配置文件的经验,我知道这并不总是必需的(因为我刚刚安装了 autotools 套件来生成这个项目),所以我想知道如何做到这一点? IE。如何创建一个可以提供给任何 UNIX 类型机器的配置文件,并让他们能够在没有 automake 或 autoconf 的情况下安装它(我在 Mac 上遇到了 autoconf 问题)。我的最终目标是能够为某人提供源代码树和配置脚本,并让他们能够自定义他们使用的编译器等...

【问题讨论】:

  • 描述一下您尝试使用 autoconf 和 automake 解决的问题可能会更好,也许我们可以提出更好的解决方案?

标签: c++ makefile configure autoconf automake


【解决方案1】:

启用维护者模式时会出现此问题。 autotools 默认自动启用此模式,因此必须将AM_MAINTAINER_MODE 添加到他们的configure.ac。调用AM_MAINTAINER_MODE 会自动禁用该模式并允许在配置时将其重新打开:

./configure --enable-maintainer-mode

也可以通过将AM_MAINTATINER_MODE([enable]) 行添加到他们的configure.ac 来默认启用它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2014-11-01
    • 2010-09-08
    • 2021-07-25
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多