-
Notifications
You must be signed in to change notification settings - Fork 62
Automake Files
Once you've downloaded all the necessary prerequisites, these shell commands will build MADNESS.
cd trunk/ autoreconf ./configure #check trunk/INSTALL for the appropriate arguments for LIBS= make
This page describes the basic elements of automakefiles (Makefile.am). For detailed documentation please refer to the automake project documentation.
Look at the bottom of this page for a sample automakefile for applications. See NewSubDirectory for how to add a new subdirectory.
Why automakefiles? They are much simpler to write than full makefiles and we leverage the existing GNU autotool structure to manage our dependencies and to hide the idiosyncrasies of the world at large. By using the full GNU autotool chain we maintain better compatibility with the GNU world which will help us when we finally try to push MADNESS into Linux-GNU distributions. Our package and makefiles will behave exactly as expected by anyone used to building other GNU packages.
Bear in mind that the automakefiles don't just describe how to build libraries and programs, but also how to build a tar or package file for distribution of MADNESS and how to install MADNESS when it is built (see below). This is why you might sometimes have to specify more detail than is necessary just to build the code.
The MADNESS configure/make structure is still incomplete since we don't yet have logic to install the code after building it - this will come soon.
When you run automake in the top level directory (probably as part of autoreconf) each Makefile.am indicated in configure.ac is converted into a Makefile.in. Subsequently, running configure converts the Makefile.in into the actual Makefile. The SVN source repository only contains the Makefile.am, which is why you need to run autoreconf when you first check the source out. However, an actual distribution tar file of MADNESS will contain the Makefile.in so that end-users only need run configure.
The generated Makefiles are truly horrific. Don't try to edit them - even if you somehow get things to work your changes will be lost the next time configure is run.
Modifications to the Makefile.am will be detected by make which will automatically cause the Makefile.in and Makefile to be regenerated. Thus you can easily add new source files and targets to the Makefile.am without manually re-running autoreconf and configure.
You can override the configured compiler options on the command line. E.g.,
make CXXFLAGS="-g -O0"
This is best illustrated with a real example. Here is src/lib/world/Makefile.am
include $(top_srcdir)/config/MakeGlobal.am bin_PROGRAMS = world testhash lib_LIBRARIES = libMADworld.a testhash_SOURCES = testhash.cc world_SOURCES = world.cc world_LDADD = libMADworld.a libMADworld_a_SOURCES = worldstuff.cc redirectio.cc archive_type_names.cc debug.cc print.cc worldmem.cc lookup3.c \ \ archive.h print.h worldam.h worldfut.h worldmpi.h worldtask.h \ array.h sharedptr.h worldgop.h worldobj.h \ binfsar.h mpiar.h textfsar.h worlddc.h world.h worldprofile.h worldtime.h \ bufar.h nodefaults.h typestuff.h worlddep.h worldhash.h worldref.h worldtypes.h \ dqueue.h parar.h vecar.h worldexc.h worldmem.h worldser.h
This automakefile will build two programs (world and testhash) and one library (libMADworld.a). In the first line we include MADNESS's global automakefile that does little more than define a few variables for your convenience (more of these later). The variable bin_PROGRAM
defines the programs to be built. If you don't have any don't define it. Similarly, lib_LIBRARIES
defines the libraries to be built. For each program or library we must list _all_ of the source files (including headers) in the corresponding item_SOURCES
(where you replace item with the name of the program or library, replacing .a
with _a
). For clarity, MADNESS adopts the convention that SOURCES
should first list the actual source files and then the header files.
Additional libraries required to link items should be listed on item_LDADD
. If all programs in a directory require the same additional options or libraries, they can be listed in the variable LDADD
.
Presently this files just defines variables pointing to the directories containing the standard MADNESS libraries (e.g., LIBWORLDDIR
), variables pointing to the actual libraries (e.g., LIBWORLD
), and for the convenience of most applications it also defines MRALIBS
to contain the libraries necessary to link most applications.
Here is the Makefile.am from the TDSE (time-dependent Schroedinger equation) directory. Your Makefile.am should probably be no more complicated.
include $(top_srcdir)/config/MakeGlobal.am bin_PROGRAMS = tdse tdse_SOURCES = tdse.cc tdse_LDADD = $(MRALIBS)
For more information consult http://en.wikipedia.org/wiki/Autoconf