From af1e100f49c8cdb6b0517352e4350690a6f7f51e Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 10:44:24 -0500 Subject: For portability, use the POSIX sh(1) string-comparison operator `=` instead of `==`. --- tools/test/h5jam/testh5jam.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/h5jam/testh5jam.sh.in b/tools/test/h5jam/testh5jam.sh.in index 3ae180b..bf705b4 100644 --- a/tools/test/h5jam/testh5jam.sh.in +++ b/tools/test/h5jam/testh5jam.sh.in @@ -474,9 +474,9 @@ UNJAMTEST () { # TOOLTEST_OUTPUT() { - if [ "$1" == "JAM" ]; then + if [ "$1" = "JAM" ]; then TOOLCMD=$JAM_BIN/$JAM - elif [ "$1" == "UNJAM" ]; then + elif [ "$1" = "UNJAM" ]; then TOOLCMD=$JAM_BIN/$UNJAM fi shift -- cgit v0.12 From 7c82abc3fffa2ce573a9fd1b585962437a813ed6 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 11:12:32 -0500 Subject: Not every system has perl installed in /usr/bin/, so change the shebang (#!) line to `/usr/bin/env perl` to locate perl on the PATH. Everything after the first pathname in the shebang line is treated as a single argument to the command interpreter (/usr/bin/env "perl -w"), and there is not ordinarily any such program as "perl -w". So if the old shebang line used an option such as `-w`, add a `use warnings;` statement to the script---note that the semantics change slightly. `bin/destdep` uses a trick to pass `-p` to `/usr/bin/env perl`. It couldn't hurt to use the same trick to pass `-w`. With these changes, `sh autogen.sh` runs on NetBSD. It ought to still work on every other system HDF5 supports, too. --- bin/checkapi | 4 +++- bin/checkposix | 3 ++- bin/debug-ohdr | 2 +- bin/dependencies | 4 +++- bin/distdep | 5 ++++- bin/errors | 3 ++- bin/iostats | 2 +- bin/make_err | 3 ++- bin/make_overflow | 3 ++- bin/make_vers | 3 ++- bin/runbkgprog | 3 ++- bin/trace | 3 ++- 12 files changed, 26 insertions(+), 12 deletions(-) diff --git a/bin/checkapi b/bin/checkapi index 6882dea..f5dcacc 100755 --- a/bin/checkapi +++ b/bin/checkapi @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -13,6 +13,8 @@ # require 5.003; +use warnings; + # Purpose: insures that API functions aren't called internally. # Usage: checkapi H5*.c my $filename = ""; diff --git a/bin/checkposix b/bin/checkposix index 30128e3..233d15c 100755 --- a/bin/checkposix +++ b/bin/checkposix @@ -1,5 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl require 5.003; +use warnings; # # Copyright by The HDF Group. diff --git a/bin/debug-ohdr b/bin/debug-ohdr index 5b0a4b3..1363456 100755 --- a/bin/debug-ohdr +++ b/bin/debug-ohdr @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. diff --git a/bin/dependencies b/bin/dependencies index 82247da..367351a 100755 --- a/bin/dependencies +++ b/bin/dependencies @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -11,6 +11,8 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # +use warnings; + my $depend_file; my $new_depend_file; my $srcdir; diff --git a/bin/distdep b/bin/distdep index 4643700..cd310e0 100755 --- a/bin/distdep +++ b/bin/distdep @@ -1,4 +1,7 @@ -#!/usr/bin/perl -p +#!/bin/sh +#! -*-perl-*- +eval 'exec perl -p -x -S $0 ${1+"$@"}' + if 0; # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. diff --git a/bin/errors b/bin/errors index 3c99fdc..107bb9c 100755 --- a/bin/errors +++ b/bin/errors @@ -1,5 +1,6 @@ -#!/usr/local/bin/perl -w +#!/usr/bin/env perl require 5.003; +use warnings; use Text::Tabs; # NOTE: THE FORMAT OF HRETURN_ERROR AND HGOTO_ERROR MACROS HAS diff --git a/bin/iostats b/bin/iostats index f054b9c..e389992 100755 --- a/bin/iostats +++ b/bin/iostats @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. diff --git a/bin/make_err b/bin/make_err index 623c1b6..7f38591 100755 --- a/bin/make_err +++ b/bin/make_err @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl require 5.003; $indent=4; +use warnings; # # Copyright by The HDF Group. diff --git a/bin/make_overflow b/bin/make_overflow index ccd640e..cee0126 100755 --- a/bin/make_overflow +++ b/bin/make_overflow @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl require 5.003; use strict; +use warnings; # Global settings diff --git a/bin/make_vers b/bin/make_vers index 1ea1402..c6d2c04 100755 --- a/bin/make_vers +++ b/bin/make_vers @@ -1,5 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl require 5.003; +use warnings; # Global settings # (The max_idx parameter is the only thing that needs to be changed when adding diff --git a/bin/runbkgprog b/bin/runbkgprog index 69fa2d0..f04ea89 100755 --- a/bin/runbkgprog +++ b/bin/runbkgprog @@ -1,5 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl require 5.003; +use warnings; $indent=4; # diff --git a/bin/trace b/bin/trace index 54b6f8f..eac0126 100755 --- a/bin/trace +++ b/bin/trace @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl ## # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -12,6 +12,7 @@ # help@hdfgroup.org. ## require 5.003; +use warnings; $Source = ""; ############################################################################## -- cgit v0.12 From cef5db7e1f97d5e30513a9cb4e879b08b05c9b78 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 11:19:23 -0500 Subject: For portability, insulate the HDF5 library from some system macros. --- src/H5private.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/H5private.h b/src/H5private.h index bb2a2eb..62951b7 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -345,6 +345,14 @@ #define FAIL (-1) #define UFAIL (unsigned)(-1) +/* The HDF5 library uses the symbol `ERR` frequently. So do + * header files for libraries such as curses(3), terminfo(3), etc. + * Remove its definition here to avoid clashes with HDF5. + */ +#ifdef ERR +#undef ERR +#endif + /* number of members in an array */ #ifndef NELMTS # define NELMTS(X) (sizeof(X)/sizeof(X[0])) @@ -1645,9 +1653,18 @@ extern char *strdup(const char *s); /* Assign a variable to one of a different size (think safer dst = (dsttype)src"). * The code generated by the macro checks for overflows. + * + * Use w##x##y##z instead of H5_GLUE4(w, x, y, z) because srctype + * or dsttype on some systems (e.g., NetBSD 8 and earlier) may + * supply some standard types using a macro---e.g., + * #defineĀ uint8_tĀ __uint8_t. The preprocessor will expand the + * macros before it evaluates H5_GLUE4(), and that will generate + * an unexpected name such as ASSIGN___uint8_t_TO___uint16_t. + * The preprocessor does not expand macros in w##x##y##z, so + * that will always generate the expected name. */ #define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ - H5_GLUE4(ASSIGN_,srctype,_TO_,dsttype)(dst,dsttype,src,srctype)\ + ASSIGN_##srctype##_TO_##dsttype(dst,dsttype,src,srctype)\ #else /* NDEBUG */ #define H5_CHECKED_ASSIGN(dst, dsttype, src, srctype) \ -- cgit v0.12 From 6083b740ad585610300bb60e1456ab33d636ac6f Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 12:52:01 -0500 Subject: Make the HDF5 configure script grok NetBSD. --- config/netbsd | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ 2 files changed, 59 insertions(+) create mode 100644 config/netbsd diff --git a/config/netbsd b/config/netbsd new file mode 100644 index 0000000..9a9348b --- /dev/null +++ b/config/netbsd @@ -0,0 +1,56 @@ +# -*- shell-script -*- +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. + + +# This file is part of the HDF5 build script. It is processed shortly +# after configure starts and defines, among other things, flags for +# the various compile modes. +# +# See BlankForm in this directory for details. + +# The default compiler is `gcc' +if test "X-" = "X-$CC"; then + CC=gcc + CC_BASENAME=gcc +fi + +# Figure out C compiler flags +. $srcdir/config/gnu-flags + +# Figure out Intel C compiler flags +. $srcdir/config/intel-flags + +# The default Fortran 90 compiler +if test "X-" = "X-$FC"; then + case $CC_BASENAME in + gcc*|pgcc*) + FC=gfortran + FC_BASENAME=gfortran + ;; + icc*) + FC=ifort + FC_BASENAME=ifort + ;; + mpicc*) + FC=mpif90 + FC_BASENAME=mpif90 + ;; + esac +fi + +# Figure out FORTRAN compiler flags +. $srcdir/config/gnu-fflags + +# Figure out Intel F90 compiler flags +. $srcdir/config/intel-fflags + diff --git a/configure.ac b/configure.ac index 2ffbf0f..345c4bd 100644 --- a/configure.ac +++ b/configure.ac @@ -232,6 +232,9 @@ case $host_os in freebsd*) host_os_novers=freebsd ;; + netbsd*) + host_os_novers=netbsd + ;; solaris*) host_os_novers=solaris ;; -- cgit v0.12 From 7bb8d071c6b4b6fecc84eda4982cab6b86f9ff04 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 13:26:35 -0500 Subject: Under the examples directories, always find the installed HDF5 executables and scripts using @prefix@ instead of a relative path, because the number of ../ in the relative path will be different on NetBSD than on other systems. Examples on NetBSD are installed at ${prefix}/share/examples/hdf5/ instead of at ${prefix}/share/hdf5_examples/, by convention. It may be the same on other BSDs, I'm not sure. --- c++/examples/run-c++-ex.sh.in | 2 +- examples/run-c-ex.sh.in | 2 +- fortran/examples/run-fortran-ex.sh.in | 2 +- hl/c++/examples/run-hlc++-ex.sh.in | 2 +- hl/examples/run-hlc-ex.sh.in | 2 +- hl/fortran/examples/run-hlfortran-ex.sh.in | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/c++/examples/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in index d975924..f0d3e93 100644 --- a/c++/examples/run-c++-ex.sh.in +++ b/c++/examples/run-c++-ex.sh.in @@ -32,7 +32,7 @@ EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../..}" +prefix="${prefix:-@prefix@}" AR="@AR@" RANLIB="@RANLIB@" H5TOOL="h5c++" # The tool name diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 209cdd7..4d5d594 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -31,7 +31,7 @@ EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../..}" +prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in index aa17f89..ad14368 100644 --- a/fortran/examples/run-fortran-ex.sh.in +++ b/fortran/examples/run-fortran-ex.sh.in @@ -32,7 +32,7 @@ EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../..}" +prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" diff --git a/hl/c++/examples/run-hlc++-ex.sh.in b/hl/c++/examples/run-hlc++-ex.sh.in index eb688a1..9539724 100644 --- a/hl/c++/examples/run-hlc++-ex.sh.in +++ b/hl/c++/examples/run-hlc++-ex.sh.in @@ -31,7 +31,7 @@ EXIT_SUCCESS=0 EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../../..}" +prefix="${prefix:-@prefix@}" AR="@AR@" RANLIB="@RANLIB@" H5TOOL="h5c++" # The tool name diff --git a/hl/examples/run-hlc-ex.sh.in b/hl/examples/run-hlc-ex.sh.in index f51b165..b12955f 100644 --- a/hl/examples/run-hlc-ex.sh.in +++ b/hl/examples/run-hlc-ex.sh.in @@ -31,7 +31,7 @@ EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../../..}" +prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" diff --git a/hl/fortran/examples/run-hlfortran-ex.sh.in b/hl/fortran/examples/run-hlfortran-ex.sh.in index 5f12ef0..c8f41f8 100644 --- a/hl/fortran/examples/run-hlfortran-ex.sh.in +++ b/hl/fortran/examples/run-hlfortran-ex.sh.in @@ -32,7 +32,7 @@ EXIT_FAILURE=1 # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-../../../..}" +prefix="${prefix:-@prefix@}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" -- cgit v0.12 From bbc1264ea67f93eabe53c7b555933072231e108d Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 13:30:41 -0500 Subject: Follow longstanding execv convention for compatibility with NetBSD. --- test/accum.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/accum.c b/test/accum.c index 91acf0f..f7d02fd 100644 --- a/test/accum.c +++ b/test/accum.c @@ -1838,7 +1838,6 @@ test_swmr_write_big(hbool_t newest_format) pid_t pid; /* Process ID */ #endif /* H5_HAVE_UNISTD_H */ int status; /* Status returned from child process */ - char *new_argv[] = {NULL}; char *driver = NULL; /* VFD string (from env variable) */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ @@ -1968,6 +1967,13 @@ test_swmr_write_big(hbool_t newest_format) FAIL_STACK_ERROR; } else if(0 == pid) { /* Child process */ + /* By convention, argv[0] tells the name of program invoked. + * + * execv on NetBSD 8 will actually return EFAULT if there is a + * NULL at argv[0], so we follow the convention unconditionally. + */ + char swmr_reader[] = SWMR_READER; + char * const new_argv[] = {swmr_reader, NULL}; /* Run the reader */ status = HDexecv(SWMR_READER, new_argv); HDprintf("errno from execv = %s\n", strerror(errno)); -- cgit v0.12 From b8a93a7224114739e42f32aaf62ae64fd1aad33e Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 15:56:34 -0500 Subject: Let us override the examples directory using --with-examplesdir=DIR. This is handy for NetBSD where HDF5 examples are installed by convention in $prefix/share/examples/hdf5/ rather than in ${prefix}/share/hdf5_examples/, which is the HDF5 default. Place hdf5_examples/ under ${datarootdir} which on most systems will be ${prefix}/share/, anyway. --- c++/examples/Makefile.am | 4 ++-- c++/examples/run-c++-ex.sh.in | 2 +- configure.ac | 22 ++++++++++++++++++++++ examples/Makefile.am | 4 ++-- examples/run-c-ex.sh.in | 2 +- fortran/examples/Makefile.am | 4 ++-- fortran/examples/run-fortran-ex.sh.in | 2 +- hl/c++/examples/Makefile.am | 4 ++-- hl/c++/examples/run-hlc++-ex.sh.in | 2 +- hl/examples/Makefile.am | 4 ++-- hl/examples/run-hlc-ex.sh.in | 2 +- hl/fortran/examples/Makefile.am | 4 ++-- hl/fortran/examples/run-hlfortran-ex.sh.in | 2 +- 13 files changed, 40 insertions(+), 18 deletions(-) diff --git a/c++/examples/Makefile.am b/c++/examples/Makefile.am index 51ab8e3..0648504 100644 --- a/c++/examples/Makefile.am +++ b/c++/examples/Makefile.am @@ -49,8 +49,8 @@ CXX_API=yes # Where to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/c++ -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples +EXAMPLEDIR=$(examplesdir)/c++ +EXAMPLETOPDIR=$(examplesdir) # How to build programs using h5c++ $(EXTRA_PROG): $(H5CPP) diff --git a/c++/examples/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in index f0d3e93..d01cb7f 100644 --- a/c++/examples/run-c++-ex.sh.in +++ b/c++/examples/run-c++-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the c++ examples from source files # -# installed in .../share/hdf5_examples/c++ using h5c++. The # +# installed in @examplesdir@/c++ using h5c++. The # # order for running programs with RunTest in the MAIN section below is taken # # from the Makefile. The order is important since some of the test programs # # use data files created by earlier test programs. Any future additions should # diff --git a/configure.ac b/configure.ac index 345c4bd..0eada60 100644 --- a/configure.ac +++ b/configure.ac @@ -2967,6 +2967,28 @@ fi AC_CACHE_SAVE ## ---------------------------------------------------------------------- +## Use custom examples path. +## +AC_MSG_CHECKING([for custom examples path definition]) +AC_ARG_WITH([examplesdir], + [AS_HELP_STRING([--with-examplesdir=location], + [Specify path for examples + [default="DATAROOTDIR/hdf5_examples"]])],, + withval="${datarootdir}/hdf5_examples") + +if test "X$withval" = "X"; then + AC_MSG_RESULT([default]) + examplesdir="${datarootdir}/hdf5_examples" +else + AC_MSG_RESULT([$withval]) + examplesdir=$withval +fi + +AC_SUBST([examplesdir]) +AC_DEFINE_UNQUOTED([EXAMPLESDIR], ["$examplesdir"], + [Define the examples directory]) + +## ---------------------------------------------------------------------- ## Enable custom plugin default path for library. It requires SHARED support. ## AC_MSG_CHECKING([for custom plugin default path definition]) diff --git a/examples/Makefile.am b/examples/Makefile.am index 554ee44..a0d2b00 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -84,8 +84,8 @@ CHECK_CLEANFILES+=$(EXTLINK_DIRS) # Example directory # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/c -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples +EXAMPLEDIR=$(examplesdir)/c +EXAMPLETOPDIR=$(examplesdir) # List dependencies for each program. Normally, automake would take # care of this for us, but if we tell automake about the programs it diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 4d5d594..ffb01bc 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the c examples from source files installed # -# in .../share/hdf5_examples/c using h5cc or h5pc. The order for running # +# in @examplesdir@/c using h5cc or h5pc. The order for running # # programs with RunTest in the MAIN section below is taken from the Makefile. # # The order is important since some of the test programs use data files created # # by earlier test programs. Any future additions should be placed accordingly. # diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am index 6bf2edb..fb510bc 100644 --- a/fortran/examples/Makefile.am +++ b/fortran/examples/Makefile.am @@ -74,8 +74,8 @@ endif # Tell automake how to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples +EXAMPLEDIR=$(examplesdir)/fortran +EXAMPLETOPDIR=$(examplesdir) # List dependencies for each example. Normally, automake would take # care of this for us, but if we tell automake about the programs it diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in index ad14368..8ea4dc3 100644 --- a/fortran/examples/run-fortran-ex.sh.in +++ b/fortran/examples/run-fortran-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the fortran examples from source files # -# installed in .../share/hdf5_examples/fortran using h5fc or h5pfc. The # +# installed in @examplesdir@/fortran using h5fc or h5pfc. The # # order for running programs with RunTest in the MAIN section below is taken # # from the Makefile. The order is important since some of the test programs # # use data files created by earlier test programs. Any future additions should # diff --git a/hl/c++/examples/Makefile.am b/hl/c++/examples/Makefile.am index ce719f5..592e8da 100644 --- a/hl/c++/examples/Makefile.am +++ b/hl/c++/examples/Makefile.am @@ -33,8 +33,8 @@ CXX_API=yes # Where to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl/c++ -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl +EXAMPLEDIR=$(examplesdir)/hl/c++ +EXAMPLETOPDIR=$(examplesdir)/hl # How to build programs using h5c++ $(EXTRA_PROG): $(H5CPP) diff --git a/hl/c++/examples/run-hlc++-ex.sh.in b/hl/c++/examples/run-hlc++-ex.sh.in index 9539724..1e7ce10 100644 --- a/hl/c++/examples/run-hlc++-ex.sh.in +++ b/hl/c++/examples/run-hlc++-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the c++ examples from source files # -# installed in .../share/hdf5_examples/hl/c++ using h5c++. The # +# installed in @examplesdir@/hl/c++ using h5c++. The # # order for running programs with RunTest in the MAIN section below is taken # # from the Makefile. The order is important since some of the test programs # # use data files created by earlier test programs. Any future additions should # diff --git a/hl/examples/Makefile.am b/hl/examples/Makefile.am index 29e1a48..cc2d671 100644 --- a/hl/examples/Makefile.am +++ b/hl/examples/Makefile.am @@ -25,8 +25,8 @@ endif # Example directory # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl/c -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl +EXAMPLEDIR=$(examplesdir)/hl/c +EXAMPLETOPDIR=$(examplesdir)/hl INSTALL_SCRIPT_FILES = run-hlc-ex.sh INSTALL_TOP_SCRIPT_FILES = run-hl-ex.sh diff --git a/hl/examples/run-hlc-ex.sh.in b/hl/examples/run-hlc-ex.sh.in index b12955f..1404fa4 100644 --- a/hl/examples/run-hlc-ex.sh.in +++ b/hl/examples/run-hlc-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the c examples from source files installed # -# in .../share/hdf5_examples/hl/c using h5cc or h5pc. The order for running # +# in @examplesdir@/hl/c using h5cc or h5pc. The order for running # # programs with RunTest in the MAIN section below is taken from the Makefile. # # The order is important since some of the test programs use data files created # # by earlier test programs. Any future additions should be placed accordingly. # diff --git a/hl/fortran/examples/Makefile.am b/hl/fortran/examples/Makefile.am index d383f9a..b81cc6f 100644 --- a/hl/fortran/examples/Makefile.am +++ b/hl/fortran/examples/Makefile.am @@ -51,8 +51,8 @@ endif # Tell automake how to install examples # Note: no '/' after DESTDIR. Explanation in commence.am -EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl/fortran -EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/hl +EXAMPLEDIR=$(examplesdir)/hl/fortran +EXAMPLETOPDIR=$(examplesdir)/hl # List dependencies for each example. Normally, automake would take # care of this for us, but if we tell automake about the programs it diff --git a/hl/fortran/examples/run-hlfortran-ex.sh.in b/hl/fortran/examples/run-hlfortran-ex.sh.in index c8f41f8..d7de8e3 100644 --- a/hl/fortran/examples/run-hlfortran-ex.sh.in +++ b/hl/fortran/examples/run-hlfortran-ex.sh.in @@ -18,7 +18,7 @@ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # This script will compile and run the fortran examples from source files # -# installed in .../share/hdf5_examples/hl/fortran using h5fc or h5pfc. The # +# installed in @examplesdir@/hl/fortran using h5fc or h5pfc. The # # order for running programs with RunTest in the MAIN section below is taken # # from the Makefile. The order is important since some of the test programs # # use data files created by earlier test programs. Any future additions should # -- cgit v0.12 From d459daa1f725cf24d3a0bdffdda7205cc9329d63 Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 5 Nov 2019 10:14:59 -0600 Subject: Make this script relocatable again: derive a relative path for the original installation prefix from the examples prefix. Use that relative path to locate the current installation prefix, always. Fall back to an absolute installation prefix if the relative path cannot be derived. --- examples/run-c-ex.sh.in | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index ffb01bc..82050a1 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -28,10 +28,33 @@ # Initializations EXIT_SUCCESS=0 EXIT_FAILURE=1 - + +# +# Try to derive the path to the installation $prefix established +# by ./configure relative to the examples directory established by +# ./configure. If successful, set `prefix_relto_examplesdir` to the +# relative path. Otherwise, set `prefix_relto_examplesdir` to the +# absolute installation $prefix. +# +# This script uses the value of `prefix` in the user's environment, if +# it is set, below. The content of $() is evaluated in a sub-shell, so +# if `prefix` is set in the user's environment, the shell statements in +# $() won't clobbered it. +# +prefix_relto_examplesdir=$( +prefix=@prefix@ +examplesdir=@examplesdir@ +if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then + echo $(echo ${examplesdir##${prefix}/} | \ + sed -E 's,[^/]+,..,g') +else + echo $prefix +fi +) + # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-@prefix@}" +prefix="${prefix:-${prefix_relto_examplesdir}}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" -- cgit v0.12 From 1b01b6d60b515db4c45786151e192b70aba27597 Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 5 Nov 2019 15:13:02 -0600 Subject: Get the path to prefix right: needs a ../ to back out of subdirectory c/. --- examples/run-c-ex.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 82050a1..030d967 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -54,7 +54,7 @@ fi # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-${prefix_relto_examplesdir}}" +prefix="${prefix:-../${prefix_relto_examplesdir}}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" -- cgit v0.12 From 0b721858e46a317c370a24115032d5be41688f67 Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 5 Nov 2019 15:13:47 -0600 Subject: Make these scripts relocatable again: derive a relative path for the original installation prefix from the examples prefix. Use that relative path to locate the current installation prefix, always. Fall back to an absolute installation prefix if the relative path cannot be derived. --- c++/examples/run-c++-ex.sh.in | 25 ++++++++++++++++++++++++- fortran/examples/run-fortran-ex.sh.in | 25 ++++++++++++++++++++++++- hl/c++/examples/run-hlc++-ex.sh.in | 26 +++++++++++++++++++++++++- hl/examples/run-hlc-ex.sh.in | 25 ++++++++++++++++++++++++- 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/c++/examples/run-c++-ex.sh.in b/c++/examples/run-c++-ex.sh.in index d01cb7f..08e9633 100644 --- a/c++/examples/run-c++-ex.sh.in +++ b/c++/examples/run-c++-ex.sh.in @@ -30,9 +30,32 @@ EXIT_SUCCESS=0 EXIT_FAILURE=1 +# +# Try to derive the path to the installation $prefix established +# by ./configure relative to the examples directory established by +# ./configure. If successful, set `prefix_relto_examplesdir` to the +# relative path. Otherwise, set `prefix_relto_examplesdir` to the +# absolute installation $prefix. +# +# This script uses the value of `prefix` in the user's environment, if +# it is set, below. The content of $() is evaluated in a sub-shell, so +# if `prefix` is set in the user's environment, the shell statements in +# $() won't clobbered it. +# +prefix_relto_examplesdir=$( +prefix=@prefix@ +examplesdir=@examplesdir@ +if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then + echo $(echo ${examplesdir##${prefix}/} | \ + sed -E 's,[^/]+,..,g') +else + echo $prefix +fi +) + # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-@prefix@}" +prefix="${prefix:-../${prefix_relto_examplesdir}}" AR="@AR@" RANLIB="@RANLIB@" H5TOOL="h5c++" # The tool name diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in index 8ea4dc3..e2b444f 100644 --- a/fortran/examples/run-fortran-ex.sh.in +++ b/fortran/examples/run-fortran-ex.sh.in @@ -30,9 +30,32 @@ EXIT_SUCCESS=0 EXIT_FAILURE=1 +# +# Try to derive the path to the installation $prefix established +# by ./configure relative to the examples directory established by +# ./configure. If successful, set `prefix_relto_examplesdir` to the +# relative path. Otherwise, set `prefix_relto_examplesdir` to the +# absolute installation $prefix. +# +# This script uses the value of `prefix` in the user's environment, if +# it is set, below. The content of $() is evaluated in a sub-shell, so +# if `prefix` is set in the user's environment, the shell statements in +# $() won't clobbered it. +# +prefix_relto_examplesdir=$( +prefix=@prefix@ +examplesdir=@examplesdir@ +if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then + echo $(echo ${examplesdir##${prefix}/} | \ + sed -E 's,[^/]+,..,g') +else + echo $prefix +fi +) + # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-@prefix@}" +prefix="${prefix:-../${prefix_relto_examplesdir}}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" diff --git a/hl/c++/examples/run-hlc++-ex.sh.in b/hl/c++/examples/run-hlc++-ex.sh.in index 1e7ce10..e46534a 100644 --- a/hl/c++/examples/run-hlc++-ex.sh.in +++ b/hl/c++/examples/run-hlc++-ex.sh.in @@ -29,9 +29,33 @@ # Initializations EXIT_SUCCESS=0 EXIT_FAILURE=1 + +# +# Try to derive the path to the installation $prefix established +# by ./configure relative to the examples directory established by +# ./configure. If successful, set `prefix_relto_examplesdir` to the +# relative path. Otherwise, set `prefix_relto_examplesdir` to the +# absolute installation $prefix. +# +# This script uses the value of `prefix` in the user's environment, if +# it is set, below. The content of $() is evaluated in a sub-shell, so +# if `prefix` is set in the user's environment, the shell statements in +# $() won't clobbered it. +# +prefix_relto_examplesdir=$( +prefix=@prefix@ +examplesdir=@examplesdir@ +if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then + echo $(echo ${examplesdir##${prefix}/} | \ + sed -E 's,[^/]+,..,g') +else + echo $prefix +fi +) + # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-@prefix@}" +prefix="${prefix:-../../${prefix_relto_examplesdir}}" AR="@AR@" RANLIB="@RANLIB@" H5TOOL="h5c++" # The tool name diff --git a/hl/examples/run-hlc-ex.sh.in b/hl/examples/run-hlc-ex.sh.in index 1404fa4..ceb77dd 100644 --- a/hl/examples/run-hlc-ex.sh.in +++ b/hl/examples/run-hlc-ex.sh.in @@ -29,9 +29,32 @@ EXIT_SUCCESS=0 EXIT_FAILURE=1 +# +# Try to derive the path to the installation $prefix established +# by ./configure relative to the examples directory established by +# ./configure. If successful, set `prefix_relto_examplesdir` to the +# relative path. Otherwise, set `prefix_relto_examplesdir` to the +# absolute installation $prefix. +# +# This script uses the value of `prefix` in the user's environment, if +# it is set, below. The content of $() is evaluated in a sub-shell, so +# if `prefix` is set in the user's environment, the shell statements in +# $() won't clobbered it. +# +prefix_relto_examplesdir=$( +prefix=@prefix@ +examplesdir=@examplesdir@ +if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then + echo $(echo ${examplesdir##${prefix}/} | \ + sed -E 's,[^/]+,..,g') +else + echo $prefix +fi +) + # Where the tool is installed. # default is relative path to installed location of the tools -prefix="${prefix:-@prefix@}" +prefix="${prefix:-../../${prefix_relto_examplesdir}}" PARALLEL=@PARALLEL@ # Am I in parallel mode? AR="@AR@" RANLIB="@RANLIB@" -- cgit v0.12