summaryrefslogtreecommitdiffstats
path: root/bin/buildhdf5
blob: fe39b0ae603c813f202ab9251bd2e126fc47477c (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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/bin/sh
##
# 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.
##
# Build HDF5 library by doing configure, make, and tests.
# Usage: See USAGE()
# Programmer: Albert Cheng
# Creation date: Jul  9, 2003

# Some handy definitions
USAGE()
{
cat <<EOF
Buildhdf5 builds the HDF5 library by running configure, make and make check.
It skips the configure part if one has been done already.  In effect, one
can continue from a previous build.

Command Syntax
==============
buildhdf5 [-config] [-gass] [-srcdir dir] config-arguments ...
   -config:	run configure only. [default to do build too]
   -gass:	configure for the GASS driver
   -help:	show this help page
   -n:   	no execution, just show commands
   -srcdir:	use dir as the source directory
             	   [Note: this is different from --srcdir
             	    which will be passed to configure]
   all other arguments are passed to configure


Configure in place or by srcdir
===============================
By default, the command looks for the configure command in
'.' and then '../hdf5'.  When it finds it, it uses it to do
the configure part.  In effect, if ./configure is found, it
does the build in place.  If it finds ../hdf5/configure, it
does the --srcdir (that is separated source) build.  Therefore,
if you have the following structure setup, you can run multiple
hosts building simultantously using a common source code.
     hdf5_1.4/hdf5        # holds the source
	  .../arabica     # for SunOS 2.7
	  .../arabicapp   # for SunOS 2.7 parallel
	  .../burrwhite   # for Linux 2.4
EOF
}


TIMESTAMP()
{
    echo "=====" "`date`" "====="
}


QUIT()
{
    TIMESTAMP
}


# Do one step bracketed with time stamps
# The '< /dev/null' is needed to prevent some applications like MPI
# jobs blocked for reading when they read stdin unnecessary.
STEP()
{
    banner="$1"
    command="$2"
    resultfile="$3"

    echo "$banner"
    (TIMESTAMP; nerror=0 ;
	echo "eval $command"
	eval $command || nerror=1 ;
	TIMESTAMP; exit $nerror) < /dev/null >> "$resultfile" 2>&1
    if [ $? -ne 0 ]; then
	echo "error in '$banner'.  buildhdf5 aborted."
	exit 1
    fi
}


# Try locate the HDF4 library
# This is a hack because there is no consistent place to find
# the valid HDF library.
LOCATE_HDF4()
{
    OS=`uname -s`
    echo OS=$OS
    case "$OS" in
	HP-UX)
	    h4paths="/afs/ncsa/packages/hdf/HPUX_10.20"
	    ;;
	IRIX)
	    h4paths="/afs/ncsa/packages/hdf/4.1r3_irix"
	    ;;
	IRIX64)
	    case "$CC" in
	    *-n32)
		h4paths="/afs/ncsa/packages/hdf/IRIX64-n32_6.5"
		;;
	    *)
		h4paths="/afs/ncsa/packages/hdf/IRIX64_6.5"
		;;
	    esac
	    ;;
	Linux)
	    h4paths="/afs/ncsa/packages/hdf/linux"
	    ;;
	OSF1)
	    h4paths="/afs/ncsa/packages/hdf/OSF1_V4.0"
	    ;;
	*)
	    h4paths="/usr/ncsa /usr/sdt"
	    ;;
    esac
    echo $h4paths
    for h4 in $h4paths; do
	if [ -f $h4/lib/libdf.a -a -f $h4/include/hdf.h ]; then
	    WITH_H4="--with-hdf4=$h4/include,$h4/lib"
	    break
	fi
    done
    echo WITH_H4="$WITH_H4"
}


