I tried to only add certain sources to the libimport depending on
what is really needed for the system. Unfortunately I failed to
set it up that way and even mailing several people who should
know how to solve it and posting it to some newsgroups did not
bring any results.

If you can help me, I'd be glad for a mail to <greve@gnu.org> because
it annoys me a lot that I can't get this to work. Anyway, here is the
posting I sent out with the description:


Hi !

It seems I am unable to solve the following problem - spending hours
fooling around with it and browsing all documentation I could find
didn't help, either. Some other people I asked for advice failed, as
well, so I hope there is some real "autoconf/automake" freak in here
who's capable of solving this.

I am trying to do the following:

For my program "Xlogmaster" (http://www.gnu.org/software/xlogmaster/)
I want to do proper commandline parsing (getopt_long) and the regular
REGEX stuff. Unfortunately I cannpt assume getopt.h and rx.h to be
present on every system so I need to include those functions for
systems where it is missing.

I have a directory called "import" in the source tree that contains
all the imported sources that are not really part of the Xlogmaster
distribution. In this directory I build a libimport.a that gets linked
to the xlogmaster binary at compile-time.

This library should (of course) only get compiled when needed and only
the things that are actually missing should be compiled into it.

What I am doing right now is:

- - ----- configure.in ------

import_sources=""

dnl  GNU commandline parsing in getopt.h present ?
AC_CHECK_HEADERS(getopt.h, AC_DEFINE(HAVE_GETOPT_H), 
	import_sources="getopt.c getopt1.c $import_sources")


dnl  REGEXP functions in rx.h present ?
AC_CHECK_HEADERS(rx.h, AC_DEFINE(HAVE_RX_H), 
	import_sources="rx.c $import_sources")


dnl  do we need to build and include the libimport.a ?
AM_CONDITIONAL(NEED_LIBIMPORT, test "x$import_sources" != "x" )
AC_SUBST(import_sources)

- - -------------------

- - ----- import/Makefile.am -----

if NEED_LIBIMPORT
noinst_LIBRARIES = libimport.a
libimport_a_SOURCES = @import_sources@
endif

- - -------------------

- - ----- src/Makefile.am -----

if NEED_LIBIMPORT
xlogmaster_LDADD = ../import/libimport.a
endif

- - -------------------


It *almost* works perfectly. import_sources are set perfectly and the
libimport.a gets activated properly, the linking works and the
libimport_a_SOURCES contains the proper source names.

What goes wrong is that libimport_a_OBJECTS doesn't contain the
corresponding objects and I can't set it directly, as well - automake
forbids that.

So how do I get automake to reconsider it's objects ??? I couldn't
find any reference to this in the manuals.

Oh, by the way:

Before I tried to create NEED_RX_H and NEED_GETOP_H variables and had
a SOURCEFILES variable in the Makefile.am where I appended the source
files according to what the program needs. This led to another
unsolvable problem because automake forces those conditionals to be at
the END of the Makefile (even if they stand before the other
declarations in the Makefile.am) and that means that the SOURCEFILES
variable only holds the right definition AFTER the libimport_a_ things
have been computed... another dead end.


So does anyone have the big clue that brings me back on track ?

Thanks in advance,
		Georg

- -- 
Georg C. F. Greve <greve@gnu.org>
http://porter.desy.de/~greve/ - ICQ#10016966
"People who fight may lose. People who do not
fight have already lost." -- Bertolt Brecht
