Automake: building shared module which is not to be installed

让人想犯罪 __ 提交于 2019-12-05 14:10:53

I had the same problem. This is what I did, including the peeved comment to myself for future reference:

# 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)

You can use check_LTLIBRARIES which is for test targets. According to Automake's Uniform Naming Scheme:

The special prefix ‘check_’ indicates that the objects in question should not be built until the ‘make check’ command is run. Those objects are not installed either.

It also generates a static library by default. I managed to force it like this:

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

You can also compile and run a test suite executable.

check_PROGRAMS = suite

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

check-local:
    ./suite
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!