The cfitsio
component wraps the HEASARC FITS
library of the same name, and installs from it the library
itself, plus a few header files. Although we probably
could adapt the library's distributed autoconf script,
that script is sufficiently old, and there are
sufficiently few components installed, that it is less
trouble to simply wrap this configuration in another
one.
The cfitsio
component contains a
cfitsio/
directory containing the distributed
library source. Along with it are the usual
component.xml.in
file, copied from the
template in `starconf --show
buildsupportdata`
, and Makefile.am
and
configure.ac
files, which are too different
from the template ones for them to be helpful.
The configure.ac
looks like this:
Note that we must usednl Process this file with autoconf to produce a configure script AC_REVISION($Revision: 1.116 $) AC_INIT(cfitsio, 2.4-90, ussc@star.rl.ac.uk) AC_PREREQ(2.50) AM_INIT_AUTOMAKE(1.8.2-starlink) AC_CONFIG_SRCDIR([cfitsio.news]) STAR_DEFAULTS dnl To configure CFITSIO proper we just run ./configure in the dnl cfitsio sub-directory. Do not invoke AC_CONFIG_SUBDIRS, dnl since that prompts autoreconf to try to reconfigure that directory, and dnl automake to assume it's allowed to play there, too. ( cd cfitsio ./configure --prefix=$prefix ) dnl Find required versions of the programs we need for configuration AC_PROG_LIBTOOL AC_PROG_MAKE_SET STAR_LATEX_DOCUMENTATION(sun227) AC_CONFIG_FILES([Makefile component.xml]) AC_OUTPUT
STAR_DEFAULTS
, and we
must not use AC_CONFIG_SUBDIRS
, for the reason
described in the comments above, even though configuring
the subdirectories is exactly what we want to do. This
particular combination of commands is sufficient to
configure the cfitsio
distribution -- you might
need to do different things for other third-party
packages. That's all the configuration we need; how about
the Makefile?The Makefile.am
looks like this:
(if you look in the## Process this file with automake to produce Makefile.in dist_bin_SCRIPTS = cfitsio_link lib_LIBRARIES = cfitsio/libcfitsio.a # There are no sources for libcfits in this directory. cfitsio_libcfitsio_a_SOURCES = include_HEADERS = cfitsio/fitsio.h cfitsio/longnam.h \ cfitsio/fitsio2.h cfitsio/drvrsmem.h stardocs_DATA = @STAR_LATEX_DOCUMENTATION@ EXAMPLE_SOURCES = cfitsio/cookbook.c cfitsio/cookbook.f # Put examples in dist_pkgdata dist_pkgdata_DATA = $(EXAMPLE_SOURCES) \ cfitsio_changes.txt CFITSIO_CONDITIONS Licence.txt cfitsio.news # Headers and example sources are made within cfitsio $(include_HEADERS) $(EXAMPLE_SOURCES): (cd cfitsio; unset CFLAGS; $(MAKE)) # Must be a separate target from above, otherwise automake doesn't notice, # and adds its own, conflicting, target. cfitsio/libcfitsio.a: (cd cfitsio; unset CFLAGS; $(MAKE)) ...
cfitsio
component, you will
see that the actual Makefile.am
does a little
more than this, and is rather more copiously commented,
but these are the important parts).This uses a number of useful automake features. First of
all, the assignments which control what is installed --
the contents of the _LIBRARIES
,
_HEADERS
and (via
EXAMPLE_SOURCES
) _DATA
primaries
-- refer to files within the cfitsio/
subdirectory. When these are installed, the path to them
is stripped, so that libcfitsio.a
, for
example, ends up installed in .../lib/
and not
in .../lib/cfitsio/
, as you might possibly
intuit. This is the useful behaviour which is turned off
by the use of the nobase_
prefix, as
described in item `Automake flattens paths when it
installs things. Why?'.
Second, the presence of the lib_LIBRARIES
line means that automake expects to find some library
sources somewhere, and if it is not told where they are
with a xxx_SOURCES
variable, then it will
assume a default based on the library name. In this case,
of course, the sources are not in this directory, and we
do not wish automake to generate rules to build them, so
we have to pacify it by giving a value for the
cfitsio_libcfitsio_a_SOURCES
variable (note
the canonicalisation of the library name).
Each of the
cfitsio/
targets is built in the same way, by
switching to the cfitsio/
directory and
making `all' using that directory's own Makefile. The
only remaining wrinkle is that it turns out we have to
specify the cfitsio/libcfitsio.a
target by
itself, rather than as part of the previous compendium
target. Due, probably, to a bug, automake does not appear
to `notice' the library if it's mentioned in the
compendium target, and instead generates its own
conflicting target.