From 86c7575f97d21a6351bf0ac965823df37d113cd3 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Wed, 17 Aug 2016 14:01:25 +0100 Subject: [PATCH 1/4] Use correct autotools variables in nc-config This was fixed in a previous commit for nc-config.cmake.in, but not for the autotools version --- nc-config.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) mode change 100644 => 100755 nc-config.in diff --git a/nc-config.in b/nc-config.in old mode 100644 new mode 100755 index 6c4cc8069..b964bcb80 --- a/nc-config.in +++ b/nc-config.in @@ -5,12 +5,14 @@ # contributed by netCDF user Arlindo DaSilva. Thanks Arlindo! prefix=@prefix@ -exec_prefix=${prefix} -includedir=${prefix}/include - +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ cc="@CC@" -cflags=" -I${includedir} @CPPFLAGS@" +cflags="-I${includedir} @CPPFLAGS@" +libs="-L${libdir} @NC_LIBS@" + has_dap="@HAS_DAP@" has_nc2="@HAS_NC2@" has_nc4="@HAS_NC4@" From a49816ad43e98a4222832d780d8ee9dcaada9af4 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Wed, 17 Aug 2016 14:03:38 +0100 Subject: [PATCH 2/4] Use libs variable instead of pkg-config pkg-config isn't used in the cmake version of nc-config, so probably shouldn't be used in autotools version either? --- nc-config.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nc-config.in b/nc-config.in index b964bcb80..b5006421c 100755 --- a/nc-config.in +++ b/nc-config.in @@ -205,7 +205,7 @@ while test $# -gt 0; do ;; --libs) - PKG_CONFIG_PATH=${prefix}/lib/pkgconfig pkg-config netcdf --libs + echo $libs ;; --prefix) From ce15b1cc2df8989ca706b3e381fa3fb3b35d94e1 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Wed, 17 Aug 2016 14:40:37 +0100 Subject: [PATCH 3/4] Add couple of missing flags to nc-config - Add --has-fortran, in addition to the specific --has-f90, --has-f03 - Add --libdir to print just the libdir - Also 'which nf-config' will spit out errors if nf-config is not found. Silence these errors --- nc-config.cmake.in | 18 +++++++++++++++--- nc-config.in | 19 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/nc-config.cmake.in b/nc-config.cmake.in index 09aeb8ed0..b11d7394c 100755 --- a/nc-config.cmake.in +++ b/nc-config.cmake.in @@ -79,11 +79,11 @@ has_fortran="no" has_f90="no" has_f03="no" -nfconf=$(which nf-config) +nfconf=$(which nf-config 2>/dev/null) if [ -f "$nfconf" ]; then - echo "Using nf-config: $nfconf" - has_fortran="yes" + echo "Using nf-config: $nfconf" + has_fortran="yes" fc=`nf-config --fc` fflags=`nf-config --fflags` flibs=`nf-config --flibs` @@ -112,6 +112,7 @@ Available values for OPTION include: --all display all options --cc C compiler --cflags pre-processor and compiler flags + --has-fortran whether Fortran API is installed --has-dap whether OPeNDAP is enabled in this build --has-nc2 whether NetCDF-2 API is enabled --has-nc4 whether NetCDF-4/HDF-5 is enabled in this build @@ -123,6 +124,7 @@ Available values for OPTION include: --libs library linking information for netcdf --prefix Install prefix --includedir Include directory + --libdir Library directory --version Library version EOF @@ -171,6 +173,7 @@ all() echo " --cxx4 -> $cxx4" echo + echo " --has-fortran-> $has_fortran" if [ -f "$nfconf" ]; then echo " --fc -> $fc" echo " --fflags -> $fflags" @@ -190,6 +193,7 @@ fi echo echo " --prefix -> $prefix" echo " --includedir-> $includedir" + echo " --libdir -> $libdir" echo " --version -> $version" echo } @@ -269,6 +273,10 @@ while test $# -gt 0; do echo "${includedir}" ;; + --libdir) + echo "${libdir}" + ;; + --version) echo $version ;; @@ -297,6 +305,10 @@ while test $# -gt 0; do # echo $cxxlibs # ;; + --has-fortran) + echo $has_fortran + ;; + --fc) echo $fc ;; diff --git a/nc-config.in b/nc-config.in index b5006421c..74cee44ff 100755 --- a/nc-config.in +++ b/nc-config.in @@ -26,11 +26,11 @@ has_fortran="no" has_f90="no" has_f03="no" -nfconf=$(which nf-config) +nfconf=$(which nf-config 2>/dev/null) if [ -f "$nfconf" ]; then - echo "Using nf-config: $nfconf" - has_fortran="yes" + echo "Using nf-config: $nfconf" + has_fortran="yes" fc=`nf-config --fc` fflags=`nf-config --fflags` flibs=`nf-config --flibs` @@ -59,6 +59,7 @@ Available values for OPTION include: --all display all options --cc C compiler --cflags pre-processor and compiler flags + --has-fortran whether Fortran API is installed --has-dap whether OPeNDAP is enabled in this build --has-nc2 whether NetCDF-2 API is enabled --has-nc4 whether NetCDF-4/HDF-5 is enabled in this build @@ -70,6 +71,7 @@ Available values for OPTION include: --libs library linking information for netcdf --prefix Install prefix --includedir Include directory + --libdir Library directory --version Library version EOF @@ -118,6 +120,7 @@ all() echo " --cxx4 -> $cxx4" echo + echo " --has-fortran-> $has_fortran" if [ -f "$nfconf" ]; then echo " --fc -> $fc" echo " --fflags -> $fflags" @@ -137,6 +140,7 @@ fi echo echo " --prefix -> $prefix" echo " --includedir-> $includedir" + echo " --libdir -> $libdir" echo " --version -> $version" echo } @@ -216,6 +220,10 @@ while test $# -gt 0; do echo "${includedir}" ;; + --libdir) + echo "${libdir}" + ;; + --version) echo $version ;; @@ -236,6 +244,11 @@ while test $# -gt 0; do echo $cxx4 ;; + + --has-fortran) + echo $has_fortran + ;; + --fc) echo $fc ;; From 6c028fbf5c40f312063e06234f672715950c0a52 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Wed, 17 Aug 2016 14:45:40 +0100 Subject: [PATCH 4/4] Get C++ flags from ncxx{4}-config --- nc-config.cmake.in | 51 +++++++++++++++++++++++++++++++--------------- nc-config.in | 44 +++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 25 deletions(-) diff --git a/nc-config.cmake.in b/nc-config.cmake.in index b11d7394c..a07e85b5d 100755 --- a/nc-config.cmake.in +++ b/nc-config.cmake.in @@ -95,9 +95,13 @@ has_cxx="no" has_cxx4="no" if type -p ncxx4-config > /dev/null 2>&1; then cxx4=`ncxx4-config --cxx` + cxx4flags=`ncxx4-config --cflags` + cxx4libs=`ncxx4-config --libs` has_cxx4="yes" elif type -p ncxx-config > /dev/null 2>&1; then cxx=`ncxx-config --cxx` + cxxflags=`ncxx-config --cflags` + cxxlibs=`ncxx-config --libs` has_cxx="yes" fi @@ -112,6 +116,8 @@ Available values for OPTION include: --all display all options --cc C compiler --cflags pre-processor and compiler flags + --has-c++ whether C++ API is installed + --has-c++4 whether netCDF-4 C++ API is installed --has-fortran whether Fortran API is installed --has-dap whether OPeNDAP is enabled in this build --has-nc2 whether NetCDF-2 API is enabled @@ -128,19 +134,17 @@ Available values for OPTION include: --version Library version EOF -# When supported by ncxx4-config and ncxx-config, add -# --cxxflags flags needed to compile a netCDF-4 C++ program -# --cxxlibs libraries needed to link a netCDF-4 C++ program if type -p ncxx4-config > /dev/null 2>&1; then cat < /dev/null 2>&1; then cat < $has_cxx" echo " --cxx -> $cxx" -# echo " --cxxflags -> $cxxflags" -# echo " --cxxlibs -> $cxxlibs" +if type -p ncxx-config > /dev/null 2>&1; then + echo " --cxxflags -> $cxxflags" + echo " --cxxlibs -> $cxxlibs" +fi + echo echo " --has-c++4 -> $has_cxx4" echo " --cxx4 -> $cxx4" +if type -p ncxx4-config > /dev/null 2>&1; then + echo " --cxx4flags -> $cxx4flags" + echo " --cxx4libs -> $cxx4libs" +fi echo echo " --has-fortran-> $has_fortran" @@ -289,6 +300,14 @@ while test $# -gt 0; do echo $cxx ;; + --cxxflags) + echo $cxxflags + ;; + + --cxxlibs) + echo $cxxlibs + ;; + --has-c++4) echo $has_cxx4 ;; @@ -297,13 +316,13 @@ while test $# -gt 0; do echo $cxx4 ;; -# --cxxflags) -# echo $cxxflags -# ;; -# -# --cxxlibs) -# echo $cxxlibs -# ;; + --cxx4flags) + echo $cxx4flags + ;; + + --cxx4libs) + echo $cxx4libs + ;; --has-fortran) echo $has_fortran diff --git a/nc-config.in b/nc-config.in index 74cee44ff..339ec3d83 100755 --- a/nc-config.in +++ b/nc-config.in @@ -42,9 +42,13 @@ has_cxx="no" has_cxx4="no" if type -p ncxx4-config > /dev/null 2>&1; then cxx4=`ncxx4-config --cxx` + cxx4flags=`ncxx4-config --cflags` + cxx4libs=`ncxx4-config --libs` has_cxx4="yes" elif type -p ncxx-config > /dev/null 2>&1; then cxx=`ncxx-config --cxx` + cxxflags=`ncxx-config --cflags` + cxxlibs=`ncxx-config --libs` has_cxx="yes" fi @@ -59,6 +63,8 @@ Available values for OPTION include: --all display all options --cc C compiler --cflags pre-processor and compiler flags + --has-c++ whether C++ API is installed + --has-c++4 whether netCDF-4 C++ API is installed --has-fortran whether Fortran API is installed --has-dap whether OPeNDAP is enabled in this build --has-nc2 whether NetCDF-2 API is enabled @@ -75,19 +81,17 @@ Available values for OPTION include: --version Library version EOF -# When supported by ncxx4-config and ncxx-config, add -# --cxxflags flags needed to compile a netCDF-4 C++ program -# --cxxlibs libraries needed to link a netCDF-4 C++ program if type -p ncxx4-config > /dev/null 2>&1; then cat < /dev/null 2>&1; then cat < $has_cxx" echo " --cxx -> $cxx" -# echo " --cxxflags -> $cxxflags" -# echo " --cxxlibs -> $cxxlibs" +if type -p ncxx-config > /dev/null 2>&1; then + echo " --cxxflags -> $cxxflags" + echo " --cxxlibs -> $cxxlibs" +fi + echo echo " --has-c++4 -> $has_cxx4" echo " --cxx4 -> $cxx4" +if type -p ncxx4-config > /dev/null 2>&1; then + echo " --cxx4flags -> $cxx4flags" + echo " --cxx4libs -> $cxx4libs" +fi echo echo " --has-fortran-> $has_fortran" @@ -236,6 +247,14 @@ while test $# -gt 0; do echo $cxx ;; + --cxxflags) + echo $cxxflags + ;; + + --cxxlibs) + echo $cxxlibs + ;; + --has-c++4) echo $has_cxx4 ;; @@ -244,6 +263,13 @@ while test $# -gt 0; do echo $cxx4 ;; + --cxx4flags) + echo $cxx4flags + ;; + + --cxx4libs) + echo $cxx4libs + ;; --has-fortran) echo $has_fortran