Changes between Version 3 and Version 4 of pm-source-make


Ignore:
Timestamp:
Jun 2, 2006 9:44:05 PM (14 years ago)
Author:
andreasw
Comment:

cleaned up

Legend:

Unmodified
Added
Removed
Modified
  • pm-source-make

    v3 v4  
    33The source code directories are usually the {{{src}}} directories in a project's subdirectory, or subdirectories under {{{src}}}.
    44
    5 The Makefiles in those directories take care of the fun stuff.  They define, what is to be built (libraries, executables), how it is built, and where (and if) the product is to be installed.
     5The Makefiles in those directories take care of the fun stuff.  They define what is to be built (libraries, executables), how it is built, and where (and if) the products are to be installed.
    66
    77-----------------------------
     
    3939 * In the above example, we use the Automake prefix '''lib_''' to tell Automake, that we want this library '''to be installed in the lib installation directory'''.  As Automake primary we use '''LTLIBRARIES''' (as opposed to {{{LIBRARIES}}}) to tell Autoconf, that we want to use Libtool.
    4040
    41  * If we want to build a library that is not going to be installed, we use the '''noinst_''' prefix.  For example, we might have the source code for the final library distributed into different directories, but in the end we only want to install one library that containts everything.  In this case, we need '''to create auxilliary libraries''' in each source code directory (except for one), that are later collected into a single one.  The auxilliary libraries should not be installed.
     41 * If we want to build a library that is not going to be installed, we use the '''noinst_''' prefix.  For example, we might have the source code for the final library distributed into different directories, but in the end we only want to install one library that containts everything.  In this case, we need '''to create auxilliary libraries''' in each source code directory (except for one), that are later collected into a single library.  The auxilliary libraries should not be installed.
    4242
    4343 The corresponding line in the {{{Makefile.am}}} file for an auxilliary library then looks like:
     
    8787}}}
    8888
    89  * If you distribute the source code for a library into several directories, you will have to tell Automake, which libraries should be included in the final library that is going to be installed.  In the above example, taken from the DyLP project, the final library to be installed is {{{libDylp}}} (with the approprate extension, such as "{{{.a}}}").  In the {{{Makefile.am}}} for this library you would find those lines.  The '''LIBADD''' primary tells Autoconf, that the objects from the specified lLbtool libraries should be included in the final library.
     89 * If you distribute the source code for a library into several directories, you will have to tell Automake, which libraries should be included in the final library that is going to be installed.  In the above example, taken from the DyLP project, the final library to be installed is {{{libDylp}}} (with the approprate extension, such as "{{{.a}}}").  In the {{{Makefile.am}}} for this library you would find those lines.  The '''LIBADD''' primary tells Autoconf, that the objects from the specified Libtool libraries should be included in the final library.
    9090
    9191---------------------------------
     
    101101}}}
    102102
    103  * First we tell Automake the '''name of the executable''' that we want to create.  Usually, we want those to be installed in the {{{bin}}} installation directory, as indicated by the '''bin_''' prefix.  However, the unit test program is usually not installed, in which case one uses the '''noinst_''' prefix.
     103 * First we tell Automake the '''name of the executable''' that we want to create (skip the "{{{.exe}}}" extension even if you are working under Windows).  Usually, we want programs to be installed in the {{{bin}}} installation directory, as indicated by the '''bin_''' prefix.  However, the unit test program is usually not installed, in which case one uses the '''noinst_''' prefix.
    104104
    105105=== Source Files for the Executable ===
     
    115115}}}
    116116
    117  * Just as for libraries, one lists all source files, includin headers, in a variable, which has the '''program name as prefix''', and uses the '''SOURCES''' primary.
     117 * Just as for libraries, one lists all source files, including headers, in a variable, which has the '''program name as prefix''', and uses the '''SOURCES''' primary.
    118118
    119119=== Specifying Linking Flags ===
     
    139139 * Note:
    140140   * The '''ADDLIBS''' Autoconf output variable is set to the list of additional library dependencies for third party packages.
    141    * For COIN projects, the {{{AC_COIN_HAS_PROJECT}}} Autoconf macro generates output variables '''''PRJ''SRCDIR''' and '''''PRJ''OBJDIR''', which are set to the project's main source and object subdirectory (which are different for a VPATH compilation).  Here, ''PRJ'' is the name of the project as provided to the macro in all capital letters.
     141   * For COIN projects, the {{{AC_COIN_HAS_PROJECT}}} Autoconf macro generates output variables '''''PRJ''SRCDIR''' and '''''PRJ''OBJDIR''', which are set to the project's main source and object subdirectory (which are different for a VPATH compilation).  Here, ''PRJ'' is the name of the project as provided to the macro, in all capital letters.
    142142
    143143----------------------------
     
    158158}}}
    159159
    160  * To specify the compiler flags for include directories for header files, one should use the '''AM_CPPFLAGS''' variable.  The '''CYGPATH_W''' in the given example might seem a bit cumbersome (and it is), but this is necessary to ensure that the code can also be compiled with native Windows compilers under Cygwin.  The {{{CYGPATH_W}}} variable is automatically set to "{{{cygpath -w}}}" on Cygwin, which translates the UNIX-style path to a proper Windows path.  On other platforms, it is simply set to "{{{echo}}}".
    161 
    162  Note that one can also make use of the '''''PRJ''SRCDIR''' variables for the COIN projects.
     160 * To specify the compiler flags for include directories for header files, one should use the '''AM_CPPFLAGS''' variable.  The usage of the '''CYGPATH_W''' variable might seem a bit cumbersome (and it is), but this is necessary to ensure that the code can also be compiled with native Windows compilers under Cygwin.  The {{{CYGPATH_W}}} variable is automatically set to "{{{cygpath -w}}}" on Cygwin, which translates the UNIX-style path to a proper Windows path.  On other platforms, it is simply set to "{{{echo}}}".
     161
     162 Note that one can make use of the '''''PRJ''SRCDIR''' variables for the COIN projects.
    163163
    164164=== Additional Preprocessor Definitions ===
     
    179179}}}
    180180
    181  * You should have the lines above somewhere in your {{{Makefile.am}}} file, to make sure that users can compile your code under Cygwin using the native Windows compilers in a VPATH configuration.  The default setting for '''DEFAULT_INCLUDES''' does not have the {{{CYGPATH_W}}}.
     181 * You should have the lines above somewhere in your {{{Makefile.am}}} file, to make sure that users can compile your code under Cygwin using the native Windows compilers in a VPATH configuration.  The default setting for '''DEFAULT_INCLUDES''' does not use the {{{CYGPATH_W}}} variable.
    182182
    183183-------------------------
     
    210210}}}
    211211
    212  * In order to use a COIN library (which is written in C or C++), a user will need some of the header files in the source directories to compile her/his own code.  For this reason, we specify the requires header files (which mighy only be a subset of all header files in the source directory) in the '''include_HEADERS''' Automake variable.  The prefix '''include_''' tells {{{automake}}} that those files should be copied into the {{{include}}} installation directory.   Note that you should make sure that also the configuration header file (usually in the {{{inc}}} directory) is installed.
    213 
    214  {{{
    215  #############################################################################
     212 * In order to use a COIN library (if it is written in C or C++), a user will need some of the header files in the source directories to compile her/his own code.  For this reason, we specify the required header files (which mighy only be a subset of all header files in the source directory) in the '''include_HEADERS''' Automake variable.  The prefix '''include_''' tells {{{automake}}} that those files should be copied into the {{{include}}} installation directory.   Note that you should make sure that also the configuration header file (usually in the {{{inc}}} directory) is installed.
     213
     214{{{
     215#############################################################################
    216216# Create the Config.h file that always defines HAVE_CONFIG_H and install it #
    217217#############################################################################
     
    232232 }}}
    233233
    234  * As discussed in the [wiki:pm-autotools-intro Autotools introduction page], in COIN we don't include the configuration header file (above {{{config_clp.h}}}) directly.  Instead, this is done via the '''''Pkg''Config.h''' file, to make sure that the compilation can also be done smoothly with the Developer Studio.  Therefore, this header file should also be installed, but it has to be modified slightly.  This is done with the lines above; you should have those in one of your source code {{{Makefile.am}}} files, and adapt the '''ConfigHeader''' variable for your project.  The {{{install-exec-local}}} is run by the generated Makefile for a {{{make install}}}, and the commands for {{{uninstall-local}}} are executed for the {{{make uninstall}}}.
     234 * As discussed in the [wiki:pm-autotools-intro Autotools introduction page], in COIN we don't include the configuration header file (above {{{config_clp.h}}}) directly.  Instead, this is done via the '''''Pkg''Config.h''' file, to make sure that the compilation can also be done smoothly with the Developer Studio.  Therefore, the ''Pkg''Config.h header file should also be installed, but it has to be modified slightly.  This is done with the lines above; you should have those in one of your source code {{{Makefile.am}}} files, and adapt the '''ConfigHeader''' variable for your project.  The {{{install-exec-local}}} is run by the generated Makefile for a {{{make install}}}, and the commands for {{{uninstall-local}}} are executed for the {{{make uninstall}}}.