15.6 Linksets

If you want to use linksets in your packages, you must also define the LINKSET target property in the makefile. This tells the release tools not to use the simple-minded defaults, but to use the linkset definitions instead. However, it may be difficult to start using linksets in individual packages--they tend to propagate very quickly throughout the software project. Therefore, it is probably best to decide to go for the linksets as a whole or not at all. At the very minimum the decision has to start from the lowest-level packages and then propagate along the package use relationships. It is not possible for a higher-level package to use linksets if the packages it depends on do not.

The value of the LINKSET property should be one of the linkset names defined in the PACKAGE file. By using the package name[1] you can get the default linkset. When the property has been set you should no longer define the LIBS property, except possibly to name libraries that are created in the same makefile.[2] The release tools will resolve the libraries based on linkset relationships and sort them by dependency order. The sorting will fail if circular dependencies are found among libraries--you will see an error message describing the cycle and the target will not get any libraries at all. This should usually be enough to make the linker fail completely and you can try to analyse the situation.

Here is an example of a simple PACKAGE file that defines the linksets for an imaginary package example. The logic is that the package builds two programs: a simple one and a fancier one that uses plenty of graphics. Notice how it gets makefile uses c++ and CLHEP as pseudo-packages.

title      Example Package
author     Lassi A. Tuura <lat@iki.fi>
version    example-01-01-13:19980819080003

includedir -none

use        HelloWorld   01-02 Examples
use        c++

linkset
use        CLHEP

linkset    fancy
use        OpenGLScene  01    Graphics/Scenes

Now for the makefile that builds the libraries

TARGET_BINS    = ex oglex

ex_LINKSET     = example
ex_CXXCPPFLAGS = -I$(srcdir)
ex_SRC         = ex.cxx

oglex_LINKSET  = fancy
oglex_SRC      = oglex.cxx

######################################################################
include $(SRT_HOME)/standard.mk

Briefly, the PACKAGE file defines two linksets, the default example one and fancy. Both use the package HelloWorld (presumably getting a library from it) and c++ because they compile C++ source files. This is implied because these uses come before any linkset definitions (remember, there is an implicit linkset -all in the beginning of the file). The fancy part also uses OpenGL. On the makefile side we just refer to the linksets and define other properties as usual. We do not need to define any makefile uses because they all came from the PACKAGE file.

Notes

[1]

Only the last name part, not the leading directories.

[2]

If you do not dynamically configure your linksets, you will need to name the libraries from the same makefile. Otherwise the release tools will not know the ordering dependencies. However, if you use linkset -frag option and tell the release tools how the linksets in your package depend on each other via the needs variables, you do not need to define the LIBS property. You will still need to define the dependencies though--otherwise make might try to build targets in incorrect order.