[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
non-recursive automake advice?
From: |
tom fogal |
Subject: |
non-recursive automake advice? |
Date: |
Mon, 29 Aug 2005 18:56:10 -0400 |
So I've been convinced that the effort involved in changing a build
system to not use recursive make is worth it, and I was wondering if
anyone had some good advice as to how I should go about doing this,
since my way seems to be having issues =).
I have a directory setup like the following:
/
/src/
/src/input/
/src/models/
/src/share/
/tests/
with configure.in in the /, and a Makefile.am in the root that just
recurses into /src/ and /tests/ (okay, so its not \emph{completely}
non-recursive...). Each subdirectory off of /src/ is essentially its
own self-contained module, or at least thats the hope/plan.
Basically I'd like each module to build their own libtool convenience
library, and then have /src/Makefile.am link all of those modules'
convenience libraries into one that is the union of all of them.
Without recursive make this is a little strange, but I've devised a
scheme to make each module 'feel' like it has its own, local
Makefile.am, by playing with includes.
Each module gets its own 'Inc.am'. In /src/Makefile.am, I setup
noinst_LTLIBRARIES, noinst_HEADERS, and BUILT_SOURCES. Then I include
every modules' 'Inc.am':
#### /src/Makefile.am ####
AM_CFLAGS=-I$(srcdir)/input/ -I$(srcdir)/share/ -I$(srcdir)/models/
# set variables before the includes, so include can append to the
# existing setup and not get overwritten later.
noinst_LTLIBRARIES = libAll.la libCur.la
noinst_HEADERS=jf_read.h jf_data.h bfield.h jf_bfield.h cmd_line.h
particle.h
BUILT_SOURCES=
include $(srcdir)/models/Inc.am
include $(srcdir)/share/Inc.am
include $(srcdir)/input/Inc.am
libCur_la_SOURCES = cmd_line.c consts.c bfield.c jf_bfield.c jf_read.c\
particle.c
libAll_la_LIBADD = \
$(srcdir)/models/libModels.la \
$(srcdir)/share/libShare.la \
$(srcdir)/input/libInput.la \
$(srcdir)/libCur.la
gcpt_SOURCES=main.c
bin_PROGRAMS=gcpt
gcpt_LDADD = \
libAll.la \
-ly -lfl
#### /src/Makefile.am ####
In all of the modules' 'Inc.am' files, I do some sort of
'noinst_LTLIBRARIES+=something.la' (note the plus-equals, not just
equals). This appears to work, insofar as 'autoreconf' doesn't yell at
me for doing something dumb.
Unfortunately in the 'Inc.am' files I need to remember to qualify every
filename with not just '$(srcdir)', but
'$(srcdir)/modules_directory_name/'. This is only a minor annoyance
and definitely worth the trouble, but perhaps I am missing something?
Anyway my real issue is that I just can't get the build system to find
the module-archives correctly. If I do (for example):
#### /src/models/Inc.am ####
noinst_LTLIBRARIES += $(srcdir)/models/libModels.la
libModels_la_SOURCES = ...
#### /src/models/Inc.am ####
Then automake complains that I made a typo. It sounds like its not
recognizing that 'libModels_la_SOURCES' is associated with
'$(srcdir)/models/libModels.la':
src/models/Inc.am:3: variable `libModels_la_SOURCES' is defined but no program
or
src/models/Inc.am:3: library has `libModels_la' as canonic name (possible typo)
src/Makefile.am:27: `src/models/Inc.am' included from here
However if I do NOT qualify libModels.la with '$(srcdir)/models/',
then autoreconf completes fine. Then when I go to 'make', make
complains that it doesn't know how to build libModels.la:
make[2]: Entering directory `/home/tfogal/tracer/src'
make[2]: *** No rule to make target `models/libModels.la', needed by
`libAll.la'. Stop.
make[2]: Leaving directory `/home/tfogal/tracer/src'
Which is true according to the generated 'Makefile' -- it knows how to
generate 'libModels.la', not 'models/libModels.la'.
Am I going about this completely the wrong way? Is there some software
I can look at for an example of a 'correct' way to do this?
Thanks for any help / advice you can offer. I also appreciate any
stylistic / readability / other advice beyond just "what'll make it
work".
-tom
- non-recursive automake advice?,
tom fogal <=