From 45a6e2c0c8838119d5ea8117b86a2faba89e843b Mon Sep 17 00:00:00 2001
From: James Laird
+
diff --git a/doc/html/TechNotes/Automake.html b/doc/html/TechNotes/Automake.html
new file mode 100644
index 0000000..c6dfc41
--- /dev/null
+++ b/doc/html/TechNotes/Automake.html
@@ -0,0 +1,223 @@
+
+
+
+
+Automake Use Cases
+
+ Simple explanations of how to make some common changes to HDF5's Automake-generated Makefiles.am.
+ An Automake Primer for HDF5
+James Laird - May 2005
+
+How to:
Suppose you need to make a minor change to the Makefile in the test directory
+(hdf5/test/Makefile
). You have checked out hdf5 from the CVS repository into
+~/scratch/hdf5
. You want to build the library in a directory named
+~/scratch/build
.
+First, edit the Makefile.am in the source tree. You must make any changes in the Makefile.am,
+not the Makefile, since the Makefile is automatically generated.
cd ~/scratch/hdf5/test
+vi Makefile.am
Now, go to the root of the source tree and run the reconfigure script, which updates the +source tree. It will create a new Makefile.in in the test directory with your changes.
+ +cd ~/scratch/hdf5
+./bin/reconfigure
After running bin/reconfigure
, you will want to test your change. Go to
+~/scratch/build
and run configure
.
cd ~/scratch/build
+
+../hdf5/configure
+
+make check
Configure generates Makefiles from the Makefiles.in in the source tree. The dependencies are:
+ +Makefile.am -> (bin/reconfigure) -> Makefile.in -> (configure) -> Makefile
Reconfigure should also be used when any change is made to configure.in.
+Suppose you want to add the source file h5testfoo.c
to the HDF5 test
+library in the test directory. You open up test/Makefile.am
in your
+favorite text editor and scroll down until you see the line:
libh5test_la_SOURCES=h5test.c testframe.c
Just add h5testfoo.c
to the list of sources. You're done!
+Now run bin/reconfigure
to create a new Makefile.in from the Makefile.am you just
+edited.
Suppose you want to create a new test executable named newtest
with one
+source file, newtest.c
. You open up test/Makefile.am
and find
+the line
TEST_PROG=testhdf5 lheap ohdr ...
Just add newtest
to the list of programs. That's it! Automake will by
+default guess that your program newtest
has one source file named
+newtest.c
.
+Now run bin/reconfigure
to update the Makefile.in.
Suppose you want to create a new test executable named newertest
with
+several source files. You open up test/Makefile.am
as before and find the line
TEST_PROG=testhdf5 lheap ohdr ...
Add newertest
to the list of programs.
+Now you need to tell Automake how to build newertest. Add a new line below
+TEST_PROG
:
newtest_SOURCES = source1.c source2.c source3.c
You don't need to mention header files, as these will be automatically detected.
+Now run bin/reconfigure
to update the Makefile.in.
To add the directory for a new tool, h5merge
, go to the Makefile.am
+in the tools directory (the parent directory of the directory you want to add).
+Find the line that reads
SUBDIRS=lib h5dump...
Add h5merge
to this list of subdirectories.
+Now you probably want to create a Makefile.am in the h5merge directory. A good starting
+point for this Makefile.am might be the sample Makefile.am in the config directory
+(config/Makefile.am.blank
). Alternately, you could copy the Makefile.am
+from another directory.
+Once you have your new Makefile.am in place, edit configure.in
in the root
+directory. Near the end of the file is a list of files generated by configure.
+Add tools/h5merge/Makefile.in
to this list.
+Now run bin/reconfigure
. This will update configure and generate a Makefile.in in the
+tools/h5merge
directory. Don't forget to add both the Makefile.am and the Makefile.in to
+CVS, and to update the manifest!.
Suppose you only want to compile a program when HDF5 is configured to run in
+parallel--for example, a parallel version of h5repack called h5prepack
.
+Open up the h5repack Makefile.am
+The simple solution is:
if BUILD_PARALLEL_CONDITIONAL
+ H5PREPACK=h5prepack
+endif
Now the variable $H5PREPACK
will be "h5prepack" if parallel is
+enabled and "" if parallel is disabled. Add $H5PREPACK
to the list of
+programs to be built:
bin_PROGRAMS=h5repack $(H5PREPACK)
Add sources for this program as usual:
+ +h5prepack_SOURCES=...
Don't forget to run bin/reconfigure
when you're done!
Automake conditionals can be a very powerful tool. Suppose that instead of building
+two versions of h5repack during a parallel build, you want to change the name of
+the tool depending on whether or not HDF5 is configured to run in parallel--you
+want to create either h5repack or h5prepack, but not both.
+Open up the h5repack Makefile.am and use an automake conditional:
if BUILD_PARALLEL_CONDITIONAL
+ H5REPACK_NAME=h5prepack
+else
+ H5REPACK_NAME=h5repack
+endif
+bin_PROGRAMS=$(H5REPACK_NAME)
Now you only build one program, but the name of that program changes. You still need +to define sources for both h5repack and h5prepack, but you needn't type them out twice if +they are the same:
+ +h5repack_SOURCES=...
+h5prepack_SOURCES=$(h5repack_SOURCES)
Don't forget to run bin/reconfigure
when you're done!
Suppose you want to add a new library to the HDF5 build tree, libfoo. The procedure for +building libraries is very similar to that for building programs:
+ +lib_LTLIBRARIES=libfoo.la
+libfoo_la_SOURCES=sourcefoo.c sourcefootwo.c
This library will be installed in the lib directory when a user types
+"make install
".
+You might instead be building a convenience library for testing purposes (like
+libh5test.la
) and not want it to be installed. If this is the case, you
+would type
check_LTLIBRARIES=libfoo.la
+instead of
+lib_LTLIBRARIES=libfoo.la
To make it easier for other directories to link to your library,
+you might want to assign its path to a variable in all HDF5 Makefiles. You can
+make changes to all Makefiles by editing config/commence.am
and adding a line
+like
LIBFOO=$(top_builddir)/foo/src/libfoo.la
config/commence.am
is textually included in all Makefiles.am when automake
+processes them.
+As always, if you change a Makefile.am or config/commence.am
, don't forget to run
+bin/reconfigure
.
If you have added or removed a function from HDF5, or if you have changed a function
+signature, you must indicate this by updating the file lt_vers.am
located in
+the config
directory.
+If you have changed the API at all, increment LT_VERS_INTERFACE
and set
+LT_VERS_REVISION
to zero.
+If you have added functions but not altered or removed existing ones, also increment
+LT_VERS_AGE
.
+If instead you have altered or removed any functions, reset LT_VERS_AGE
to
+zero.