-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
609 lines (540 loc) · 19.2 KB
/
configure.ac
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
## Process this file with autoconf to produce a configure script.
##
## This file is part of h5tuner. The full h5tuner copyright notice,
## including terms governing use, modification, and redistribution, is
## contained in the file COPYING, which can be found at the root of the
## source code distribution tree. If you do not have access to this file,
## you may request a copy from [email protected].
##
##
##
## Initialize configure.
##
AC_PREREQ(2.69)
## AC_INIT takes the name of the package, the version number, and an
## email address to report bugs. AC_CONFIG_SRCDIR takes a unique file
## as its argument.
##
## NOTE: Do not forget to change the version number here when we do a
## release!!!
##
AC_INIT(autotuner, 0.1.1, [email protected])
AC_CONFIG_SRCDIR([src/autotuner_hdf5.c])
AC_CONFIG_HEADERS([src/autotuner.h])
AC_CONFIG_MACRO_DIR([m4])
## AM_INIT_AUTOMAKE takes a list of options that should be applied to
## every Makefile.am when automake is run.
AM_INIT_AUTOMAKE
AM_SILENT_RULES([yes])
## AM_MAINTAINER_MODE turns off "rebuild rules" that contain dependencies
## for Makefiles, configure, src/H5config.h, etc. If AM_MAINTAINER_MODE
## is enabled, these files will be rebuilt if out of date. This is a
## problem because if users try to build on a machine with
## the wrong versions of autoconf and automake, these files will be
## rebuilt with the wrong versions and bad things can happen.
## Also, CVS doesn't preserve dependencies between timestamps, so
## Makefiles will often think rebuilding needs to occur when it doesn't.
##
## By default, it is enabled. Users can configure with
## --disable-maintainer-mode to prevent running the autotools.
AM_MAINTAINER_MODE([enable])
## ----------------------------------------------------------------------
## Set prefix default (install directory) to a directory in the build area.
## This allows multiple src-dir builds within one host.
AC_PREFIX_DEFAULT([`pwd`/h5tuner])
AC_PROG_CC
## H5_CFLAGS (and company) are used by HDF5 for flags not exported to h5cc.
## That's not necessary here, but using them will allow copying the config
## files from HDF5 without modification.
AC_SUBST([H5_CFLAGS])
AC_SUBST([H5_CPPFLAGS])
AC_SUBST([H5_LDFLAGS])
## AM_CFLAGS (and company) are for CFLAGS that should be used on h5tuner
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CFLAGS_SHARED])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([AM_LDFLAGS_SHARED])
AC_SUBST([AM_ADDFLAGS])
AC_SUBST([AM_ADDFLAGS_SHARED])
AC_SUBST([AM_LIBS])
AC_SUBST([AM_MXML_LIB])
AC_SUBST([AM_HDF5_LIB])
AC_SUBST([AM_MPI_LIB])
## Make sure flags are initialized.
AM_CFLAGS="${AM_CFLAGS}"
AM_CPPFLAGS="${AM_CPPFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS}"
CFLAGS="${CFLAGS}"
CPPFLAGS="${CPPFLAGS}"
LDFLAGS="${LDFLAGS}"
## Configure may need to alter any of the *FLAGS variables in order for
## various checks to work correctly. Save the user's value here so it
## can be restored once all configure checks are complete.
saved_user_CFLAGS="$CFLAGS"
saved_user_FCFLAGS="$FCFLAGS"
saved_user_CPPFLAGS="$CPPFLAGS"
## Detect OS from shell
OS=`uname`
if test $OS = Darwin; then
dnl On MacOS
AM_LIBS="-lpthread -lz"
else
dnl set for Linux
AM_LIBS="-lpthread -lrt -lz"
fi
## ----------------------------------------------------------------------
## Dump all shell variables values.
##
AC_MSG_CHECKING([shell variables initial values])
set >&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([done])
## set some flag values. These may be moved to platform specific config
## files later.
AM_CFLAGS="-I . -I${MPIROOT}/include -I${MXMLROOT}/include -I${HDF5ROOT}/include"
AM_CFLAGS_SHARED="-I . -I${MPIROOT}/include -I${MXMLROOT}/include -I${HDF5ROOT}/include -g -shared -fpic -DPIC"
AM_LDFLAGS=
AM_LDFLAGS_SHARED=-ldl
AM_MXML_LIB="-L${MXMLROOT}/lib/ -lmxml"
AM_HDF5_LIB="-L${HDF5ROOT}/lib -lhdf5"
AM_MPI_LIB="-L${MPIROOT}/lib -lmpich"
AM_ADDFLAGS=-DDEBUG
AM_ADDFLAGS_SHARED=-DDEBUG
## ----------------------------------------------------------------------
## Some platforms have broken basename, and/or xargs programs. Check
## that it actually does what it's supposed to do. Catch this early
## since configure and scripts relies upon them heavily and there's
## no use continuing if it's broken.
##
AC_MSG_CHECKING([if basename works])
BASENAME_TEST="`basename /foo/bar/baz/qux/basename_works`"
if test $BASENAME_TEST != "basename_works"; then
AC_MSG_ERROR([basename program doesn't work])
else
AC_MSG_RESULT([yes])
fi
## xargs basename used in configure to get the CC_BASENAME value
AC_MSG_CHECKING([if xargs works])
XARGS_TEST="`echo /foo/bar/baz/qux/xargs_works | xargs basename`"
if test $XARGS_TEST != "xargs_works"; then
AC_MSG_ERROR([xargs program doesn't work])
else
AC_MSG_RESULT([yes])
fi
## ----------------------------------------------------------------------
## Check that the cache file was build on the same host as what we're
## running on now.
##
AC_CACHE_CHECK([for cached host], [hdf5_cv_host], [hdf5_cv_host="none"]);
if test $hdf5_cv_host = "none"; then
hdf5_cv_host=$host
elif test $hdf5_cv_host != $host; then
echo "The config.cache file was generated on $hdf5_cv_host but"
echo "this is $host. Please remove that file and try again."
AC_MSG_ERROR([config.cache file is invalid])
fi
## ----------------------------------------------------------------------
## Source any special files that we need. These files normally aren't
## present but can be used by the maintainers to fine tune things like
## turning on debug or profiling flags for the compiler. The search order
## is:
##
## CPU-VENDOR-OS
## VENDOR-OS
## CPU-OS
## CPU-VENDOR
## OS
## VENDOR
## CPU
##
## If the `OS' ends with a version number then remove it. For instance,
## `freebsd3.1' would become `freebsd'
case $host_os in
aix*)
host_os_novers=aix
;;
freebsd*)
host_os_novers=freebsd
;;
solaris*)
host_os_novers=solaris
;;
*)
host_os_novers=$host_os
;;
esac
host_config="none"
for f in $host_cpu-$host_vendor-$host_os \
$host_cpu-$host_vendor-$host_os_novers \
$host_vendor-$host_os \
$host_vendor-$host_os_novers \
$host_cpu-$host_os \
$host_cpu-$host_os_novers \
$host_cpu-$host_vendor \
$host_os \
$host_os_novers \
$host_vendor \
$host_cpu ; do
AC_MSG_CHECKING([for config $f])
if test -f "$srcdir/config/$f"; then
host_config=$srcdir/config/$f
AC_MSG_RESULT([found])
break
fi
AC_MSG_RESULT([no])
done
if test "X$host_config" != "Xnone"; then
CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
. $host_config
fi
## Source any special site-specific file
hname="`hostname`"
while test -n "$hname"; do
file=$srcdir/config/site-specific/host-$hname
AC_MSG_CHECKING([for config $file])
if test -f "$file"; then
. $file
AC_MSG_RESULT([found])
break
fi
AC_MSG_RESULT([no])
hname_tmp=$hname
hname="`echo $hname | cut -d. -f2-99`"
test "$hname_tmp" = "$hname" && break
done
## ----------------------------------------------------------------------
## Determine build mode (debug, production, clean).
## This has to be done early since the build mode is referred to
## frequently.
##
AC_MSG_CHECKING([build mode])
AC_ARG_ENABLE([build-mode],
[AS_HELP_STRING([--enable-build-mode=(debug|production|clean)],
[Sets the build mode. Debug turns on symbols, API
tracing, asserts, and debug optimization,
as well as several other minor configure options
that aid in debugging.
Production turns high optimizations on.
Clean turns nothing on and disables optimization
(i.e.: a 'clean slate' configuration).
All these settings can be overridden by using
specific configure flags.
[default=clean]
])],
[BUILD_MODE=$enableval])
## Set the default
## Depends on branch, set via script at branch creation time
if test "X-$BUILD_MODE" = X- ; then
BUILD_MODE=clean
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([BUILD_MODE])
case "X-$BUILD_MODE" in
X-clean)
AC_MSG_RESULT([clean])
;;
X-debug)
AC_DEFINE([DEBUG_BUILD], [1], [Define if this is a debug build.])
H5_CFLAGS="$H5_CFLAGS $DEBUG_CFLAGS"
H5_CPPFLAGS="$H5_CPPFLAGS $DEBUG_CPPFLAGS"
AC_MSG_RESULT([debug])
;;
X-production)
H5_CFLAGS="$H5_CFLAGS $PROD_CFLAGS"
H5_CPPFLAGS="$H5_CPPFLAGS $PROD_CPPFLAGS"
AC_MSG_RESULT([production])
;;
*)
AC_MSG_ERROR([Unrecognized build mode: $BUILD_MODE. Use debug, production, or clean.])
esac
## ----------------------------------------------------------------------
## Some built-in configure checks can only see CFLAGS (not AM_CFLAGS), so
## we need to add this in so configure works as intended. We will need to
## reset this value at the end of configure, to preserve the user's settings.
CFLAGS="${AM_CFLAGS} ${CFLAGS}"
CPPFLAGS="${AM_CPPFLAGS} ${CPPFLAGS}"
LDFLAGS="${AM_LDFLAGS} ${LDFLAGS}"
## ----------------------------------------------------------------------
## Enable dependency tracking unless the configure options or a
## site-specific file told us not to. This prevents configure from
## silently disabling dependencies for some compilers.
##
if test -z "${enable_dependency_tracking}"; then
enable_dependency_tracking="yes"
fi
## ----------------------------------------------------------------------
## Check for programs.
##
AC_PROG_CC
CC_BASENAME="`echo $CC | cut -f1 -d' ' | xargs basename 2>/dev/null`"
## Need to add the AM_ and H5_ into CFLAGS/CPPFLAGS to make them visible
## for configure checks.
## Note: Both will be restored by the end of configure.
CPPFLAGS="$H5_CPPFLAGS $AM_CPPFLAGS $CPPFLAGS"
CFLAGS="$H5_CFLAGS $AM_CFLAGS $CFLAGS"
## Checkpoint the cache
AC_CACHE_SAVE
## RUNSERIAL -- This is a command which will be prepended to
## the executable name to run the executable using
## a single process. For serial versions of the
## library this will normally be empty. For parallel
## versions it might be something like `mpiexec -n 1'.
## The value of this variable is substituted in *.in
## files.
##
## RUNPARALLEL -- This is a command which will be prepended to
## the executable name to run the executable on
## multiple processors. For the serial library the
## value will normally be the empty string. For
## parallel library it should be something like
## "mpiexec -n \$\${NPROCS:=6}" where NPROCS will
## eventually contain the number of processors on which
## to run the executable (the double dollarsigns are to
## protect the expansion until make executes the
## command). The value of this variable is
## substituted in *.in files.
##
AC_SUBST([RUNSERIAL])
AC_SUBST([RUNPARALLEL])
## ----------------------------------------------------------------------
## Create libtool. If shared/static libraries are going to be enabled
## or disabled, it should happen before these macros.
LT_PREREQ([2.2])
LT_INIT([dlopen])
## ----------------------------------------------------------------------
## Check if the compiler should include symbols
##
AC_MSG_CHECKING([enable debugging symbols])
AC_ARG_ENABLE([symbols],
[AS_HELP_STRING([--enable-symbols=(yes|no|<custom>)],
[Add debug symbols to the library (e.g.: build with -g).
This is independent of the build mode and optimization
level. The custom string allows special settings like
-ggdb, etc. to be used.
[default=yes if debug build, otherwise no]
])],
[SYMBOLS=$enableval])
## Set default
if test "X-$SYMBOLS" = X- ; then
if test "X-$BUILD_MODE" = "X-debug" ; then
SYMBOLS=yes
else
SYMBOLS=no
fi
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([SYMBOLS])
case "X-$SYMBOLS" in
X-yes)
H5_CFLAGS="$H5_CFLAGS $SYMBOLS_CFLAGS"
AC_MSG_RESULT([yes])
;;
X-no)
H5_CFLAGS="$H5_CFLAGS $NO_SYMBOLS_CFLAGS"
AC_MSG_RESULT([no])
;;
*)
H5_CFLAGS="$H5_CFLAGS $SYMBOLS"
SYMBOLS="custom ($SYMBOLS)"
AC_MSG_RESULT([$SYMBOLS])
;;
esac
## ----------------------------------------------------------------------
## Check if the assert macro should be enabled
##
AC_MSG_CHECKING([enable asserts])
AC_ARG_ENABLE([asserts],
[AS_HELP_STRING([--enable-asserts],
[Determines whether NDEBUG is defined or not, which
controls assertions.
This is independent of the build mode and presence
of debugging symbols.
[default=yes if debug build, otherwise no]
])],
[ASSERTS=$enableval])
## Set default
if test "X-$ASSERTS" = X- ; then
if test "X-$BUILD_MODE" = "X-debug" ; then
ASSERTS=yes
else
ASSERTS=no
fi
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([ASSERTS])
case "X-$ASSERTS" in
X-yes)
H5_CPPFLAGS="$H5_CPPFLAGS -UNDEBUG"
AC_MSG_RESULT([yes])
;;
X-no)
H5_CPPFLAGS="$H5_CPPFLAGS -DNDEBUG"
AC_MSG_RESULT([no])
;;
*)
AC_MSG_ERROR([Unrecognized value: $ASSERTS])
;;
esac
## ----------------------------------------------------------------------
## Check if the compiler should use profiling flags/settings
##
AC_MSG_CHECKING([profiling])
AC_ARG_ENABLE([profiling],
[AS_HELP_STRING([--enable-profiling=(yes|no|<custom>)],
[Enable profiling flags (e.g.: -pg).
This can be set independently from the build mode.
The custom setting can be used to pass alternative
profiling flags (e.g.: -P for using Prof with gcc).
[default=no]
])],
[PROFILING=$enableval])
## Default is no profiling
if test "X-$PROFILING" = X- ; then
PROFILING=no
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([PROFILING])
case "X-$PROFILING" in
X-yes)
H5_CFLAGS="$H5_CFLAGS $PROFILE_CFLAGS"
AC_MSG_RESULT([yes])
;;
X-no)
AC_MSG_RESULT([no])
;;
*)
H5_CFLAGS="$H5_CFLAGS $PROFILING"
PROFILING="custom ($PROFILING)"
AC_MSG_RESULT([$PROFILING])
;;
esac
## ----------------------------------------------------------------------
## Check if the compiler should use a particular optimization setting
##
AC_MSG_CHECKING([optimization level])
AC_ARG_ENABLE([optimization],
[AS_HELP_STRING([--enable-optimization=(high|debug|none|<custom>)],
[Enable optimization flags/settings (e.g.: -O3).
This can be set independently from the build mode.
Optimizations for a given compiler can be specified
at several levels: High, with aggressive optimizations
turned on; debug, with optimizations that are
unlikely to interfere with debugging or profiling;
and none, with no optimizations at all.
See the compiler-specific config/*-flags file for more
details.
Alternatively, optimization options can
be specified directly by specifying them as a
string value. These custom optimzation flags will
completely replace all other optimization flags.
[default depends on build mode: debug=debug,
production=high, clean=none]
])],
[OPTIMIZATION=$enableval])
## Set the default optimization level. This depends on the compiler mode.
if test "X-$OPTIMIZATION" = X- ; then
case "X-$BUILD_MODE" in
X-debug)
OPTIMIZATION=debug
;;
X-production)
OPTIMIZATION=high
;;
X-clean)
OPTIMIZATION=none
;;
esac
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([OPTIMIZATION])
case "X-$OPTIMIZATION" in
X-high)
H5_CFLAGS="$H5_CFLAGS $HIGH_OPT_CFLAGS"
AC_MSG_RESULT([high])
;;
X-debug)
H5_CFLAGS="$H5_CFLAGS $DEBUG_OPT_CFLAGS"
AC_MSG_RESULT([debug])
;;
X-none)
H5_CFLAGS="$H5_CFLAGS $NO_OPT_CFLAGS"
AC_MSG_RESULT([none])
;;
*)
H5_CFLAGS="$H5_CFLAGS $OPTIMIZATION"
OPTIMIZATION="custom ($OPTIMIZATION)"
AC_MSG_RESULT([$OPTIMIZATION])
;;
esac
## Check if they would like the function stack support compiled in
##
AC_MSG_CHECKING([whether function stack tracking is enabled])
AC_ARG_ENABLE([codestack],
[AS_HELP_STRING([--enable-codestack],
[Enable the function stack tracing (for developer debugging).
[default=no]
])],
[CODESTACK=$enableval])
## Set the default level.
if test "X-$CODESTACK" = X- ; then
CODESTACK=no
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([CODESTACK])
case "X-$CODESTACK" in
X-yes)
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CODESTACK], [1],
[Define if the function stack tracing code is to be compiled in])
;;
X-no)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_ERROR([Unrecognized value: $CODESTACK])
;;
esac
## Checkpoint the cache
AC_CACHE_SAVE
## Set RUNPARALLEL to mpiexec.
if test -z "$RUNPARALLEL"; then
RUNPARALLEL="mpiexec -n \$\${NPROCS:=3}"
fi
## Display what we found about running programs
AC_MSG_CHECKING([prefix for running on one processor])
AC_MSG_RESULT([$RUNSERIAL])
AC_MSG_CHECKING([prefix for running in parallel])
AC_MSG_RESULT([$RUNPARALLEL])
## There *must* be some way to run in parallel even if it's just the
## word `none'.
if test -z "$RUNPARALLEL"; then
AC_MSG_ERROR([no way to run a parallel program])
fi
## If RUNSERIAL or RUNPARALLEL is the word `none' then replace it with
## the empty string. This means that no launch commands were requested,
## so we will not use any launch commands.
if test "X$RUNSERIAL" = "Xnone"; then
RUNSERIAL=""
fi
if test "X$RUNPARALLEL" = "Xnone"; then
RUNPARALLEL=""
fi
## ----------------------------------------------------------------------
## Restore user's CFLAGS.
CFLAGS="$saved_user_CFLAGS"
CPPFLAGS="$saved_user_CPPFLAGS"
LDFLAGS="$saved_user_LDFLAGS"
AC_CONFIG_FILES([Makefile
src/Makefile
test/Makefile
examples/Makefile
lib/Makefile
examples/config.xml
test/config.xml
evo/h5evolve_sample.py])
AC_OUTPUT