From 82f647534c309ff97e4827fb95949954aeed4a26 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 3 Oct 2019 17:30:46 -0500 Subject: Make some NetBSD compatibility patches. --- 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 +- c++/examples/Makefile.am | 4 +-- c++/examples/run-c++-ex.sh.in | 4 +-- config/netbsd | 56 ++++++++++++++++++++++++++++++ configure.ac | 29 ++++++++++++++++ examples/Makefile.am | 4 +-- examples/run-c-ex.sh.in | 4 +-- fortran/examples/Makefile.am | 4 +-- fortran/examples/run-fortran-ex.sh.in | 4 +-- hl/c++/examples/Makefile.am | 4 +-- hl/c++/examples/run-hlc++-ex.sh.in | 4 +-- hl/examples/Makefile.am | 4 +-- hl/examples/run-hlc-ex.sh.in | 4 +-- hl/fortran/examples/Makefile.am | 4 +-- hl/fortran/examples/run-hlfortran-ex.sh.in | 4 +-- src/H5private.h | 19 +++++++++- test/accum.c | 8 ++++- tools/test/h5jam/testh5jam.sh.in | 4 +-- 29 files changed, 162 insertions(+), 40 deletions(-) create mode 100644 config/netbsd 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 7ab741c..821d78c 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 4de2dbd..8316393 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 9712b59..f196b85 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 = ""; ############################################################################## 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 d975924..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 # @@ -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/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 279c443..cb17e53 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 ;; @@ -2788,7 +2791,33 @@ fi ## Direct VFD files are not built if not required. AM_CONDITIONAL([DIRECT_VFD_CONDITIONAL], [test "X$DIRECT_VFD" = "Xyes"]) +## Checkpoint the cache +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 8c6540f..c07b52b 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 209cdd7..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. # @@ -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/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 da0c357..7490d0e 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 # @@ -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/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 eb688a1..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 # @@ -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/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 f51b165..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. # @@ -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/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 5f12ef0..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 # @@ -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/src/H5private.h b/src/H5private.h index 9506497..8d90fdc 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -335,6 +335,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])) @@ -1628,9 +1636,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) \ diff --git a/test/accum.c b/test/accum.c index 91786a9..d453121 100644 --- a/test/accum.c +++ b/test/accum.c @@ -1825,7 +1825,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 */ @@ -1954,6 +1953,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)); 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