summaryrefslogtreecommitdiffstats
path: root/HDF5Examples/configure.ac
blob: 80f0b6839e7b65d270d8ec279844d9dae804af01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure 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 files COPYING and Copyright.html.  COPYING can be found at the root
# of the source code distribution tree; Copyright.html can be found at the
# root level of an installed copy of the electronic HDF5 document set and
# is linked from the top-level documents page.  It can also be found at
# http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have
# access to either file, you may request a copy from help@hdfgroup.org.

AC_PREREQ(2.69)
AC_INIT(HDF5-examples, 0.1, help@hdfgroup.org)
dnl AM_INIT_AUTOMAKE takes a list of options that should be applied to
dnl every Makefile.am when automake is run.
AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config.h)

# Turn off automake rebuild rules so make doesn't try to run automake
# (which probably won't work).
AM_MAINTAINER_MODE

# Argument for static linking
AC_ARG_ENABLE(shared,
    [AS_HELP_STRING([--disable-shared],
        [force static linking])],
    [if test "$enableval" = "no"; then
        shared_suffix=""
        echo lo!
    else
        shared_suffix=" -shlib"
    fi],
    [shared_suffix=" -shlib"])

# Checks and sets HDF5 compiler wrappers.
if test "x$CC" = "x"; then
  H5C_exists=`h5cc -help > /dev/null 2>&1; echo $?`
  if test "x1" = "x$H5C_exists"; then
    H5C_valid=`h5cc -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
    if test "x1" = "x$H5C_valid"; then
      H5C="h5cc"
    fi
  else
    H5C_exists=`h5pcc > /dev/null 2>&1; echo $?`
    if test "x1" = "x$H5C_exists"; then
      H5C_valid=`h5pcc -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
      if test "x1" = "x$H5C_valid"; then
        H5C="h5pcc"
      else
        AC_MSG_ERROR(failed to find h5cc or h5pcc)
      fi
    else
      AC_MSG_ERROR(failed to find h5cc or h5pcc)
    fi
  fi
