在自动工具项目中包含(仅标头)库
我想在我的 Autotools 项目中集成一个仅包含头文件的 C++ 库。由于该库使用 Autoconf 和 Automake,因此我使用 AC_CONFIG_SUBDIRS
在 configure.ac
中,并将库目录添加到 Makefile.am
中的 SUBDIRS =
行。
我的问题是:如何防止 make install
安装头库?我正在构建一个二进制文件,因此我的用户不需要这些标头。
我不想篡改库,因此我可以通过解压新版本来获取升级。
I want to integrate a header-only C++ library in my Autotools project. Since the library uses Autoconf and Automake, I use AC_CONFIG_SUBDIRS
in configure.ac
and added the library dir to the SUBDIRS =
line in Makefile.am
.
My question is: how do I prevent the header library from being installed by make install
? I'm building a single binary, so my users don't need these headers.
I'd prefer not to tamper with the library, so I can fetch upgrade by just untarring the new version.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个想法。
将所有您不想安装的第三方库移至名为
noinst/
的子目录中。例如,如果您想将项目与 Boost 一起发布,请将其解压到目录noinst/boost/
中。使用AC_CONFIG_SUBDIRS([noinst/boost])
。在noinst/Makefile.am
中,执行如下操作:效果是,每当从顶级目录运行某些递归“make install*”或“make uninstall”命令时,递归将停在
noinst/
处并且不访问其子目录。其他递归命令(如“make”、“make clean”或“make dist”)仍将递归到子目录中。您当然可以直接将
install:
等覆盖到第三方包中,并避免额外的noinst/
目录。但如果您像我一样,您不想篡改第三方软件包以简化其更新。上述设置的一个很好的特性是,如果有人进入
noinst/boost/
并决定运行make install
,它就会起作用。当他们安装您的软件包时,默认情况下不会发生这种情况。Here is an idea.
Move all the third-party libraries you do not want to see installed into a subdirectory called
noinst/
. So for instance if you want to ship your project with something like Boost, unpack it into the directorynoinst/boost/
. UseAC_CONFIG_SUBDIRS([noinst/boost])
. Insidenoinst/Makefile.am
, do something like this:The effect is that whenever some of the recursive "make install*" or "make uninstall" commands are run from the top-level directory, the recursion will stop in
noinst/
and not visit its subdirectories. Other recursive commands (like "make", "make clean" or "make dist") will still recurse into the subdirectories.You could of course override
install:
and friends directly into the third-party package, and avoid the extranoinst/
directory. But if you are like me, you don't want to tamper with third-party packages to ease their update.Also a nice property of the above setup is that if someone goes into
noinst/boost/
and decide to runmake install
, it will work. It just does not occur by default when they install your package.刚刚遇到类似的问题,并在automake手册:
Andreas
just came across a similar problem and found the solution in the automake manual:
Andreas
那么就不要使用
SUBDIRS
。以下 hack 可能会起作用:当然,如果该库保留在项目之外的自己的目录中,并且您只需通过 CFLAGS/LIBS 标志指向它,那将是最好的。
Don't use
SUBDIRS
then. The following hack may work:Of course it would be best if the library remained in its own directory outside of your project, and you just point to it via CFLAGS/LIBS flags.