# Try locate the Fortran compiler
# This is a hack because there is no consistent fortran compiler name
LOCATE_FORTRAN()
{
    OS=`uname -s`
    echo OS=$OS
    case "$OS" in
	IRIX64)
	    case "$CC" in
	    *-n32)
		gasspaths=/usr/local/globus-install-1.1.1/development/mips-sgi-irix6.5-n32_nothreads_standard_debug
		sslpaths=/usr/local/ssl-n32
		;;
	    *)
		gasspaths=/usr/local/globus-install-1.1.1/development/mips-sgi-irix6.5-64_nothreads_standard_debug
		sslpaths=/usr/local/ssl
		;;
	    esac
	    ;;
	*)
	    ;;
    esac
    echo gasspaths=$gasspaths
    echo $sslpaths=$sslpaths
    for x in $gasspaths dummy; do
	if [ $x != dummy -a -f $x/lib/libglobus_gass_cache.a ]; then
	   WITH_GASS="--with-gass=$x/include,$x/lib"
	   break
	fi
    done
    for x in $sslpaths dummy; do
	if [ $x != dummy -a -f $x/lib/libssl.a ]; then
	   WITH_SSL="--with-ssl=$x/lib"
	   break
	fi
    done

    echo WITH_GASS="$WITH_GASS"
    echo WITH_SSL="$WITH_SSL"

}


# Try locate the GASS software library
# This is a hack because there is no consistent place to find
# the valid HDF library.
LOCATE_GASS()
{
    OS=`uname -s`
    echo OS=$OS
    case "$OS" in
	IRIX64)
	    case "$CC" in
	    *-n32)
		gasspaths=/usr/local/globus-install-1.1.1/development/mips-sgi-irix6.5-n32_nothreads_standard_debug
		sslpaths=/usr/local/ssl-n32
		;;
	    *)
		gasspaths=/usr/local/globus-install-1.1.1/development/mips-sgi-irix6.5-64_nothreads_standard_debug
		sslpaths=/usr/local/ssl
		;;
	    esac
	    ;;
	*)
	    ;;
    esac
    echo gasspaths=$gasspaths
    echo $sslpaths=$sslpaths
    for x in $gasspaths dummy; do
	if [ $x != dummy -a -f $x/lib/libglobus_gass_cache.a ]; then
	   WITH_GASS="--with-gass=$x/include,$x/lib"
	   break
	fi
    done
    for x in $sslpaths dummy; do
	if [ $x != dummy -a -f $x/lib/libssl.a ]; then
	   WITH_SSL="--with-ssl=$x/lib"
	   break
	fi
    done

    echo WITH_GASS="$WITH_GASS"
    echo WITH_SSL="$WITH_SSL"

}


# Configure.  Default to do --srcdir.
CONFIG()
{
    CMD="$SRCDIR/configure $*"
    echo $CMD
    if [ "$NOEXEC" != 'noexec' ]; then
	$CMD
    else
	true		# set exit code as 0
    fi
}

# Main body
TIMESTAMP
trap QUIT 0

#
# setup
#
MAKE=${MAKE:-'gmake'}
export MAKE
CONFIGURE="CONFIG"
CONFIG_ONLY=no		# default is configure and build
NOEXEC=			# default to execute commands
SRCDIRLIST=". ../hdf5"  # places to look for configure
nerror=0

# parse some options
while [ $# -gt 0 ]; do
    case "$1" in
	-config)
	    # do configure only
	    CONFIG_ONLY=yes
	    ;;
	-gass)
	    LOCATE_GASS
	    ;;
	-help)
	    USAGE
	    exit 0
	    ;;
	-n)
	    NOEXEC='noexec'
	    ;;
	-srcdir)
	    shift
	    SRCDIRLIST="$1"
	    ;;
	*)	# Quit parsing
	    break
	    ;;
    esac
    shift
done
	    
# Figure out if srcdir is wished.
# Make sure we are at the library root level
# by checking couple typical files.  Not bullet-proof.
for SRCDIR in $SRCDIRLIST dummy; do
    if [ x-$SRCDIR = x-dummy ]; then
	break
    fi
    if [ -d $SRCDIR/src -a -d $SRCDIR/config -a -f $SRCDIR/configure ]
    then
	break
    fi
done

if [ x-$SRCDIR = x-dummy ]; then
    echo "Could not find the source dir or configure script.  Abort."
    exit 1
fi

# Configure
# no configure if already done.
if [ ! -f config.status ]; then
    CONFIGURE="$CONFIGURE $WITH_SSL $WITH_GASS"
    STEP "Configure HDF5..." "$CONFIGURE $*" "#config"
else
    STEP "Confiugre Skipped" "echo Confiugre Skipped" "#config"
fi

if [ x-$CONFIG_ONLY = x-yes ]; then
    exit 0
fi


# Compile
STEP "Make HDF5..." "$MAKE" "#make"

# Tests
STEP "Testing HDF5..." "$MAKE check" "#test"

# all done
echo "No Errors encountered"
TIMESTAMP