psb
psb

Reputation: 392

How to fully include another project(s) with autotools build system?

My project depends on a third-party library(-ies) in C, which itself has a working standalone autotools based build system.

I would like to have a copy of a third-party library in a source tree and compose common autotools-based build system for my project such that I can have one configure and all usual autotools strapping to do a complete one-shot build.

This system will somehow build third-party library first (using third-party's configure.ac etc, as if it was built in isolation), then compiles and links all my sources with third-party library (I'm willing to just statically link my program to third-party library and not install third-party library anywhere in a system's locations like /usr/local etc).

So I assume the following directory structure for a project:

project/
    src/
        folder_with_my_source_code/
        third-party/
            third-party-lib-1/
                src/
                Makefile.am  // native lib-1 files, prefer to keep unmodified
                configure.ac // native lib-1 files, prefer to keep unmodified
            third-party-lib-2/
                src/
                Makefile.am  // native lib-2 files, prefer to keep unmodified
                configure.ac // native lib-2 files, prefer to keep unmodified
            Makefile.am   // do I need this at all ?

        Makefile.am //this should describe how to build my files
    Makefile.am  // project's root makefile
    configure.ac // this, probably, should somehow include instructions on how to build lib-1 and lib-2 with their supplied configure.ac's ?

How can I create such chain-like dependent builds?

Upvotes: 3

Views: 437

Answers (1)

S.S. Anne
S.S. Anne

Reputation: 15566

You can use AC_CONFIG_SUBDIRS:

In most situations, calling AC_OUTPUT is sufficient to produce makefiles in subdirectories. However, configure scripts that control more than one independent package can use AC_CONFIG_SUBDIRS to run configure scripts for other packages in subdirectories.

— Macro: AC_CONFIG_SUBDIRS (dir ...)
Make AC_OUTPUT run configure in each subdirectory dir in the given blank-or-newline-separated list.

Upvotes: 3

Related Questions