Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building nested Autotools Package without Installing

What I want is to build my autotools package together with a nested autotools package. It's a static library and usually this package install the lib in your $prefix/lib folder, if you type make && make install

Sub-Package-Files:

configure.ac

AC_INIT([testlib],[1.0],[[email protected]])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_PROG_CC()
AC_PROG_RANLIB()
AC_CHECK_HEADERS()
AC_LANG([C])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

Makefile.am

SUBDIRS = src

src/Makefile.am

lib_LIBRARIES = libtestlib.a
libtestlib_a_SOURCES = testlib.c
include_HEADERS = testlib.h

But I want to use it as a nested package in my autotools package and need it only for linking while build time.

So how do I achieve that my package is build & installed but the sub- / nested package is only build without modifying the configure.ac or the Makefile.am from the sub-package?

like image 732
Sebi2020 Avatar asked May 09 '26 07:05

Sebi2020


1 Answers

So how do I achieve that my package is build & installed but the sub- / nested package is only build without modifying the configure.ac or the Makefile.am from the sub-package?

Your best bet is probably to use AC_CONFIG_SUBDIRS in the top-level configure.ac to link configuration of the subpackage with the top-level package, but to avoid using SUBDIRS in the top-level Makefile.am to trigger make recursing into the subpackage. Instead of the latter, add a manual rule to the top-level Makefile.am for building the wanted library via a recursive make.

In the top-level package, that would look something like this:

configure.ac

# ...
AC_CONFIG_SUBDIRS([testlib-1.0])
# ...

Makefile.am

# ... testlib-1.0 *not* present in SUBDIRS ...

testlib-1.0/src/libtestlib.a:
    $(MAKE) -C testlib-1.0

Be sure, then, to express a proper dependency on testlib-1.0/src/libtestlib.a where needed, and to use appropriate link options at the top level.

like image 53
John Bollinger Avatar answered May 12 '26 10:05

John Bollinger