Next Up Previous Contents
Next: 6.2 Conditionally building components, I
Up: 6 Miscellaneous hints and tips
Previous: 6 Miscellaneous hints and tips
[ID index][Keyword index]

6.1 Forcing automake's choice of linking language

XXX no: there's an better mechanism, as yet undocumented. Watch this space, but don't use this technique.

When building a library or application, automake needs to make a decision about which language to use to do the final link. For example, it must use the Fortran linker to make a library which consists of or includes Fortran modules, and the C linker if it consists of pure C. This matters more on some platforms than others -- the OSX linker has some very fixed ideas on this point (it heartily disapproves of common blocks, and so needs special Fortran juju to make a library from Fortran which uses them).

Automake makes this decision based on the source code which is listed in the library's _SOURCES variable. When you are assembling a library purely from convenience libraries, however (see section `Linking static libraries' in the Libtool manual), the _SOURCES variable is empty, and automake ends up using the C linker, for want of any other information.

You can avoid this problem, and indicate to automake which langauge it should use, by giving a dummy value for the _SOURCES variable as follows:


libsubpar_adam_la_SOURCES = dummy_routine.f
libsubpar_adam_la_LIBADD = \
        subpar/libsubpar_convenience.la \
        parsecon/libparsecon_convenience.la
where the dummy_fortran.f module is a trivial Fortran routine:

C A dummy Fortran routine.  See comments in Makefile.am
      SUBROUTINE DUMMY
      END
As the comment indicates, it is wise to include an explanation of this ... let's not call it a hack ... in the Makefile.am.

This is currently used in the `pcs', `gks', `astrom' and `pgplot' components.


Next Up Previous Contents
Next: 6.2 Conditionally building components, I
Up: 6 Miscellaneous hints and tips
Previous: 6 Miscellaneous hints and tips
[ID index][Keyword index]
The Starlink Build System
Starlink System Note 78
Norman Gray, Peter W Draper, Mark B Taylor, Steven E Rankin
11 April 2005. Release snapshot: $Revision: 1.116 $. Last updated 28 May 2006