diff options
author | James Laird <jlaird@hdfgroup.org> | 2005-10-31 21:35:49 (GMT) |
---|---|---|
committer | James Laird <jlaird@hdfgroup.org> | 2005-10-31 21:35:49 (GMT) |
commit | 617522e467c817811d80d60ce7e97212c9df4059 (patch) | |
tree | 15df31a9336fd427e7cba038852aa033699fe00b /c++ | |
parent | 6a53f457cfcbfcd3309dbb6fcbab03095302290e (diff) | |
download | hdf5-617522e467c817811d80d60ce7e97212c9df4059.zip hdf5-617522e467c817811d80d60ce7e97212c9df4059.tar.gz hdf5-617522e467c817811d80d60ce7e97212c9df4059.tar.bz2 |
[svn-r11646] Purpose:
Bug fix/feature
Description:
Added support for -shlib in h5fc and h5c++.
Made check-install use -shlib when only shared libraries have been installed.
Solution:
h5fc and h5c++ didn't recognize -shlib. Stole code from h5cc to link against
shared libraries.
When static libraries are disabled, the examples Makefiles will automatically
use the -shlib option to link against shared libraries. Thus,
--disable-static and make check-install should work together.
Platforms tested:
heping(disable-static, enable-static, fortran, c++), modi4 (disable-static, fortran, c++, parallel, enable-static)
Diffstat (limited to 'c++')
-rw-r--r-- | c++/Makefile.in | 18 | ||||
-rw-r--r-- | c++/examples/Makefile.am | 5 | ||||
-rw-r--r-- | c++/examples/Makefile.in | 23 | ||||
-rw-r--r-- | c++/src/Makefile.in | 18 | ||||
-rwxr-xr-x | c++/src/h5c++.in | 73 | ||||
-rw-r--r-- | c++/test/Makefile.in | 18 |
6 files changed, 127 insertions, 28 deletions
diff --git a/c++/Makefile.in b/c++/Makefile.in index ebaab76..a443524 100644 --- a/c++/Makefile.in +++ b/c++/Makefile.in @@ -99,6 +99,8 @@ BUILD_PABLO_CONDITIONAL_FALSE = @BUILD_PABLO_CONDITIONAL_FALSE@ BUILD_PABLO_CONDITIONAL_TRUE = @BUILD_PABLO_CONDITIONAL_TRUE@ BUILD_PARALLEL_CONDITIONAL_FALSE = @BUILD_PARALLEL_CONDITIONAL_FALSE@ BUILD_PARALLEL_CONDITIONAL_TRUE = @BUILD_PARALLEL_CONDITIONAL_TRUE@ +BUILD_SHARED_ONLY_CONDITIONAL_FALSE = @BUILD_SHARED_ONLY_CONDITIONAL_FALSE@ +BUILD_SHARED_ONLY_CONDITIONAL_TRUE = @BUILD_SHARED_ONLY_CONDITIONAL_TRUE@ BYTESEX = @BYTESEX@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -285,12 +287,20 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la docdir = $(exec_prefix)/doc +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC = $(bindir)/h5cc # Scripts used to build examples -H5CC = $(bindir)/h5cc -H5CC_PP = $(bindir)/h5pcc -H5FC = $(bindir)/h5fc -H5FC_PP = $(bindir)/h5pfc +# If only shared libraries have been installed, have h5cc build examples with +# shared libraries instead of static libraries +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC = $(bindir)/h5cc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC_PP = $(bindir)/h5pcc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC_PP = $(bindir)/h5pcc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC = $(bindir)/h5fc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC = $(bindir)/h5fc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC_PP = $(bindir)/h5pfc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC_PP = $(bindir)/h5pfc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CPP = $(bindir)/h5c++ +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CPP = $(bindir)/h5c++ -shlib # .chkexe files are used to mark tests that have run successfully. # .chklog files are output from those tests. diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am index d79faea..e82c3cd 100644 --- a/c++/examples/Makefile.am +++ b/c++/examples/Makefile.am @@ -20,9 +20,6 @@ include $(top_srcdir)/config/commence.am -# Use h5c++ to build examples, instead of reguar C++ compiler -H5CPP=$(bindir)/h5c++ - # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. TEST_PROG=create readdata writedata compound extend_ds chunks h5group @@ -88,7 +85,7 @@ installcheck-local: @$(MAKE) $(AM_MAKEFLAGS) check # How to build programs using h5c++ -$(EXTRA_PROG): $(H5CPP) $(LIBHDF5) $(LIBH5CPP) +$(EXTRA_PROG): $(LIBHDF5) $(LIBH5CPP) $(H5CPP) $(CPPFLAGS) -o $@ $(srcdir)/$@.cpp # List dependencies for each program. Normally, automake would take diff --git a/c++/examples/Makefile.in b/c++/examples/Makefile.in index db940ce..f27e4bd 100644 --- a/c++/examples/Makefile.in +++ b/c++/examples/Makefile.in @@ -91,6 +91,8 @@ BUILD_PABLO_CONDITIONAL_FALSE = @BUILD_PABLO_CONDITIONAL_FALSE@ BUILD_PABLO_CONDITIONAL_TRUE = @BUILD_PABLO_CONDITIONAL_TRUE@ BUILD_PARALLEL_CONDITIONAL_FALSE = @BUILD_PARALLEL_CONDITIONAL_FALSE@ BUILD_PARALLEL_CONDITIONAL_TRUE = @BUILD_PARALLEL_CONDITIONAL_TRUE@ +BUILD_SHARED_ONLY_CONDITIONAL_FALSE = @BUILD_SHARED_ONLY_CONDITIONAL_FALSE@ +BUILD_SHARED_ONLY_CONDITIONAL_TRUE = @BUILD_SHARED_ONLY_CONDITIONAL_TRUE@ BYTESEX = @BYTESEX@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -277,12 +279,20 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la docdir = $(exec_prefix)/doc +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC = $(bindir)/h5cc # Scripts used to build examples -H5CC = $(bindir)/h5cc -H5CC_PP = $(bindir)/h5pcc -H5FC = $(bindir)/h5fc -H5FC_PP = $(bindir)/h5pfc +# If only shared libraries have been installed, have h5cc build examples with +# shared libraries instead of static libraries +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC = $(bindir)/h5cc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC_PP = $(bindir)/h5pcc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC_PP = $(bindir)/h5pcc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC = $(bindir)/h5fc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC = $(bindir)/h5fc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC_PP = $(bindir)/h5pfc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC_PP = $(bindir)/h5pfc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CPP = $(bindir)/h5c++ +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CPP = $(bindir)/h5c++ -shlib # .chkexe files are used to mark tests that have run successfully. # .chklog files are output from those tests. @@ -293,9 +303,6 @@ H5FC_PP = $(bindir)/h5pfc # tell it to clean the example programs, too. CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 -# Use h5c++ to build examples, instead of reguar C++ compiler -H5CPP = $(bindir)/h5c++ - # These are the programs that 'make all' or 'make prog' will build and # which 'make check' will run. List them in the order they should be run. TEST_PROG = create readdata writedata compound extend_ds chunks h5group @@ -546,7 +553,7 @@ installcheck-local: @$(MAKE) $(AM_MAKEFLAGS) check # How to build programs using h5c++ -$(EXTRA_PROG): $(H5CPP) $(LIBHDF5) $(LIBH5CPP) +$(EXTRA_PROG): $(LIBHDF5) $(LIBH5CPP) $(H5CPP) $(CPPFLAGS) -o $@ $(srcdir)/$@.cpp # List dependencies for each program. Normally, automake would take diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index f4e1e44..ea70e62 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -133,6 +133,8 @@ BUILD_PABLO_CONDITIONAL_FALSE = @BUILD_PABLO_CONDITIONAL_FALSE@ BUILD_PABLO_CONDITIONAL_TRUE = @BUILD_PABLO_CONDITIONAL_TRUE@ BUILD_PARALLEL_CONDITIONAL_FALSE = @BUILD_PARALLEL_CONDITIONAL_FALSE@ BUILD_PARALLEL_CONDITIONAL_TRUE = @BUILD_PARALLEL_CONDITIONAL_TRUE@ +BUILD_SHARED_ONLY_CONDITIONAL_FALSE = @BUILD_SHARED_ONLY_CONDITIONAL_FALSE@ +BUILD_SHARED_ONLY_CONDITIONAL_TRUE = @BUILD_SHARED_ONLY_CONDITIONAL_TRUE@ BYTESEX = @BYTESEX@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -319,12 +321,20 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la docdir = $(exec_prefix)/doc +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC = $(bindir)/h5cc # Scripts used to build examples -H5CC = $(bindir)/h5cc -H5CC_PP = $(bindir)/h5pcc -H5FC = $(bindir)/h5fc -H5FC_PP = $(bindir)/h5pfc +# If only shared libraries have been installed, have h5cc build examples with +# shared libraries instead of static libraries +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC = $(bindir)/h5cc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC_PP = $(bindir)/h5pcc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC_PP = $(bindir)/h5pcc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC = $(bindir)/h5fc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC = $(bindir)/h5fc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC_PP = $(bindir)/h5pfc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC_PP = $(bindir)/h5pfc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CPP = $(bindir)/h5c++ +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CPP = $(bindir)/h5c++ -shlib # .chkexe files are used to mark tests that have run successfully. # .chklog files are output from those tests. diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index 239fd41..aa436eb 100755 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -75,6 +75,8 @@ usage() { echo " subdirectories [default: $prefix]" echo " -show Show the commands without executing them" echo " -showconfig Show the HDF5 library configuration summary" + echo " -shlib Compile with shared HDF5 libraries" + echo " -noshlib Compile with static HDF5 libraries [default]" echo " " echo " <compile line> - the normal compile line options for your compiler." echo " $prog_name uses the same compiler you used to compile" @@ -180,6 +182,12 @@ for arg in $@ ; do showconfigure exit $status ;; + -shlib) + USE_SHARED_LIB="yes" + ;; + -noshlib) + USE_SHARED_LIB="no" + ;; -help) usage ;; @@ -240,13 +248,70 @@ if test "x$do_compile" = "xyes"; then fi if test "x$do_link" = "xyes"; then + shared_link="" # conditionnaly link with the hl library - if test "X$HL" = "Xhl"; then - link_args="$link_args ${libdir}/libhdf5_cpp.a ${libdir}/libhdf5.a ${libdir}/libhdf5_hl.a $LIBS" + if test "X$HL" = "Xhl"; then + libraries=" $libraries -lhdf5_cpp -lhdf5_hl -lhdf5 " + else + libraries=" $libraries -lhdf5_cpp -lhdf5 " + fi + link_args="$link_args -L${libdir}" + + case "$kind" in + gcc|linux*) + # MacOS X doesn't support the "-Wl,-rpath -Wl," style of linker flags. + # It appears to want none of them specified. + case "$host_os" in + darwin*) flag="" ;; + *) flag="-Wl,-rpath -Wl," ;; + esac + ;; + hpux*) flag="-Wl,+b -Wl," ;; + freebsd*|solaris*) flag="-R" ;; + rs6000*|aix*) flag="-L" ;; + irix*|sgi) flag="-rpath " ;; + *) flag="" ;; + esac + + if test -n "$flag"; then + shared_link="${flag}${libdir}" + fi + + if test "x$USE_SHARED_LIB" != "xyes"; then + # The "-lhdf5" & "-lhdf5_hl" flags are in here already...This is a static + # compile though, so change it to the static version (.a) of the library. + new_libraries="" + for lib in $libraries; do + case "$lib" in + -lhdf5) + new_libraries="$new_libraries ${libdir}/libhdf5.a" + ;; + -lhdf5_hl) + new_libraries="$new_libraries ${libdir}/libhdf5_hl.a" + ;; + *) + new_libraries="$new_libraries $lib" + ;; + esac + done + libraries="$new_libraries" + fi + + for lib in $libraries; do + if echo $link_args | grep " $lib " > /dev/null || + echo $link_args | grep " $lib$" > /dev/null; then + : else - link_args="$link_args ${libdir}/libhdf5_cpp.a ${libdir}/libhdf5.a $LIBS" + link_args="$link_args $lib " fi - $SHOW $CXXLINKER -I$includedir $CPPFLAGS $CXXFLAGS $LDFLAGS $clibpath $link_objs $link_args + done + + # The LIBS are just a bunch of -l* libraries necessary for the HDF5 + # module. It's okay if they're included twice in the compile line. + link_args="$link_args $LIBS" + + $SHOW $CXXLINKER $CPPFLAGS $CXXFLAGS $LDFLAGS $clibpath $link_objs $link_args $shared_link + status=$? fi diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 2891a2d..88df2a0 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -122,6 +122,8 @@ BUILD_PABLO_CONDITIONAL_FALSE = @BUILD_PABLO_CONDITIONAL_FALSE@ BUILD_PABLO_CONDITIONAL_TRUE = @BUILD_PABLO_CONDITIONAL_TRUE@ BUILD_PARALLEL_CONDITIONAL_FALSE = @BUILD_PARALLEL_CONDITIONAL_FALSE@ BUILD_PARALLEL_CONDITIONAL_TRUE = @BUILD_PARALLEL_CONDITIONAL_TRUE@ +BUILD_SHARED_ONLY_CONDITIONAL_FALSE = @BUILD_SHARED_ONLY_CONDITIONAL_FALSE@ +BUILD_SHARED_ONLY_CONDITIONAL_TRUE = @BUILD_SHARED_ONLY_CONDITIONAL_TRUE@ BYTESEX = @BYTESEX@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ @@ -308,12 +310,20 @@ LIBH5_HL = $(top_builddir)/hl/src/libhdf5_hl.la LIBH5F_HL = $(top_builddir)/hl/fortran/src/libhdf5hl_fortran.la LIBH5CPP_HL = $(top_builddir)/hl/c++/src/libhdf5_hl_cpp.la docdir = $(exec_prefix)/doc +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC = $(bindir)/h5cc # Scripts used to build examples -H5CC = $(bindir)/h5cc -H5CC_PP = $(bindir)/h5pcc -H5FC = $(bindir)/h5fc -H5FC_PP = $(bindir)/h5pfc +# If only shared libraries have been installed, have h5cc build examples with +# shared libraries instead of static libraries +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC = $(bindir)/h5cc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CC_PP = $(bindir)/h5pcc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CC_PP = $(bindir)/h5pcc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC = $(bindir)/h5fc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC = $(bindir)/h5fc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5FC_PP = $(bindir)/h5pfc +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5FC_PP = $(bindir)/h5pfc -shlib +@BUILD_SHARED_ONLY_CONDITIONAL_FALSE@H5CPP = $(bindir)/h5c++ +@BUILD_SHARED_ONLY_CONDITIONAL_TRUE@H5CPP = $(bindir)/h5c++ -shlib # .chkexe files are used to mark tests that have run successfully. # .chklog files are output from those tests. |