如何使用GNU Autotools配置源文件目录和安装位置 [英] How to configure the source file directory and install location using GNU Autotools

查看:141
本文介绍了如何使用GNU Autotools配置源文件目录和安装位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个这样的项目目录:

I want a project directory like this:

app/
 |
  src/
  Makefile 

所有.cpp和.hpp,.h文件都位于src子目录中.如何配置Makefile.amconfigure.ac以使用目录/src作为源目录,让生成的Makefile?以及如何让生成的可执行文件进入指定的目录,例如/usr/opt?

All of the .cpp and .hpp, .h files are in the src subdirectory. How can I configure Makefile.am or configure.ac to let the generated Makefile using the directory /src as the source directory? And how to let the generated executable into a specified directory like /usr/opt?

另一个问题是,如果我想将程序制作为.so库,如何实现将其安装到/usr/lib/usr/local/lib的目标?以及如何使头文件变成/usr/local/include/app?

Another question is that If I want to make my program as a .so library, how to achieve my goal to make it install into /usr/lib or /usr/local/lib? And how to make the header files into like /usr/local/include/app?

推荐答案

通常,您只需添加


SUBDIRS = src

到顶层Makefile.am,并在AC_CONFIG_FILES中提到src/Makefile.关于递归make有一些合理的抱怨,但是如果您所有的源都在src中,则make中的单个递归级别并不是真正的问题.在配置时设置前缀时,由用户将可执行文件放入/usr/opt中,并且在构建软件包时不应该考虑.要生成可执行文件,请在Makefile.am中使用bin_PROGRAMS,并要生成库,则应使用lib_LIBRARIES或lib_LTLIBRARIES(就我个人而言,我倾向于使用libtool并与后者一起使用.)

to the toplevel Makefile.am, and mention src/Makefile in AC_CONFIG_FILES. There are some reasonable complaints about recursive make, but if all of your source is in src then the single level of recursion in make is not really an issue. Putting the executable in /usr/opt is done by the user when setting prefix at configure time, and should not be a consideration when building the package. To build an executable, use bin_PROGRAMS in the Makefile.am, and to build a library you should use either lib_LIBRARIES or lib_LTLIBRARIES (personally, I tend to use libtool and go with the latter.)

我认为您有关在/usr/lib或/usr/opt中安装的问题表明存在根本的误解.在构建软件包时,您绝对不会在乎.作为软件包维护者,您指示该程序应安装在$(prefix)/bin(或$ exec_prefix/bin或$ bindir)中,并且库应位于$ libdir中,但用户应确定$ prefix和$ libdir和$ bindir在运行configure时. (通常,人们只是设置前缀,bindir的默认值为$ prefix/bin,而libdir的默认值为$ prefix/lib.)

I think your questions about installing in /usr/lib or in /usr/opt indicate a fundamental misunderstanding. When building the package, you absolutely do not care about that. As the package maintainer, you indicate that the program should be installed in $(prefix)/bin (or $exec_prefix/bin, or $bindir) and that libraries should be in $libdir, but the user determines the location of $prefix and $libdir and $bindir when they run configure. (Usually, people just set prefix, and bindir defaults to $prefix/bin while libdir defaults to $prefix/lib.)

这篇关于如何使用GNU Autotools配置源文件目录和安装位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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