Changes between Version 1 and Version 2 of pm-project-make


Ignore:
Timestamp:
Jun 1, 2006 8:23:47 PM (14 years ago)
Author:
andreasw
Comment:

finished first draft

Legend:

Unmodified
Added
Removed
Modified
  • pm-project-make

    v1 v2  
    1 = The Package Base Directory Makefile.am File =
     1= The Makefile.am File in the Project Main Subdirectory =
    22
    3 A typical COIN package base directory {{{Makefile.am}}} file looks like this example taken from Clp:
     3In the [wiki:user-directories directory structure example], the project main directories are {{{Clp}}} and {{{CoinUtils}}}.
     4
     5The purpose of the Makefile here is to recurse into the source code directories to compile the code, to do the project specific installations, and to provide a {{{test}}} target to run the project's unit test (if available).
     6
     7A typical COIN project main subdirectory {{{Makefile.am}}} file looks like this example taken from Clp:
    48
    59{{{
     
    1418AUTOMAKE_OPTIONS = foreign
    1519
    16 EXTRA_DIST = doxydoc/doxygen.conf
    17 
    1820########################################################################
    1921#                          Subdirectories                              #
    2022########################################################################
    2123
    22 # subdirs is set by configure as the list of all subdirectories to recurse
    23 # into
    24 SUBDIRS = $(subdirs)
     24SUBDIRS = src
    2525
     26# We don't want to compile the test subdirectory, unless the test target is
     27# specified.  But we need to list it as subdirectory to make sure that it is
     28# included in the tarball
     29
     30if ALWAYS_FALSE
     31  SUBDIRS += test
     32endif
     33}}}
     34
     35 * One should always start with a copyright note and author information, and include the {{{svn:keyword}}} "{{{$Id}}}".  The line with the keyword should start with "{{{##}}}" so that it is not copied into the generated {{{Makefile.in}}} file, which causes some confusion for subversion.
     36
     37 * As for the [wiki:pm-base-make base directory Makefile.am file], we first specify ,in the '''SUBDIRS''' variable, the subdirectories  into which to recurse in order to compile the libraries, programs, and whatever other products this project has to offer.  In this examples, it is only one directory, but in order to organize your code, you might want to split the source files into different directories, in which case you need to specify them all here.  These lines with the {{{ALWAYS_FALSE}}} Automake conditional (which is always false :) are a trick to skip recursion into the {{{test}}} subdirectory for a usual run of {{{make}}} to build the products, but it will cause a {{{make dist}}} to pick up the files in the {{{test}}} directory (even though we don't use the {{{make dist}}} mechanism to generate the COIN tarballs.)
     38
     39{{{
     40########################################################################
     41#             Additional files to be included in tarball               #
     42########################################################################
     43
     44# Here we need include all files that are not mentioned in other Makefiles
     45
     46EXTRA_DIST = \
     47        doc/authors.xml \
     48        doc/basicmodelclasses.xml \
     49        doc/clpexe.xml \
     50        doc/clpuserguide.xml \
     51        examples/driver.cpp \
     52        examples/dualCuts.cpp \
     53        examples/ekk.cpp \
     54        examples/ekk_interface.cpp \
     55        examples/hello.cpp \
     56        examples/hello.mps \
     57        examples/input.130 \
     58        examples/INSTALL
     59}}}
     60
     61 * In this section we specify additional files that should be included in a {{{make dist}}} tarball, using the '''EXTRA_DIST''' Automake variable.
     62
     63{{{
    2664########################################################################
    2765#                           Extra Targets                              #
     
    2967
    3068test: all
    31         cd Clp; make test
     69        cd test; make test
    3270
    3371unitTest: test
    3472
    35 tests:
    36         for dir in $(subdirs); do \
    37           if test -r $$dir/test/Makefile; then \
    38             (cd $$dir; make test) \
    39           fi; \
    40         done
     73clean-local:
     74        if test -r test/Makefile; then cd test; make clean; fi
    4175
    42 unitTests: tests
     76distclean-local:
     77        if test -r test/Makefile; then cd test; make distclean; fi
    4378
    44 doxydoc:
    45         cd $(srcdir); doxygen doxydoc/doxygen.conf
     79.PHONY: test unitTest
     80}}}
    4681
    47 .PHONY: test unitTest tests unitTests doxydoc
     82In this section we define some extra targets:
    4883
     84 * The '''test''' (and '''unitTest''') target, which first makes sure that everything has been compiled (since it depends on {{{all}}}), and then changes into the {{{test}}} subdirectory, where it runs the {{{test}}} target.  If the project does not provide a unit test, this is of course not there.
     85
     86 * The '''clean-local''' and '''distclean-local''' targets are special Automake targets.  They are "called", when the user does a "{{{make clean}}}" and "{{{make distclean}}}".  It allows us to specify additional actions for that case.  Here, we want to make sure that also the {{{test}}} subdirectory is cleaned; by default it is not, since it is not included in the {{{SUBDIRS}}} variable, since the {{{ALWAYS_FALSE}}} Automake conditional is always false.  The command line simply checks if the Makefile in the {{{test}}} subdirectory exists, and if it does, the corresponding target is made.
     87
     88{{{
     89########################################################################
     90#                  Installation of the addlibs file                    #
     91########################################################################
     92
     93addlibsfile = clp_addlibs.txt
     94
     95install-exec-local:
     96        $(install_sh_DATA) $(addlibsfile) $(DESTDIR)$(libdir)/$(addlibsfile)
     97
     98uninstall-local:
     99        rm -f $(DESTDIR)$(libdir)/$(addlibsfile)
     100}}}
     101
     102 * Those lines make sure that the '''..._addlibs.txt''' files is installed.  This is the file containing additionally required library link flags in order to link with the library generated by this project's Makefiles.  You only have to adapt the '''addlibsfile''' variable.
     103
     104{{{
    49105########################################################################
    50106#                         Maintainer Stuff                             #
     
    54110DISTCLEANFILES =
    55111
    56 include BuildTools/Makemain.inc
     112include ../BuildTools/Makemain.inc
    57113}}}
    58114
    59  * One should always start with a copyright note and author information, and include the {{{svn:keyword}}} "{{{$Id}}}"
    60 
    61  * The '''AUTOMAKE_OPTIONS''' variable is a special variable that indicates certain options for the {{{automake}}} run.  The '''foreign''' option doesn't require the strict conformance with GNU guidelines.
    62 
    63  * The '''EXTRA_DIST''' variable is set to every file that should be included in a {{{make dist}}} generated tarball.  One only needs to list non-source files, and non-autotools related files.  In the above example, this is only the configuration file for doxygen.
    64 
    65  * The {{{Makefile.am}}} in a package base directory needs to be told into which subdirectories to recurse.  This is done with the '''SUBDIRS''' variable.  The Autoconf output variable is already automatically set to the correct value by {{{configure}}}, based on the results of the {{{AC_COIN_MAIN_SUBDIRS}}} macro tests.
    66 
    67  * In the next section we can define '''extra Makefile targets'''.  As you can see, the '''test''' (and '''unitTest''') first make sure that everything is compiled (the target {{{all}}} is the automatically generated target for compilation of everything).  Then it changes into the packages project directory and runs the {{{test}}} target there.  It is also nice to provide a '''tests''' (and '''unitTests''') target, which runs the {{{test}}} targets in every project subdirectory that seems to have a {{{test}}} subdirectory with a Makefile.
    68 
    69  * For C++ packages, we usually also provide a target '''doxydoc''', which runs the {{{doxygen}}} program for all source code found in subdirectories.  Note the "'''cd $(srcdir)'''" here.  In case of a VPATH compilation, the Makefile generated from this {{{Makefile.am}}} file is not run in the directory where {{{doxygen}}} should be run.  The Autoconf output variable '''srcdir''' is set to the directory which contains the source code (such as the {{{Makefile.am}}} file) corresponding to the VPATH directory.
    70 
    71  * Finally, we '''include the BuildTools include Makefile.am'''.  This makes sure that additional maintainer-specific targets are defined (such as an automatic update of the {{{svn:externals}}} property when the {{{Externals}}} file has been changed). 
     115 * This makes sure that some maintainer-specific things are automatically taken case of.  Just copy this to the end of you own {{{Makefile.am}}} file.