Changes between Version 10 and Version 11 of pm-switch


Ignore:
Timestamp:
Dec 4, 2010 10:41:17 AM (9 years ago)
Author:
stefan
Comment:

update w.r.t. addlibs file and binary dependencies; other small fixes

Legend:

Unmodified
Added
Removed
Modified
  • pm-switch

    v10 v11  
    8989   * The second argument are the names the pkg-config files associated with the projects that make up the package, with the optional ability to specify specific required versions (see example below).
    9090   * The third argument can be used to specify a particular library or binary to which the particular dependency applies. This is for cases where the project exports both a library and a binary executable and these have different dependencies. In this case, different command lines are built up for each of them separately.
    91    * An example of how this comes together is the call {{{AC_COIN_CHECK_PACKAGE(CoinDepend, [coinutils = trunk osi = trunk alps = trunk], [DipLib])}}}, which defines a package called {{{CoinDepend}}} that consists of the trunk versions of !CoinUtils, Osi, and Alps. The dependency applies to the Dip library. We'll see below how this specification comes to play in the Makefiles.
     91   * An example of how this comes together is the call {{{AC_COIN_CHECK_PACKAGE(CoinDepend, [coinutils >= 2.7 osi >= 0.104 alps >= 1.2], [DipLib])}}}, which defines a package called {{{CoinDepend}}} that consists of the trunk versions of !CoinUtils, Osi, and Alps. The dependency applies to the Dip library. We'll see below how this specification comes to play in the Makefiles.
    9292 1. Calls to the function {{{AC_COIN_HAS_USER_LIBRARY()}}} can generally be replaced with calls to {{{AC_COIN_CHECK_PACKAGE()}}} if they apply to solvers to be used through Osi. This is because the {{{OsiYyy}}} packages now have pkg-config support. So the call to check for the presence of CPLEX, for example, is now {{{AC_COIN_CHECK_PACKAGE(Cpx,  [osi-cplex],  [DipLib])}}}.
    9393  Other uses of the macros {{{AC_COIN_HAS_USER_LIBRARY}}} should be renamed to {{{AC_COIN_CHECK_USER_LIBRARY}}}.
     
    9696== {{{Root/Xxx/Makefile.am}}} ==
    9797
    98 The main change here is that we are now replacing the old {{{xxx_addlibs.txt}}} file with {{{xxx.pc}}} and {{{xxx-uninstalled.pc}}} files (see below). If the pkg-config command is present, an addlibs file can be created in the old style from the {{{.pc}}} files. So we have the following changes:
     98The main change here is that we are now replacing the old {{{xxx_addlibs.txt}}} file with {{{xxx.pc}}} and {{{xxx-uninstalled.pc}}} files (see below).[[BR]]
     99If the pkg-config command is present, an addlibs file can be created in from the {{{.pc}}} files.[[BR]]
     100If the pkg-config command is not present, then the AC_COIN_CHECK_PACKAGE macro in configure has setup variables that contain the flags for linking against installed dependency libraries.
     101This variable can then be used to setup the addlibs file.[[BR]]
     102So we have the following changes:
    99103{{{
    100104addlibsfile = xxx_addlibs.txt
     
    116120should be replaced with
    117121{{{
    118 if COIN_HAS_PKGCONFIG
    119122addlibsdir = $(DESTDIR)$(datadir)/coin/doc/Xxx
    120123
    121124install-data-hook:
    122125       @$(mkdir_p) "$(addlibsdir)"
     126if COIN_HAS_PKGCONFIG
    123127       PKG_CONFIG_PATH=@COIN_PKG_CONFIG_PATH@ \
    124        $(PKG_CONFIG) --libs xxx > $(addlibsdir)/xxx_addlibs.txt
     128       $(PKG_CONFIG) --libs xxx > $(addlibsdir)/xxx_addlibs.txt
     129else
     130       echo -L@abs_lib_dir@ -lxxx @XXXLIB_LIBS_INSTALLED@ > $(addlibsdir)/xxx_addlibs.txt
     131endif
    125132
    126133uninstall-hook:
    127134        rm -f $(addlibsdir)/xxx_addlibs.txt
    128 endif
    129135}}}
    130136
     
    148154== {{{Root/Xxx/xxx-uninstalled.pc.in}}}==
    149155
    150 This the pkg-config file for finding uninstalled versions of a given library built from source. It's almost identical to the above with just a few path differences.
    151 
    152 Also it is important to note that no .pc file variables should be used in the Libs and Cflags arguments, e.g., ${libdir} or ${includedir} as in the xxx.pc.in file.
    153 The reason is that in the case that pkg-config is not installed on a system, configure parses the xxx-uninstalled.pc.in files itself, and this parsing code does not support variables in .pc files.
     156This the pkg-config file for finding uninstalled versions of a given library built from source.
     157In difference to above, we use here path's in the build directory.
     158Further, instead of specifying linker flags via -L and -l, we list here the .la file with full path explicitly.
     159This is necessary to setup the DEPENDENCIES variable in the Makefile's that use project Xxx.
    154160{{{
    155161prefix=@prefix@
     162libdir=@ABSBUILDDIR@/src
     163includedir=@includedir@/coin
    156164
    157165Name: Xxx
    158166Description: Xxx does nothing useful
    159167Version: @PACKAGE_VERSION@
    160 Libs: -L@ABSBUILDDIR@/src -lXxx @XXXLIB_PCLIBS@
     168Libs: ${libdir}/libXxx.la @XXXLIB_PCLIBS@
    161169Cflags: -I@abs_source_dir@/src -I@ABSBUILDDIR@/inc
    162170Requires: @XXXLIB_PCREQUIRES@
     
    165173== {{{Root/Xxx/src/Makefile.am}}} ==
    166174
    167 The main difference in the construction of the various {{{Makefile.am}}} files is that not so much work has to be done now to build up the command lines and lists of dependent libraries. This is all done automatically. For each package Yyy defined in {{{configure.ac}}}, there are now two variables: {{{YYY_CFLAGS}}} and {{{YYY_LIBS}}} that hold the command line for compiling individual C and C++ files (i.e., the include paths, etc.) and the link line for linking to dependent libraries, respectively. The situation will be slightly different for each project, but for the most part, we can replace blocks like
     175The main difference in the construction of the various {{{Makefile.am}}} files is that not so much work has to be done now to build up the command lines and lists of dependent libraries. This is all done automatically. For each package Yyy defined in {{{configure.ac}}}, there are now four variables: {{{YYY_CFLAGS}}}, {{{YYY_LIBS}}}, {{{YYY_DEPENDENCIES}}}, and {{{YYY_DATA}}} that hold the flags for compiling individual C and C++ files (i.e., the include paths, etc.), the linker flags for linking to dependent libraries, a list of dependent libraries (not using -l or -L syntax), and the directory where a project may store data, respectively. The situation will be slightly different for each project, but for the most part, we can replace blocks like
    168176{{{
    169177AM_CPPFLAGS = \
     
    175183        -I`$(CYGPATH_W) $(OSISRCDIR)/src/OsiClp`   \
    176184        -I`$(CYGPATH_W) $(CLPOBJDIR)/inc`
    177 LDADD = $(COINUTILSOBJDIR)/src/libCoinUtils.la    \
     185myprog_LDADD = $(COINUTILSOBJDIR)/src/libCoinUtils.la    \
    178186        $(OSIOBJDIR)/src/libOsi.la    \
    179187        $(OSIOBJDIR)/src/OsiClp/libOsiClp.la    \
     
    183191{{{
    184192AM_CPPFLAGS = $(COINDEPEND_CFLAGS)
    185 LDADD = $(COINDEPEND_LIBS)
    186 }}}
    187 Note that the names of the variables correspond exactly to the names given to the libraries and binaries in the third argument {{{AC_COIN_HAS_PACKAGE()}}}, as described in the section on the {{{Root/Xxx/configure.ac}}} file above. Hence, the command {{{AC_COIN_HAS_PACKAGE(CoinDepend, [coinutils = trunk osi = trunk alps = trunk], [XxxLib])}}} will result in the libraries and flags for each of those dependencies being put into variables called {{{XXXLIB_LIBS}}} and {{{XXXLIB_CFLAGS}}} respectively.
    188 
    189 Further, there is no longer any need to use the {{{ADDLIBS}}} variable at all (it is not even defined), as the additional libraries are all included as dependencies when the lists of libraries are built up.
     193myprog_LDADD = $(COINDEPEND_LIBS)
     194myprog_DEPENDENCIES = $(COINDEPEND_DEPENDENCIES)
     195}}}
     196Note that the names of the variables correspond exactly to the names given to the libraries and binaries in the third argument {{{AC_COIN_CHECK_PACKAGE()}}}, as described in the section on the {{{Root/Xxx/configure.ac}}} file above. Hence, the command {{{AC_COIN_CHECK_PACKAGE(CoinDepend, [coinutils >= 2.7 osi >= 0.104 alps >= 1.2], [XxxLib])}}} will result in the libraries and flags for each of those dependencies being put into variables called {{{XXXLIB_LIBS}}} and {{{XXXLIB_CFLAGS}}} respectively.
     197
     198Further, there is no longer any need to use the {{{ADDLIBS}}} variable at all (it will soon not even be defined), as the additional libraries are all included as dependencies when the lists of libraries are built up.
    190199
    191200When building libraries, note that the location of installed libraries has changed from {{{${libdir}}}} to {{{${libdir}/coin}}}.