else
  H5C_exists=`$CC -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
  if test "x1" = "x$H5C_exists"; then
     H5C="$CC"
  else
     AC_MSG_ERROR(CC is not set to h5cc or h5pcc)
  fi
fi
AC_PROG_CC([$H5C])

if test "x$FC" = "x"; then
  H5FC_exists=`h5fc -help > /dev/null 2>&1; echo $?`
  if test "x1" = "x$H5FC_exists"; then
    H5FC_valid=`h5fc -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
    if test "x1" = "x$H5FC_valid"; then
      H5FC="h5fc"
    fi
  else
    H5FC_exists=`h5pfc > /dev/null 2>&1; echo $?`
    if test "x1" = "x$H5FC_exists"; then
      H5FC_valid=`h5pfc -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
      if test "x1" = "x$H5FC_valid"; then
        H5FC="h5pfc"
      else
        AC_MSG_ERROR(failed to find h5fc or h5pfc)
      fi
    else
      AC_MSG_ERROR(failed to find h5fc or h5pfc)
    fi
  fi
else
  H5FC_exists=`$FC -help | sed -E -n '1p' | sed -n "/h5/p" | wc -l | sed 's/ //g'`
  if test "1" = "$H5FC_exists"; then
     H5FC="$FC"
  else
     AC_MSG_ERROR(FC is not set to h5fc or h5pfc)
  fi
fi
AC_PROG_FC([$H5FC])

# Add the suffix to CC for shared linking.  Can't just set as an option
# because it must be first.
if test "$shared_suffix" && test ! `echo ${CC} | grep "$shared_suffix"`; then
    CC=${CC}${shared_suffix}
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

# Determine the version of the HDF5 Library
AC_MSG_CHECKING([the version of the HDF5 Library])

AC_SUBST([H5_LIBVER])
H5_LIBVER=$(${CC} -showconfig | grep -i "HDF5 Version:" | sed 's/^.* //g' | sed 's/[-].*//g')
AC_MSG_RESULT([$H5_LIBVER])

AC_MSG_CHECKING([the API mapping of the HDF5 Library])
AC_SUBST([H5_APIVER])
H5_APIVER=$(${CC} -showconfig | grep -i "Default API mapping:" | sed 's/^.* //g' | sed 's/v//g' | sed 's/1/1_/')
AC_MSG_RESULT([$H5_APIVER])

#if version is unreleased then bump to next official release.

H5_MAJORVER=$(echo $H5_LIBVER | cut -f1 -d'.'  | sed -E 's/\./_/g')
H5_MINORVER=$(echo $H5_LIBVER | cut -f2 -d'.'  | sed -E 's/\./_/g')
H5_RELEASEVER=$(echo $H5_LIBVER | cut -f3 -d'.'  | sed -E 's/\./_/g')

#used in fortran version checks
H5_VERS_MAJOR=$H5_MAJORVER
H5_VERS_MINOR=$H5_MINORVER
H5_VERS_RELEASE=$H5_RELEASEVER

AC_SUBST([H5_VERS_MAJOR])
AC_SUBST([H5_VERS_MINOR])
AC_SUBST([H5_VERS_RELEASE])

AC_SUBST([H5_LIBVER_DIR])
rem=$(( $H5_MINORVER % 2 ))
if test "$rem" != "0";then
 H5_MINORVER=$(($H5_MINORVER+1))
fi
H5_LIBVER_DIR=${H5_MAJORVER}${H5_MINORVER}

# Test whether one version ($1) is greater than or equal to other ($2).
function version_gt {
    test "`printf '%s\n' "$@" | sort -V | head -n 1`" != "$1";
}

if test ! "$H5EX_G" && test ! "$H5EX_D" && test ! "$H5EX_T";then
  H5EX_G=1
  H5EX_D=1
  H5EX_T=1
fi
AM_CONDITIONAL(H5G, test "$H5EX_G")
AM_CONDITIONAL(H5D, test "$H5EX_D")
AM_CONDITIONAL(H5T, test "$H5EX_T")

# Check if a Fortran 2003 compiler was used for h5fc
HAVE_FORTRAN_2003="no"

AC_MSG_CHECKING([if h5fc was compiled with Fortran 2003 enabled])

# if HDF5 version is 1.8 and HDF5 used a 2003 Fortran compiler.
if (${FC} -showconfig 2>&1 | grep 'Fortran 2003 Compiler: yes') > /dev/null; then
  HAVE_FORTRAN_2003="yes"
else
# check if HDF5 version is > 1.8
 if version_gt "$H5_LIBVER" "1.9.0"; then   
     HAVE_FORTRAN_2003="yes"
 fi
fi

AC_MSG_RESULT([$HAVE_FORTRAN_2003])

FORTRAN_2003_CONDITIONAL_F="X$HAVE_FORTRAN_2003"
AC_SUBST([FORTRAN_2003_CONDITIONAL_F])
AM_CONDITIONAL([FORTRAN_2003_CONDITIONAL_F], [test "X$HAVE_FORTRAN_2003" = "Xyes"])

# Check if we have Fortran 2003 and Intel compiler; Intel doesn't work with RECURSIVE used by h5ex_g_traverse.F90
# The example will not be built when Intel compiler is used (EIP 2011/10/14)

if test "X$HAVE_FORTRAN_2003" = "Xyes"; then
  HAVE_FORTRAN_2003_NOTINTEL="yes"
  AC_MSG_CHECKING([if h5fc is an Intel Fortran compiler])
  if (${FC} -showconfig 2>&1 | grep 'Intel(R) Fortran ') > /dev/null; then
    HAVE_FORTRAN_2003_NOTINTEL="no"
  fi
  if test "X$HAVE_FORTRAN_2003_NOTINTEL" = "Xyes"; then
    echo "no"
  else
    echo "yes"
  fi
fi
# End check if we have Fortran 2003 and Intel compiler.
AM_CONDITIONAL([FORTRAN_2003_NOTINTEL_CONDITIONAL_F], [test "X$HAVE_FORTRAN_2003_NOTINTEL" = "Xyes"])


# Set subdirectories
AC_CONFIG_FILES([Makefile
                 C/Makefile
                 C/H5D/Makefile
                 C/H5G/Makefile
                 C/H5T/Makefile
                 FORTRAN/Makefile
                 FORTRAN/H5D/h5_version.h
                 FORTRAN/H5D/Makefile
                 FORTRAN/H5G/Makefile
                 FORTRAN/H5T/Makefile
        ])

AC_CONFIG_FILES([C/H5D/test.sh], [chmod +x C/H5D/test.sh])
AC_CONFIG_FILES([C/H5G/test.sh], [chmod +x C/H5G/test.sh])
AC_CONFIG_FILES([C/H5T/test.sh], [chmod +x C/H5T/test.sh])
AC_CONFIG_FILES([FORTRAN/H5D/test.sh], [chmod +x FORTRAN/H5D/test.sh])
AC_CONFIG_FILES([FORTRAN/H5G/test.sh], [chmod +x FORTRAN/H5G/test.sh])
AC_CONFIG_FILES([FORTRAN/H5T/test.sh], [chmod +x FORTRAN/H5T/test.sh])

# Configure
AC_OUTPUT