EMAN Autoconf HowTo


Introduction

This document is a step-by-step guide on how to use GNU autoconf system to add new files, new directories, and new options to EMAN autoconf system.

  1. Install new versions of GNU tools
  2. Three software packages are used: libtool, autoconf, and automake. Because old versions of these softwares don't work well with EMAN, you need to install newer versions from source code.

  3. Add your changes to EMAN
    • How to add a new directory
    • Assume you want to add a new directory called v2 . Here are what you need to do:
      • Create 'v2':
        1. cd EMAN/src/eman
        2. mkdir v2
        3. cvs add v2
        4. copy/add your source code to 'v2'
        5. create a file called Makefile.am in v2.
          (See the following on how to create Makefile.am.)

      • Add the new directory to EMAN autoconf system:
        1. add 'v2' to eman/Makefile.am
        2. add 'v2' to eman/bootstrap
        3. add 'v2/Makefile' to AC_CONFIG_FILES() at the end of eman/configure.in

      • Run autoconf tools to create new config.

    • How to add a new file
    • Usually, you need only change one file: Makefile.am, which locates at the directory where you want to add the new file. The necessary changes in Makefile.am can be got from similar existing files.

      For example, to add 'proc2d.C' to 'eman/src' directory. Here are what you need to add to src/Makefile.am:

      1. add 'proc2d' to 'bin_PROGRAMS';
      2. add a new line:
        proc2d_SOURCES = proc2d.C

    • How to add a new option
    • Here is an example to add an option to autoconf in EMAN.

      • Purpose

        Add openMP support for EMAN autoconf system, so that a user can compile openMP program optionally.
      • Requirements

        1. default setup is no openMP. use option '--enable-openmp' to enable it.

        2. openMP library and include directories can be specified with '--with-openmp-lib=DIR', and '--with-openmp-inc=DIR'.

        3. 'omp.h' will be searched to determine whether openMP is installed on your computer.

        4. '-lmp' is added to linker flags; '-mp' is added to compiler flags for SGI machines.

        5. add openMP support to 'eman/src' binaries only

      • Implementation

        Two files need to be edited.
        • EMAN/src/eman/configure.in;
        • EMAN/src/eman/src/Makefile.am

        1. add the following to configure.in:
          			
          AC_ARG_ENABLE(openmp,	     [  --enable-openmp		enable OpenMP support [default=no]])
          AC_ARG_WITH(openmp-includes, [  --with-openmp-inc=DIR   OpenMP include files are in DIR])
          AC_ARG_WITH(openmp-libraries,[  --with-openmp-lib=DIR   OpenMP library files are in DIR])
          
          if test "$enable_openmp" = "yes"; then
              search_headerdir "OpenMP" "omp.h" 0 $with_openmp_inc
          
              if test ! "X$found_incdir" = "X"; then
                  OPENMP_CXXFLAGS="-DOPENMP -I${found_incdir}"
                  if test ! $with_openmp_lib = "X"; then
                      openmp_libdir="-L$with_openmp_lib"
                  fi
                  OPENMP_LIB="$openmp_libdir -lmp"
              else
                  AC_MSG_RESULT([WARNING: OpenMP support disabled])
              fi        
          fi   
          
          # for SGI machine only
          if test ! "$OPENMP_CXXFLAGS" = "X"; then
              OPENMP_CXXFLAGS="-mp ${OPENMP_CXXFLAGS}"
          fi
          
          
          AC_SUBST(OPENMP_CXXFLAGS)
          AC_SUBST(OPENMP_LIB)
          
        2. add the following to src/Makefile.am
          1. add '$(OPENMP_LIB)' to 'LDADD' macro
          2. add '$(OPENMP_CXXFLAGS)' to 'AM_CXXFLAGS' macro

    • How to create a new Makefile.am
    • The best way to know how to do this is to refer other Makefile.am in EMAN. For example,
      • To create a new library, refer eman/libEM/Makefile.am.
      • To create a Qt2 binary, refer eman/boxer/Makefile.am.
      • To create a regular binary, refer eman/src/Makefile.am.
      • To create a Qt3 binary, refer eman/helixboxer/Makefile.am.

  4. Use autoconf tools to update EMAN autoconf system
  5. After changing any options in EMAN config files, adding a new file, or adding a new directory, run the following to generate the new config files:
    1. aclocal
    2. autoheader
    3. automake
    4. autoconf

    lpeng@bcm.tmc.edu
    Last modified: Fri Mar 14 10:33:44 CST 2003