[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Autoconfisticating a multi-directory, non-recursive, GNU-make specif
From: |
Ralf Wildenhues |
Subject: |
Re: Autoconfisticating a multi-directory, non-recursive, GNU-make specific project |
Date: |
Thu, 16 Feb 2006 13:50:16 +0100 |
User-agent: |
Mutt/1.5.11 |
Hi Duncan,
* Duncan Gibson wrote on Thu, Feb 16, 2006 at 10:29:34AM CET:
>
> I've always struggled with auto{conf,make} in the past, but decided
> that my next project really needs to have some chance of portability.
You can use Autoconf without Automake.
> I'm aware of the famous "Recursive Make Considered Harmful" paper.
> As far as I can see from extensive searching on Google, all of the
> examples of setting up non-recursive make systems appear to rely on
> using GNU make in isolation, without auto{conf,make}
No, nonrecursive setups are quite possible with Automake. It really
helps to use a recent version (due to bugfixes), though, and you should
use the Automake option subdir-objects, to retain sanity.
> The first one that really caught my attention was:
> http://lists.gnu.org/archive/html/autoconf/2001-08/msg00011.html
> but does not provide source examples to test and verify how it works.
>
> The second one is an almost automatic system which requires only
> boilerplate sub-Makefiles and minimal editing at the top level,
> but include resolution and library linking are handled implicitly:
> http://www.mindcontrol.org/~hplus/makesample.html
I'm sorry, I've never looked at those examples (and don't have the time
to do so ATM). For a good example of a package that uses Automake and
non-recursive Makefiles look at GraphicsMagick.
> In makesample, here are two apps, app1 and app2, in two separate
> directories. app1 needs a header file from the lib1 directory, and
> app2 needs to link against a library on lib2.
>
> I'm wondering whether it is possible to autoconfisticate this *and*
> retain the non-recursive make side, but so far I can't even get a
> "standard" autoconfistication to work. So I have 3 questions that
> I hope someone will be kind enough to help me with:
>
> 1. How do I set up the lib2/lib2.a so that app2 can link with it?
>
> 2. How do I set up the include of lib1/lib1.h in app1 so that I
> can configure and make in a directory outside the source tree?
>
> 3. How can I set up a non-recursive auto{conf,make} configuration?
> [The automake "Alternate approach to subdirectories" is unclear,
> but it seems to me that automake is designed around recursion]
>
> Below you will find the results of what I have come up with so
> far after working through the tutorials at:
>
> http://vindaci.members.sonic.net/cbreak/projects/autotools/
> http://www.seul.org/docs/autotut/
> http://www-src.lip6.fr/homepages/Alexandre.Duret-Lutz/autotools.html
I only know the last tutorial (and that is good).
Here are suggestions for corrected versions of your files. Whether you
write a Makefile.am in every directory and include it from the main one,
or just put everything in the main directory right away is a matter of
taste. After having all necessary files, `autoreconf -vi' should
suffice to get you in a working state. Of course you can build outside
the source tree, just
mkdir build
cd build
../path/to/configure
make
and enjoy.
Hope that helps.
Cheers,
Ralf
--- configure.ac ---
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([makesample], [1.0], address@hidden)
AM_INIT_AUTOMAKE([1.9 subdir-objects])
AC_CONFIG_SRCDIR([app2/main.cpp])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
--- Makefile.am ---
lib_LIBRARIES =
bin_PROGRAMS =
include lib1/Makefile.am
include lib2/Makefile.am
include app1/Makefile.am
include app2/Makefile.am
--- app1/Makefile.am ---
bin_PROGRAMS += app1/app1
app1_app1_SOURCES = app1/app1.cpp
--- app2/Makefile.am ---
bin_PROGRAMS += app2/app2
app2_app2_SOURCES = app2/main.cpp
app2_app2_LDADD = lib2/lib2.a
--- lib1/Makefile.am ---
lib_LIBRARIES += lib1/lib1.a
lib1_lib1_a_SOURCES = lib1/lib1file.cpp
--- lib2/Makefile.am ---
lib_LIBRARIES += lib2/lib2.a
lib2_lib2_a_SOURCES = lib2/file-in-lib2.cpp