wiki:pm-base-make

Table of Contents

  1. Working With the GNU Autotools
    1. Introduction
    2. The configure.ac Files
    3. The Makefile.am Files
    4. Running the Autotools
    5. Which Files Should be in the Subversion Repository?
    6. Working On Your Project
  2. Autotools Basics
    1. autoconf
    2. automake
    3. libtool
  3. Basic Structure of the configure.ac File
    1. General Concepts
    2. Beginning of a configure.ac file
    3. The Body of the configure.ac File
    4. The End of the configure.ac File
  4. The Package Base Directory configure.ac File
  5. The Project Directory configure.ac File
    1. Initialization of Tools and Compilers
    2. Check for other COIN-OR Components
    3. Checks for some specific System Libraries
    4. Check for User Libraries
    5. Generation of Links for Data Files
    6. Project Specific Tests
  6. Configuration Header Files
    1. Private and public header files
    2. Header files for non-autotools setups
    3. Bringing them all together
    4. Example
  7. Introduction of Automake Concepts
  8. The Package Base Directory Makefile.am File
  9. The Project Main Directory Makefile.am File
  10. The Source Directories Makefile.am Files
    1. Beginning of the Makefile.am File
    2. Building a Library
    3. Building a Program
    4. Additional Flags
    5. Installation of Header Files
  11. The Test Directory Makefile.am File
    1. Beginning of the File
    2. Compilation of the Unit Test Program
    3. The Test Target
    4. House Cleaning
  12. The pkg-config configuration files of a project
    1. Introduction
    2. The .pc file of an installed COIN-OR project library
    3. The .pc file of an uninstalled COIN-OR project library
    4. The NO pkg-config case
  13. Using the Correct Version of the Autotools
  14. Brief Tutorial on Switching from BuildTools 0.5 to 0.7
    1. What Needs to be Edited
    2. Externals to Dependencies
    3. Changes to Installation Directories
    4. Changes to autotools files
    5. Changes to configuration header files
  15. Hints, tricks, bugs, and suggestions
    1. Using autoreconf

The Package Base Directory Makefile.am File

In the directory structure example, the package base directory is Coin-Clp.

A typical COIN-OR package base directory Makefile.am file looks like this example taken from Clp:

# Copyright (C) 2011 International Icecream Machines and others.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.

## $Id: Makefile.am 4242 2011-04-01 11:11:11Z johndoe $

# Author:  John Doe           IIM    2011-04-01

AUTOMAKE_OPTIONS = foreign

EXTRA_DIST = doxydoc/doxygen.conf
  • 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.
  • The AUTOMAKE_OPTIONS variable is a special variable that indicates certain options for the automake run. The foreign option tells automake that it should not enforce strict conformance with GNU guidelines.
  • The EXTRA_DIST variable is set to every file that should be included in a tarball generated with make dist. One only needs to list non-source files, and non-autotools related files. In the above example, the only file in this category is the configuration file for doxygen.
########################################################################
#                          Subdirectories                              #
########################################################################

# subdirs is set by configure as the list of all subdirectories to recurse into
SUBDIRS = $(subdirs)
  • The Makefile.am in a package base directory needs to be told the subdirectories into which it should recurse. This is done with the SUBDIRS variable. The Autoconf output variable subdirs is already automatically set to the correct value by configure, based on the results of the AC_COIN_MAIN_PACKAGEDIR macro tests.
########################################################################
#                           Extra Targets                              #
########################################################################

test: all
	cd Clp; $(MAKE) test

unitTest: test

tests:
	for dir in $(subdirs); do \
	  if test -r $$dir/test/Makefile; then \
	    (cd $$dir; $(MAKE) test) \
	  fi; \
	done

unitTests: tests
  • In this section we can define extra Makefile targets. As you can see, the test (and unitTest) targets first make sure that everything is compiled (the target all is the automatically generated target for compilation of everything). Then it changes into the package's 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.
# Generate doxygen doc'n in subdirectories (except @PACKAGE_NAME@) if a doxydoc
# directory is present, then do the base, if present.

doxydoc:
        for dir in $(subdirs) ; do \
          if test $$dir != @PACKAGE_NAME@ && test -r $$dir/doxydoc ; then \
            (cd $$dir ; $(MAKE) doxydoc) \
          fi ; \
        done ; \
        if test -r doxydoc/doxygen.conf ; then \
          doxygen doxydoc/doxygen.conf ; \
        fi

clean-doxydoc:
        ( cd doxydoc ; rm -rf html *.log *.tag )

# DocInstallDir is defined in Makemain.inc and is specific to the package.

install-doxydoc: doxydoc
        if test -r doxydoc/doxygen.conf ; then \
          $(mkdir_p) $(DocInstallDir) ; \ 
          cp -R doxydoc $(DocInstallDir) ; \
        fi

uninstall-doxydoc:
        rm -rf $(DocInstallDir)/doxydoc

clean-local: clean-doxydoc
# install-data-local: install-doxydoc
uninstall-local: uninstall-doxydoc


.PHONY: test unitTest tests unitTests doxydoc
  • For C++ packages, we usually also provide a target doxydoc, which runs the doxygen program for all projects that have a doxydoc directory. The doxygen documentations may be connected with doxygen tag files, so we create first the doxygen projects of all other projects and finally the one of our project. See the Using Doxygen in COIN-OR Documentation for more details.
########################################################################
#                         Maintainer Stuff                             #
########################################################################

# Files that are generated and should be cleaned with make distclean
DISTCLEANFILES = coin_subdirs.txt

include BuildTools/Makemain.inc
  • Finally, we include the BuildTools include file Makemain.inc. This makes sure that additional maintainer-specific targets are defined (such as an automatic update of the svn:externals property when the Dependencies file has been changed). Since values are added to the DISTCLEANFILES variable in this include file, this variable has to be "initalized" here. The file coin_subdirs.txt is setup by the configure in the base directory and stores the project directories which are recursed into. It is used by project's configure script to find other projects and should be removed when make distclean is called.
Last modified 9 years ago Last modified on May 8, 2011 8:04:35 AM