automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use BUILT_SOURCES in non-recursive, multi-directory project?


From: Duncan Gibson
Subject: How to use BUILT_SOURCES in non-recursive, multi-directory project?
Date: Sat, 4 Mar 2006 18:09:22 +0100 (CET)
User-agent: SquirrelMail/1.4.5

I've been trying to set up a multi-directory project using non-recursive
auto{conf,make} to build an FLTK application (see http://www.fltk.org).
I have created a simple example for testing, where I have a sub-directory
containing foo.fl and foo_test.cxx, and what I need to do is:

    use 'fluid -c foo.fl' to create foo.h and foo.cxx
    create libfoo.a from foo.cxx
    compile foo_test.cxx and link against libfoo.a

A long time ago I asked 'How to specify 2 stage build in Makefile.am'
(see http://lists.gnu.org/archive/html/automake/2002-10/msg00068.html)
that gave me some idea on how to call 'fluid'.

More recently, I had a thread 'Autoconfisticating a multi-directory,
non-recursive, GNU-make specific project' and I thought that I had all
that I needed to set up the auto{conf,make} framework for my project.
(see http://lists.gnu.org/archive/html/automake/2006-02/msg00036.html)

However, it's taken me several evenings of experimentation, not to
mention frustration, to try to marry the BUILT_SOURCES needed for the
two stage build with the non-recursive auto{conf,make} configuration,
and also be able to run 'configure' and 'make' in a new directory
outside the source tree. What I currently have is:

The configure.ac looks like:

    AC_PREREQ(2.59)
    AC_INIT([foo], [0.0.1], address@hidden)
    AM_INIT_AUTOMAKE([1.9 foreign subdir-objects])
    AC_CONFIG_SRCDIR([src/foo_test.cxx])
    AC_CONFIG_HEADER([config.h])

    AC_PROG_CC
    AC_PROC_CXX
    AC_PROG_RANLIB

    AC_CONFIG_FILES([Makefile])
    AC_OUTPUT

The top level Makefile.am looks like:

    bin_PROGRAMS =
    lib_LIBRARIES =
    noinst_LIBRARIES =
    BUILT_SOURCES =

    # in my file these variables have been expanded, but anyway will
    # be handled differently via autoconf once everything works
    FLTK_CXXFLAGS = `fltk-config --cxxflags`
    FLTK_LIBRARYS = `fltk-config --libs`
    FLTK_LDSFLAGS = `fltk-config --ldstaticflags`

    include src/Makefile.am

The src/Makefile.am looks like:

    bin_PROGRAMS += src/foo_test
    noinst_LIBRARIES += src/libfoo.a

    AM_CPPFLAGS = -I$(srcdir)/src -I$(top_builddir)/src $(FLTK_CXXFLAGS)

    .fl.h:
            d=`dirname address@hidden ; \
            f=`basename $@ .h`.fl ; \
            cp $< $(top_builddir)/$$d/$$f ; \
            cd $(top_builddir)/$$d ; \
            fluid -c $$f

    BUILT_SOURCES += src/foo.h

    nodist_src_libfoo_a_SOURCES = src/foo.cxx

    src_foo_test_LDADD = src/libfoo.a $(FLTK_LIBRARYS)
    src_foo_test_LDFLAGS = $(FLTK_LDSFLAGS)
    src_foo_test_SOURCES = src/foo_test.cxx

After a lot of trial and error, the src/Makefile.am *appears* to work,
but I'm concerned about the filename manipulations in the .fl.h rule,
the lack of checking so that I don't zap things if building in $(srcdir),
AM_CPPFLAGS needing both $(srcdir) and $(top_builddir), the fact that
src/foo.fl doesn't appear anywhere, and how to tidy up.

Am I really going about this in the best way?

Cheers
Duncan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]