And*_*dna 2 autoconf makefile autotools
我正在尝试学习GNU autotools,我正在学习一些教程,我尝试一步一步地从:
http://kern-81.homepage.t-online.de/autotools_tutorial.pdf
但我有一个问题,在第8页有手动编写的Makefile.in和一行:
BINDIR=@bindir@
Run Code Online (Sandbox Code Playgroud)
后
autoconf
./configure
Run Code Online (Sandbox Code Playgroud)
在我生成的makefile中,我得到了
BINDIR=${exec_prefix}/bin
Run Code Online (Sandbox Code Playgroud)
但是当我这样做的时候
@echo $(exec_prefix)
Run Code Online (Sandbox Code Playgroud)
似乎这个变量是空的,所以我想做的一切
make install
Run Code Online (Sandbox Code Playgroud)
会去/ bin,这有点奇怪,为什么它没有设置为/ usr/bin,我应该向autoconf发出一些参数吗?
同样在这个.pdf文件中写道:
bindir is an output variable of AC INIT which also detects includedir, srcdir, libdir, and others.
Run Code Online (Sandbox Code Playgroud)
是真的吗?因为在这个autoconf.am的例子中它是:
AC_INIT(helloworld, 0.0.1, dev@helloworld.org)
Run Code Online (Sandbox Code Playgroud)
所以这个简单的宏做了所有这些?如果有,怎么样?
是的,AC_INIT所有这些;-)你可以通过/usr/share/autoconf/autoconf/general.m4查看如何AC_INIT定义它的子程序来判断它是如何做到的.或者,configure.ac除了AC_INIT调用之外,只需将其设置为空,然后查看生成的配置脚本以查看它扩展到的内容.
我认为如果exec_prefix没有设置,它默认为prefix,所以二进制文件仍然会进入/usr/local/bin.当然,您可以通过运行make install和检查二进制文件的位置来验证这一点.