自定义 .m4 宏不适用于 configure.ac

Posted

技术标签:

【中文标题】自定义 .m4 宏不适用于 configure.ac【英文标题】:Custom .m4 macro not working with configure.ac 【发布时间】:2013-07-28 18:35:52 【问题描述】:

我正在尝试将一个神秘的科学 F77 程序更新到现代世界,使其更易于安装 w/.configure 脚本。然而,事实证明,这比宣传的要困难得多。我将踢腿和尖叫拖入 21 世纪的程序需要 SuperMongo 绘图库,我试图弄清楚如何让 Automake 为必要的 SuperMongo 库(libplotsub.a、libdevices.a 和libutils.a) 我创建了一个骨架 github 存储库 (https://github.com/Acetylene5/autoconf_testing),而不是让您好心的人查看代码的内容。

主程序是test.f,调用junk.f文件。这两个文件都包含 Stuff.com 通用块。文件 junk.f 调用了两个函数:一个(dcopy)来自 LAPACK 库,另一个(drawcurs)来自 SuperMongo 程序。我这样做的原因是因为我快进出石器时代的这个程序同时使用了这两个库。

我在互联网上发现了一个 LAPACK 宏 (ax_lapack.m4),它似乎可以在我的系统上找到 LAPACK 库。我试图将此 .m4 文件复制到 ax_supermongo.m4,并更改必要的名称和目录。但是,我不是 M4 专家,所以我不知道这是否符合我的要求。我不认为是,因为如果您查看 ./configure 的输出,它似乎没有找到 sm_graphics 文件(ax_supermongo.m4 使用的令牌 supermongo 例程到 SM 库的位置):

deen@aida44170:~/Code/FORTRAN/testing/autoconf/master> autoreconf -i
deen@aida44170:~/Code/FORTRAN/testing/autoconf/master> ./configure
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether the Fortran 77 compiler works... yes
checking for Fortran 77 compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU Fortran 77 compiler... no
checking whether /usr/local2/misc/iraf/iraf/unix/hlib/f77.sh accepts -g... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... none
checking for sgemm_... no
checking for ATL_xerbla in -latlas... no
checking for sgemm_ in -lblas... yes
checking for dgemm_ in -ldgemm... no
checking for sgemm_ in -lmkl... no
checking for sgemm_... (cached) no
checking for sgemm_ in -lcxml... no
checking for sgemm_ in -ldxml... no
checking for sgemm_ in -lscs... no
checking for sgemm_ in -lcomplib.sgimath... no
checking for sgemm_ in -lblas... (cached) yes
checking for sgemm_ in -lessl... no
checking for sgemm_ in -lblas... (cached) yes
checking build system type... x86_64-suse-linux-gnu
checking host system type... x86_64-suse-linux-gnu
checking how to get verbose linking output from /usr/local2/misc/iraf/iraf/unix/hlib/f77.sh... configure: WARNING: cannot determine how to obtain linking information from /usr/local2/misc/iraf/iraf/unix/hlib/f77.sh

checking for Fortran 77 libraries of /usr/local2/misc/iraf/iraf/unix/hlib/f77.sh... 
checking for dummy main to link with Fortran 77 libraries... none
checking for Fortran 77 name-mangling scheme... lower case, underscore, extra underscore
checking for cheev_... no
checking for cheev_ in -llapack... yes
checking for sm_graphics__... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands

在我的系统上,Supermongo 库位于:/usr/local/misc/sm/sm2_4_36/lib/

关于如何让 autoconf 查看此目录或可能使用命令行变量在此处传递目录的任何建议?

如果您需要更多信息,请告诉我。

凯西

【问题讨论】:

如果这是 Linux/HPUX-11/Solaris/AIX 系统,请尝试将 LD_LIBRARY_PATH 设置为指向您的库目录。大概它是一个.so或.sl。它可能已经有值,所以只需添加它。 始终使用标签fortran 并且仅在必要时添加版本以区分您的问题是具体的。例如,您不能使用 Fortran 2008,而只能使用 Fortran 90。 【参考方案1】:

autoconf 不会尝试为您查找库,但它生成的 configure 脚本会。如果您希望configure 脚本在/usr/local/misc/sm/sm2_4_36/lib/ 中查找,那么您使用的机制将取决于您的系统,但很常见的是为配置脚本提供LDFLAGS=-L/usr/local/misc/sm/sm2_4_36/lib/ 形式的参数。您可能还必须在CPPFLAGS 中添加类似的-I 子句才能找到头文件。

【讨论】:

以上是关于自定义 .m4 宏不适用于 configure.ac的主要内容,如果未能解决你的问题,请参考以下文章

Word VBA - 通过样式应用备用字体颜色不适用于已应用直接格式(字体颜色)的文本

m4--宏处理器

宏编程是啥?

异常不适用于 arm cortex m4 的 clang 和 cmake 交叉编译,并生成“got”部分

m4是国内的啥码

autoreconf -fi 错误:可能未定义宏:AC_DEFINE 如果此令牌和其他令牌是合法的,请使用 m4_pattern_allow