Hi,
I'm currently developing a C program and doing my best to bring the
power of GNU automake to bear on the build process. I'm now at the
stage where I can use automake fairly effectively, and consulting the
manual usually clears up any confusion I may have.
However, with this particular project, I've run into a problem that I
can't quite work out how to solve in an elegant fashion.
The problem is with a couple of source files that need to be compiled
only under certain circumstances.
I currently have a Makefile.am consisting of the following:
bin_PROGRAMS = qrcs
qrcs_SOURCES = qrcs.c qrcs.h
EXTRA_qrcs_SOURCES = ext2fs.c ext2fs.h
man_MANS = qrcs.1
EXTRA_DIST = $(man_MANS) qrcs.spec qrcs.lsm
The automake manual recommends assigning source files that are only
conditionally part of the build process to EXTRA_qrcs_SOURCES instead
of qrcs_SOURCES, so that is what I have done.
The problem comes in not knowing how to inform the build process when
it should build the EXTRA_qrcs_SOURCES files.
My configure.in checks for the existence of linux/ext2_fs.h and, if it
is found, defines HAVE_LINUX_EXT2_FS_H. That's the easy part.
When this symbol is defined, I want to compile the ext2fs.o object and
link it to the main one, qrcs.o, to form the qrcs binary.
I have solved the problem temporarily by removing the
EXTRA_qrcs_SOURCES line and adding ext2fs.c and ext2fs.h to
qrcs_SOURCES.
Of course, to make this work on non-Linux systems, I've had to edit
ext2fs.c and employ the kludge of enclosing the whole file in an
#ifdef HAVE_LINUX_EXT2_FS_H clause, which then produces a compile time
warning about ANSI C forbidding empty source files, which in turn
requires its own kludge to circumvent.
What I thus need is a way of informing the build process to build and
link EXTRA_qrcs_SOURCES only when the header file in question has been
found, but I can't work out what to put in Makefile.am to achieve
this.
The automake manual doesn't seem to provide the solution either, even
though the subject of conditional compilation *is* touched upon. Maybe
I'm barking up the wrong tree altogether.
Anyway, any help you can offer would be much appreciated.
Ian
--
Ian Macdonald | Q: What do you call 15 blondes in a circle?
Red Hat Certified Engineer | A: A dope ring. Q: Why do blondes put
http://www.caliban.org/ | their hair in ponytails? A: To cover up the
Linux 2.2.13 on an i686 | valve stem.
|