Вопрос

I'm currently working to upgrade a set of c++ binaries that each use their own set of Makefiles to something more modern based off of Autotools. However I can't figure out how to include a third party library (eg. the Oracle Instant Client) into the build/packaging process.

Is this something really simple that I've missed?

Edit to add more detail

My current build environment looks like the following:

/src
    /lib
        /libfoo
            ... source and header files
            Makefile
        /oci #Oracle Instant Client
            ... header and shared libraries
            Makefile
    /bin
        /bar
            ... source and header files
            Makefile
    Makefile
/build
    /bin
    /lib

build.sh

Today the top level build.sh does the following steps:

  1. Runs each lib's Makefile and copies the output to /build/lib
  2. Runs each binary's Makefile and copied the output to /build/bin

Each Makefile has a set of hardcoded paths to the various sibling directories. Needless to say this has become a nightmare to maintain. I have started testing out autotools but where I am stuck is figuring out the equivalent to copying /src/lib/oci/*.so to /build/lib for compile time linking and bundling into a distribution.

Это было полезно?

Решение

I figured out how to make this happen.

First I switched to a non recursive make.

Next I made the following changes to configure.am as per this page http://www.openismus.com/documents/linux/using_libraries/using_libraries

AC_ARG_WITH([oci-include-path],
    [AS_HELP_STRING([--with-oci-include-path],
        [location of the oci headers, defaults to lib/oci])],
    [OCI_CFLAGS="-$withval"],
    [OCI_CFLAGS="-Ilib/oci"])
AC_SUBST([OCI_CFLAGS])
AC_ARG_WITH([oci-lib-path],
    [AS_HELP_STRING([--with-oci-lib-path],
        [location of the oci libraries, defaults to lib/oci])],
    [OCI_LIBS="-L$withval -lclntsh -lnnz11"],
    [OCI_LIBS='-L./lib/oci -lclntsh -lnnz11'])
AC_SUBST([OCI_LIBS])

In the Makefile.am you then use the following lines (assuming a binary named foo)

foo_CPPFLAGS = $(OCI_CFLAGS)
foo_LDADD = libnavycommon.la $(OCI_LIBS)

ocidir = $(libdir)
oci_DATA = lib/oci/libclntsh.so.11.1 \
    lib/oci/libnnz11.so \
    lib/oci/libocci.so.11.1 \
    lib/oci/libociicus.so \
    lib/oci/libocijdbc11.so

Другие советы

The autotools are not a package management system, and attempting to put that type of functionality in is a bad idea. Rather than incorporating the third party library into your distribution, you should simply have the configure script check for its existence and abort if the required library is not available. The onus is on the user to satisfy the dependency. You can then release a binary package that will allow the user to use the package management system to simplify dependency resolution.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top