1#! /bin/sh
2#
3# This forms the basis for the nf-config utility, which tells you
4# various things about the netCDF fortran installation.
5
6prefix=@prefix@
7exec_prefix=@exec_prefix@
8libdir=@libdir@
9includedir=@includedir@
10fmoddir=@fmoddir@
11
12cc="@CC@"
13fc="@FC@"
14cflags="-I${includedir} @CPPFLAGS@"
15fflags="-I${includedir} @MOD_FLAG@${fmoddir}"
16has_dap="@HAS_DAP@"
17has_nc2="@HAS_NC2@"
18has_nc4="@HAS_NC4@"
19has_f90="@HAS_F90@"
20has_f03="@HAS_F03@"
21flibs="-L${libdir} @NC_FLIBS@"
22version="@PACKAGE_NAME@ @PACKAGE_VERSION@"
23
24usage()
25{
26    cat <<EOF
27Usage: nf-config [OPTION]
28
29Available values for OPTION include:
30
31  --help        display this help message and exit
32  --all         display all options
33  --cc          C compiler
34  --fc          Fortran compiler
35  --cflags      pre-processor and compiler flags
36  --fflags      flags needed to compile a Fortran program
37  --has-dap     whether OPeNDAP is enabled in this build
38  --has-nc2     whether NetCDF-2 API is enabled
39  --has-nc4     whether NetCDF-4/HDF-5 is enabled in this build
40  --has-f90     whether Fortran 90 API is enabled in this build
41  --has-f03     whether Fortran 2003 API is enabled in this build
42  --flibs       libraries needed to link a Fortran program
43  --prefix      Install prefix
44  --includedir  Include directory
45  --version     Library version
46
47EOF
48
49    exit $1
50}
51
52all()
53{
54        echo
55        echo "This $version has been built with the following features: "
56        echo
57        echo "  --cc        -> $cc"
58        echo "  --cflags    -> $cflags"
59        echo
60        echo "  --fc        -> $fc"
61        echo "  --fflags    -> $fflags"
62        echo "  --flibs     -> $flibs"
63        echo "  --has-f90   -> $has_f90"
64        echo "  --has-f03   -> $has_f03"
65        echo
66        echo "  --has-nc2   -> $has_nc2"
67        echo "  --has-nc4   -> $has_nc4"
68	echo
69        echo "  --prefix    -> $prefix"
70        echo "  --includedir-> $includedir"
71        echo "  --version   -> $version"
72        echo
73}
74
75if test $# -eq 0; then
76    usage 1
77fi
78
79while test $# -gt 0; do
80    case "$1" in
81    # this deals with options in the style
82    # --option=value and extracts the value part
83    # [not currently used]
84    -*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
85    *) value= ;;
86    esac
87
88    case "$1" in
89
90    --help)
91	usage 0
92	;;
93
94    --all)
95	all
96	;;
97
98    --cc)
99	echo $cc
100	;;
101
102    --fc)
103	echo $fc
104	;;
105
106    --cflags)
107	echo $cflags
108	;;
109
110    --fflags)
111	echo $fflags
112	;;
113
114    --has-dap)
115       	echo $has_dap
116       	;;
117
118    --has-nc2)
119       	echo $has_nc2
120       	;;
121
122    --has-nc4)
123       	echo $has_nc4
124       	;;
125
126    --has-f90)
127       	echo $has_f90
128       	;;
129
130    --has-f03)
131       	echo $has_f03
132       	;;
133
134    --flibs)
135       	echo $flibs
136       	;;
137
138    --prefix)
139       	echo "${prefix}"
140       	;;
141
142    --includedir)
143       	echo "${includedir}"
144       	;;
145
146    --version)
147	echo $version
148	;;
149
150    *)
151        echo "unknown option: $1"
152	usage
153	exit 1
154	;;
155    esac
156    shift
157done
158
159exit 0
160