Automake:构建不安装的共享模块

时间:2011-11-26 09:28:00

标签: automake libtool

如何告诉Automake构建一个不安装的动态模块?

pkglib_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = -no-undefined -module -avoid-version

导致mywrapper.so安装到pkglibdir

noinst_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = -no-undefined -module -avoid-version

导致构建 static 便利库。

有问题的动态模块仅用于运行测试套件,因此不会被分发。

2 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。这就是我所做的,包括对自己的愤怒评论以供将来参考:

# The rpath is necessary because stoopid libtool won't build a shared library
# if it's noinst_, because what POSSIBLE reason could you have to do that?
TEST_PLUGIN_LIBTOOL_FLAGS = \
    -module \
    -shared \
    -avoid-version \
    -export-symbols-regex "<whatever symbols you need to export>" \
    -rpath $(abs_builddir)

noinst_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = $(TEST_PLUGIN_LIBTOOL_FLAGS)

答案 1 :(得分:1)

您可以使用check_LTLIBRARIES作为测试目标。根据Automake的Uniform Naming Scheme

  

特殊前缀'check_'表示有问题的对象   不应该在运行'make check'命令之前构建。那些   也没有安装对象。

默认情况下,它还会生成静态库。我设法强迫它这样:

check_LTLIBRARIES = mywrapper.la
mywrapper_la_LDFLAGS = -no-undefined -module -shared -avoid-version -rpath /tmp

您还可以编译并运行测试套件可执行文件。

check_PROGRAMS = suite

suite_SOURCES = ...
suite_LDFLAGS = ...
suite_LDADD = ...

check-local:
    ./suite