Newer
Older
Kurt A. O'Hearn
committed
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
Kurt A. O'Hearn
committed
AC_INIT([PuReMD], [1.0], [ohearnku@msu.edu hma@msu.edu])
Kurt A. O'Hearn
committed
# Do not allow AC_PROG_CC to set CFLAGS (this line must be after AC_INIT but before AC_PROG_CC)
save_CFLAGS="${CFLAGS}"
: ${CFLAGS=""}
AM_INIT_AUTOMAKE([1.15 subdir-objects -Wall -Werror])
# Enable silent build rules by default.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],[1])])
Kurt A. O'Hearn
committed
AM_PROG_AR
Kurt A. O'Hearn
committed
LT_PREREQ([2.2])
LT_INIT([dlopen])
AC_CONFIG_MACRO_DIR([m4])
Kurt A. O'Hearn
committed
# Headline formatter
AC_DEFUN([CONFIGURE_HEADLINE],
[
echo; echo "+++ $1 +++"
])
AC_DEFUN([AC_PROG_PDFLATEX],
[AC_ARG_VAR([PDFLATEX], [LaTeX PDF generation program])dnl
AC_CHECK_PROGS([PDFLATEX], [pdflatex])
m4_ifval([$1],,
[if test -z "$PDFLATEX"; then
AC_MSG_WARN([pdflatex not found. Unable to build documentation. Continuing...])
fi])])
Kurt A. O'Hearn
committed
AC_ARG_ENABLE([serial],
[AS_HELP_STRING([--enable-serial],
[enable serial support @<:@default: no@:>@])],
[pack_serial_enabled=${enableval}], [pack_serial_enabled=no])
Kurt A. O'Hearn
committed
AC_ARG_ENABLE([openmp],
[AS_HELP_STRING([--enable-openmp],
[enable OpenMP support @<:@default: yes@:>@])],
[pack_openmp_enabled=${enableval}], [pack_openmp_enabled=yes])
Kurt A. O'Hearn
committed
AC_ARG_ENABLE([mpi-old],
[AS_HELP_STRING([--enable-mpi-old],
Kurt A. O'Hearn
committed
[enable MPI support (old) @<:@default: no@:>@])],
Kurt A. O'Hearn
committed
[pack_mpi_old_enabled=${enableval}], [pack_mpi_old_enabled=no])
AC_ARG_ENABLE([gpu],
[AS_HELP_STRING([--enable-gpu],
[enable CUDA (single GPU) support @<:@default: no@:>@])],
[pack_gpu_enabled=${enableval}], [pack_gpu_enabled=no])
Kurt A. O'Hearn
committed
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--enable-mpi],
Kurt A. O'Hearn
committed
[enable MPI support @<:@default: no@:>@])],
Kurt A. O'Hearn
committed
[pack_mpi_enabled=${enableval}], [pack_mpi_enabled=no])
AC_ARG_ENABLE([mpi-gpu],
[AS_HELP_STRING([--enable-mpi-gpu],
Kurt A. O'Hearn
committed
[enable MPI+CUDA (multi GPU) support @<:@default: no@:>@])],
[pack_mpi_gpu_enabled=${enableval}], [pack_mpi_gpu_enabled=no])
Kurt A. O'Hearn
committed
# Provides debug compilation mode.
AC_ARG_ENABLE([debug],
Kurt A. O'Hearn
committed
[AS_HELP_STRING([--enable-debug],
[enable debug support @<:@default: no@:>@])],
[DEBUG=${enableval}], [DEBUG=no]
)
Kurt A. O'Hearn
committed
if test "x${DEBUG}" = "xyes"
Kurt A. O'Hearn
committed
# #TODO: fix exporting to subdirs
# # See: http://stackoverflow.com/questions/34124337/changing-flags-in-configure-ac-vs-caching-with-subprojects
Kurt A. O'Hearn
committed
export BUILD_DEBUG="yes"
fi
# gprof flags.
AC_ARG_ENABLE([gprof],
Kurt A. O'Hearn
committed
[AS_HELP_STRING([--enable-gprof],
[enable support for profiling with gprof @<:@default: no@:>@])],
Kurt A. O'Hearn
committed
yes)
export BUILD_GPROF="yes"
Kurt A. O'Hearn
committed
AC_MSG_ERROR([bad value ${enableval} for --enable-gprof (only yes or no are possible)]) ;;
Kurt A. O'Hearn
committed
[]
)
# Timing measurements.
AC_ARG_ENABLE([timing],
Kurt A. O'Hearn
committed
[AS_HELP_STRING([--enable-timing],
[enable timing measurements and reporting @<:@default: no@:>@])],
[timing_enabled=${enableval}], [timing_enabled=no]
if test "x${timing_enabled}" = "xyes"
Kurt A. O'Hearn
committed
export BUILD_TIMING="yes"
Kurt A. O'Hearn
committed
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-doc],
[enable documentation generation @<:@default: no@:>@])],
[pack_doc_enabled=${enableval}], [pack_doc_enabled=no])
Kurt A. O'Hearn
committed
AM_CONDITIONAL([BUILD_DOC], [test "x${pack_doc_enabled}" = "xyes" && test "x${PDFLATEX}" != "x"])
if test "x${pack_doc_enabled}" = "xyes"; then
AC_CONFIG_SUBDIRS([doc])
fi
Kurt A. O'Hearn
committed
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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# Checks for compilers.
AC_LANG([C])
AC_PROG_CC([icc gcc clang cc])
AC_PROG_CPP
CFLAGS="${save_CFLAGS}"
AC_LANG([C++])
AC_PROG_CXX([icpc g++ clang++ CC c++])
AC_PROG_CXXCPP
# sPuReMD
if test "x${pack_serial_enabled}" = "xyes" || test "x${pack_openmp_enabled}" = "xyes"; then
if test "x${pack_serial_enabled}" = "xyes" || test "x${pack_openmp_enabled}" != "xyes"; then
BUILD_OPENMP="no"
else
BUILD_OPENMP="yes"
fi
AC_LANG_PUSH([C])
AC_CONFIG_SRCDIR([sPuReMD/src/traj.h])
AC_CONFIG_HEADERS([sPuReMD/src/config.h])
# Checks for libraries.
AC_SEARCH_LIBS([exp], [m])
AC_SEARCH_LIBS([sqrt], [m])
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([acos], [m])
AC_SEARCH_LIBS([cos], [m])
AC_SEARCH_LIBS([sin], [m])
AC_SEARCH_LIBS([tan], [m])
AC_SEARCH_LIBS([fabs], [m])
AC_SEARCH_LIBS([gzopen], [z])
AC_SEARCH_LIBS([gzeof], [z])
AC_SEARCH_LIBS([gzgets], [z])
AC_SEARCH_LIBS([gzseek], [z])
AC_SEARCH_LIBS([gzclose], [z])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_CHECK_TYPES([gzFile], [],
[AC_MSG_FAILURE([gzFile type not found in zlib.h], [1])], [#include<zlib.h>])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([gettimeofday memset])
# Check for compiler vendor. If the compiler is recognized,
# the variable ax_cv_c_compiler_vendor is set accordingly.
AX_COMPILER_VENDOR
if test "x${ax_cv_c_compiler_vendor}" = "xgnu"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0 -g2 -D_GLIBCXX_DEBUG"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -pg"
fi
elif test "x${ax_cv_c_compiler_vendor}" = "xintel"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -p"
fi
fi
AC_SUBST([DFT_CFLAGS], ["${DEFAULT_CFLAGS}"])
# Check for OpenMP support.
if test "x${BUILD_OPENMP}" = "xyes"; then
AX_OPENMP
if test "x${OPENMP_CFLAGS}" = "x"; then
AC_MSG_WARN([
-----------------------------------------------
Unable to find OpenMP support on this system.
Building a single-threaded version.
-----------------------------------------------])
else
# bug due to recent Intel compiler change (?)
if test "x${ax_cv_c_compiler_vendor}" = "xintel"; then
OPENMP_CFLAGS="-qopenmp"
fi
OPENMP_LIBS="-lgomp"
fi
# AC_MSG_NOTICE([OPENMP_CFLAGS=${OPENMP_CFLAGS}])
# AC_MSG_NOTICE([OPENMP_LIBS=${OPENMP_LIBS}])
AC_SUBST([OMP_CFLAGS], ["${OPENMP_CFLAGS}"])
AC_SUBST([OMP_LIBS], ["${OPENMP_LIBS}"])
fi
# Check for LAPACKE
LAPACKE_LIBS=
AC_CHECK_HEADERS([mkl.h], [MKL_FOUND_HEADERS="yes"])
if test "x${MKL_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [mkl_intel_ilp64],
[MKL_FOUND_LIBS="yes"], [MKL_FOUND_LIBS="no"],
[-lmkl_sequential -lmkl_core -lpthread -lm -ldl])
AS_IF([test "x${MKL_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find MKL LAPACKE library.])])
LAPACKE_LIBS="-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
AC_DEFINE([HAVE_LAPACKE_MKL], [1], [Define to 1 if you have MKL LAPACKE support enabled.])
else
AC_CHECK_HEADERS([lapacke.h], [LAPACKE_FOUND_HEADERS="yes"])
if test "x${LAPACKE_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [lapacke],
[LAPACKE_FOUND_LIBS="yes"], [LAPACKE_FOUND_LIBS="no"],
[-llapack])
AS_IF([test "x${LAPACKE_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find LAPACKE library.])])
LAPACKE_LIBS="-llapack"
AC_DEFINE([HAVE_LAPACKE], [1], [Define to 1 if you have LAPACKE support enabled.])
else
AC_MSG_WARN([
-----------------------------------------------
Unable to find LAPACKE on this system.
Disabling support for dependent methods.
-----------------------------------------------])
fi
fi
AC_SUBST([L_LIBS], ["${LAPACKE_LIBS}"])
AC_LANG_POP([C])
fi
AM_CONDITIONAL([BUILD_S_OMP], [test "x${pack_serial_enabled}" = "xyes" || test "x${pack_openmp_enabled}" = "xyes"])
# PuReMD-GPU
if test "x${pack_gpu_enabled}" = "xyes"; then
BUILD_GPU="yes"
AC_LANG_PUSH([C])
AC_CONFIG_SRCDIR([PuReMD-GPU/src/analyze.c])
AC_CONFIG_HEADERS([PuReMD-GPU/src/config.h])
# Checks for libraries.
AC_SEARCH_LIBS([exp], [m])
AC_SEARCH_LIBS([sqrt], [m])
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([acos], [m])
AC_SEARCH_LIBS([cos], [m])
AC_SEARCH_LIBS([sin], [m])
AC_SEARCH_LIBS([tan], [m])
AC_SEARCH_LIBS([fabs], [m])
AC_SEARCH_LIBS([gzopen], [z])
AC_SEARCH_LIBS([gzeof], [z])
AC_SEARCH_LIBS([gzgets], [z])
AC_SEARCH_LIBS([gzseek], [z])
AC_SEARCH_LIBS([gzclose, [z]])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_CHECK_TYPES([gzFile], [],
[AC_MSG_FAILURE([gzFile type not found in zlib.h], [1])], [#include<zlib.h>])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([gettimeofday memset])
# Check for compiler vendor. If the compiler is recognized,
# the variable ax_cv_c_compiler_vendor is set accordingly.
AX_COMPILER_VENDOR
if test "x${ax_cv_c_compiler_vendor}" = "xgnu"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0 -g2 -D_GLIBCXX_DEBUG"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -pg"
fi
elif test "x${ax_cv_c_compiler_vendor}" = "xintel"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -p"
fi
fi
# Check for CUDA support.
CONFIGURE_HEADLINE([ CUDA support ])
AX_CUDA
NVCCFLAGS=
if test "x${BUILD_DEBUG}" = "xyes"
then
NVCCFLAGS="-g -G"
fi
if test "x${BUILD_GPROF}" = "xtrue"
then
NVCCFLAGS+=" --compiler-options ${gprof_flags}"
fi
AC_DEFINE([HAVE_CUDA], [1], [Define to 1 if you have CUDA support enabled.])
AC_CHECK_LIB([cuda], [cuGetErrorString])
AC_CHECK_LIB([cudart], [cudaMalloc])
AC_CHECK_LIB([cublas], [cublasDnrm2])
AC_CHECK_LIB([cusparse], [cusparseCreateMatDescr])
# AC_SEARCH_LIBS([cublasDaxpy], [cublas])
# AC_SEARCH_LIBS([cublasDscal], [cublas])
# AC_SEARCH_LIBS([cublasDdot], [cublas])
# AC_SEARCH_LIBS([cudaThreadSynchronize], [cudart])
# AC_SEARCH_LIBS([cudaGetLastError], [cudart])
# AC_SEARCH_LIBS([cusparseCreateMatDescr], [cusparse])
# AC_SEARCH_LIBS([cusparseSetMatType], [cusparse])
# AC_SEARCH_LIBS([cusparseSetMatIndexBase], [cusparse])
#
# AC_SEARCH_LIBS([cublasDnrm2], [cublas],
# [CUBLAS_FOUND_LIBS="yes"], [CUBLAS_FOUND_LIBS="no"], [-lcublas])
# AS_IF([test "x${CUBLAS_FOUND_LIBS}" != "xyes"],
# [AC_MSG_ERROR([Unable to find CUBLAS library.])])
#
# AC_SEARCH_LIBS([cusparseSetMatType], [cusparse],
# [CUSPARSE_FOUND_LIBS="yes"], [CUSPARSE_FOUND_LIBS="no"], [-lcusparse])
# AS_IF([test "x${CUSPARSE_FOUND_LIBS}" != "xyes"],
# [AC_MSG_ERROR([Unable to find CUSPARSE library.])])
#
# AC_CHECK_TYPES([cublasHandle_t], [],
# [AC_MSG_FAILURE([cublasHandle_t type not found in cublas.h], [1])], [#include<cublas_v2.h>])
# AC_CHECK_TYPES([cusparseHandle_t], [],
# [AC_MSG_FAILURE([cusparseHandle_t type not found in cusparse.h], [1])], [#include<cusparse_v2.h>])
# AC_CHECK_TYPES([cusparseMatDescr_t], [],
# [AC_MSG_FAILURE([cusparseMatDescr_t type not found in cusparse.h], [1])], [#include<cusparse_v2.h>])
AC_LANG_POP([C])
fi
AM_CONDITIONAL([BUILD_GPU], [test "x${pack_gpu_enabled}" = "xyes"])
# PuReMD
if test "x${pack_mpi_old_enabled}" = "xyes"; then
AC_LANG_PUSH([C])
AC_CONFIG_SRCDIR([PuReMD/src/torsion_angles.h])
AC_CONFIG_HEADERS([PuReMD/src/config.h])
# Checks for libraries.
AC_SEARCH_LIBS([exp], [m])
AC_SEARCH_LIBS([sqrt], [m])
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([acos], [m])
AC_SEARCH_LIBS([cos], [m])
AC_SEARCH_LIBS([sin], [m])
AC_SEARCH_LIBS([tan], [m])
AC_SEARCH_LIBS([fabs], [m])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([gettimeofday memset pow sqrt])
# Check for compiler vendor. If the compiler is recognized,
# the variable ax_cv_c_compiler_vendor is set accordingly.
AX_COMPILER_VENDOR
if test "x${ax_cv_c_compiler_vendor}" = "xgnu"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0 -g2 -D_GLIBCXX_DEBUG"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -pg"
fi
elif test "x${ax_cv_c_compiler_vendor}" = "xintel"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -p"
fi
fi
AC_SUBST([DFT_CFLAGS], ["${DEFAULT_CFLAGS}"])
# Check for MPI support. If found, sets the following variables:
# Compiler-related: MPICC, MPICXX, MPIF77
# Library linking: MPILIBS
# Compilation support (via preprocessor def): HAVE_MPI
CONFIGURE_HEADLINE([ MPI compiler ])
ACX_MPI([], [AC_MSG_ERROR([could not find mpi library])])
AC_CHECK_PROG(MPIRUN, mpirun, mpirun)
# try to find if we are using OpenMPI / MPICH by looking inside mpi.h
save_CC="${CC}"
save_CFLAGS="${CFLAGS}"
CC="${MPICC}"
CFLAGS=""
AC_CHECK_DECL([OPEN_MPI], [mpi_vendor="OpenMPI"],
[], [#include "mpi.h"])
# MPICH v2
AC_CHECK_DECL([MPICH2], [mpi_vendor="MPICH2"],
[], [#include "mpi.h"])
# MPICH v3
AC_CHECK_DECL([MPICH_VERSION], [mpi_vendor="MPICH3"],
[], [#include "mpi.h"])
CC="${save_CC}"
CFLAGS="${save_CFLAGS}"
# try to set MPI_CFLAGS and MPI_LIBS
MPI_CFLAGS=
MPI_LIBS=
if test "x${mpi_vendor}" = "xOpenMPI"
then
MPI_CFLAGS=`${MPICC} --showme:compile`
MPI_LIBS=`${MPICC} --showme:link`
AC_MSG_NOTICE([OpenMPI support found])
AC_MSG_NOTICE([MPI_CFLAGS=${MPI_CFLAGS}])
AC_MSG_NOTICE([MPI_LIBS=${MPI_LIBS}])
elif test "x${mpi_vendor}" = "xMPICH2" || test "x${mpi_vendor}" = "xMPICH3"
then
# build MPI_CFLAGS
tmp=`${MPICC} -compile-info | awk '{$1=""; print $0 }'`
MPI_CFLAGS=
for i in $tmp
do
case ${i} in
-[[DIUbi]]*)
MPI_CFLAGS="${MPI_CFLAGS} ${i}"
;;
esac
done
# build MPI_LIBS
tmp=`${MPICC} -link-info | awk '{$1=""; print $0 }'`
for i in $tmp
do
case ${i} in
[[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]* | -Wl* )
MPI_LIBS="${MPI_LIBS} ${i}"
;;
esac
done
AC_MSG_NOTICE([MPICH support found])
AC_MSG_NOTICE([MPI_CFLAGS=${MPI_CFLAGS}])
AC_MSG_NOTICE([MPI_LIBS=${MPI_LIBS}])
else
AC_MSG_WARN([Neither OpenMPI and MPICH support recognized...])
fi
AC_SUBST([M_CFLAGS], ["${MPI_CFLAGS}"])
AC_SUBST([M_LIBS], ["${MPI_LIBS}"])
# Check for LAPACKE
LAPACKE_LIBS=
AC_CHECK_HEADERS([mkl.h], [MKL_FOUND_HEADERS="yes"])
if test "x${MKL_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [mkl_intel_ilp64],
[MKL_FOUND_LIBS="yes"], [MKL_FOUND_LIBS="no"],
[-lmkl_sequential -lmkl_core -lpthread -lm -ldl])
AS_IF([test "x${MKL_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find MKL LAPACKE library.])])
# dynamic linking
#LAPACKE_LIBS="-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
# static linking
LAPACKE_LIBS="-Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl"
AC_DEFINE([HAVE_LAPACKE_MKL], [1], [Define to 1 if you have MKL LAPACKE support enabled.])
else
AC_CHECK_HEADERS([lapacke.h], [LAPACKE_FOUND_HEADERS="yes"])
if test "x${LAPACKE_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [lapacke],
[LAPACKE_FOUND_LIBS="yes"], [LAPACKE_FOUND_LIBS="no"],
[-llapack])
AS_IF([test "x${LAPACKE_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find LAPACKE library.])])
LAPACKE_LIBS="-llapack"
AC_DEFINE([HAVE_LAPACKE], [1], [Define to 1 if you have LAPACKE support enabled.])
else
AC_MSG_WARN([
-----------------------------------------------
Unable to find LAPACKE on this system.
Disabling support for dependent methods.
-----------------------------------------------])
fi
fi
AC_SUBST([L_LIBS], ["${LAPACKE_LIBS}"])
fi
AC_LANG_POP([C])
AM_CONDITIONAL([BUILD_MPI], [test "x${pack_mpi_old_enabled}" = "xyes"])
# PG-PuReMD
if test "x${pack_mpi_enabled}" = "xyes" || test "x${pack_mpi_gpu_enabled}" = "xyes"; then
if test "x${pack_mpi_enabled}" = "xyes" || test "x${pack_mpi_gpu_enabled}" != "xyes"; then
export BUILD_GPU="no"
else
export BUILD_GPU="yes"
fi
AC_LANG_PUSH([C])
AC_CONFIG_SRCDIR([PG-PuReMD/src/torsion_angles.h])
AC_CONFIG_HEADERS([PG-PuReMD/src/config.h])
# Checks for libraries.
AC_SEARCH_LIBS([exp], [m])
AC_SEARCH_LIBS([sqrt], [m])
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([acos], [m])
AC_SEARCH_LIBS([cos], [m])
AC_SEARCH_LIBS([sin], [m])
AC_SEARCH_LIBS([tan], [m])
AC_SEARCH_LIBS([fabs], [m])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRTOD
AC_CHECK_FUNCS([gettimeofday memset])
# Check for compiler vendor. If the compiler is recognized,
# the variable ax_cv_c_compiler_vendor is set accordingly.
AX_COMPILER_VENDOR
if test "x${ax_cv_c_compiler_vendor}" = "xgnu"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0 -g2 -D_GLIBCXX_DEBUG"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -pg"
fi
elif test "x${ax_cv_c_compiler_vendor}" = "xintel"; then
if test "x${BUILD_DEBUG}" = "xyes"; then
DEFAULT_CFLAGS="-Wall -O0"
else
DEFAULT_CFLAGS="-Wall -O3"
fi
if test "x${BUILD_GPROF}" = "xyes"; then
DEFAULT_CFLAGS+=" -p"
fi
fi
AC_SUBST([DFT_CFLAGS], ["${DEFAULT_CFLAGS}"])
# Check for MPI support.
CONFIGURE_HEADLINE([ MPI compiler ])
ACX_MPI([], [AC_MSG_ERROR([could not find MPI library])])
AC_CHECK_PROG(MPIRUN, mpirun, mpirun)
AC_SUBST(MPIRUN)
# try to find if we are using OpenMPI / MPICH by looking inside mpi.h
save_CC="${CC}"
save_CFLAGS="${CFLAGS}"
CC="${MPICC}"
CFLAGS="${CFLAGS}"
AC_CHECK_DECL([OPEN_MPI], [mpi_vendor="OpenMPI"],
[], [#include "mpi.h"])
# MPICH v2
AC_CHECK_DECL([MPICH2], [mpi_vendor="MPICH2"],
[], [#include "mpi.h"])
# MPICH v3
AC_CHECK_DECL([MPICH_VERSION], [mpi_vendor="MPICH3"],
[], [#include "mpi.h"])
CC="${save_CC}"
CFLAGS="${save_CFLAGS}"
# try to set MPI_CFLAGS and MPI_LIBS
MPI_CFLAGS=
MPI_LIBS=
if test "x${mpi_vendor}" = "xOpenMPI"
then
MPI_CFLAGS=`${MPICC} --showme:compile`
MPI_LIBS=`${MPICC} --showme:link`
AC_MSG_NOTICE([OpenMPI found])
AC_MSG_NOTICE([MPI_CFLAGS=${MPI_CFLAGS}])
AC_MSG_NOTICE([MPI_LIBS=${MPI_LIBS}])
elif test "x${mpi_vendor}" = "xMPICH2" || test "x${mpi_vendor}" = "xMPICH3"
then
# build MPI_CFLAGS
tmp=`${MPICC} -compile-info | awk '{$1=""; print $0 }'`
MPI_CFLAGS=
for i in ${tmp}
do
case ${i} in
-[[DIUbi]]*)
MPI_CFLAGS="${MPI_CFLAGS} ${i}"
;;
esac
done
# build MPI_LIBS
tmp=`${MPICC} -link-info | awk '{$1=""; print $0 }'`
for i in ${tmp}
do
case ${i} in
[[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]* | -Wl* )
MPI_LIBS="${MPI_LIBS} ${i}"
;;
esac
done
AC_MSG_NOTICE([MPICH found])
AC_MSG_NOTICE([MPI_CFLAGS=${MPI_CFLAGS}])
AC_MSG_NOTICE([MPI_LIBS=${MPI_LIBS}])
else
AC_MSG_WARN([Neither OpenMPI and MPICH have been recognized...])
fi
AC_SUBST([M_CFLAGS], ["${MPI_CFLAGS}"])
AC_SUBST([M_LIBS], ["${MPI_LIBS}"])
# Check for LAPACKE
LAPACKE_LIBS=
AC_CHECK_HEADERS([mkl.h], [MKL_FOUND_HEADERS="yes"])
if test "x${MKL_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [mkl_intel_ilp64],
[MKL_FOUND_LIBS="yes"], [MKL_FOUND_LIBS="no"],
[-lmkl_sequential -lmkl_core -lpthread -lm -ldl])
AS_IF([test "x${MKL_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find MKL LAPACKE library.])])
LAPACKE_LIBS="-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl"
AC_DEFINE([HAVE_LAPACKE_MKL], [1], [Define to 1 if you have MKL LAPACKE support enabled.])
else
AC_CHECK_HEADERS([lapacke.h], [LAPACKE_FOUND_HEADERS="yes"])
if test "x${LAPACKE_FOUND_HEADERS}" = "xyes"
then
AC_SEARCH_LIBS([LAPACKE_dgels], [lapacke],
[LAPACKE_FOUND_LIBS="yes"], [LAPACKE_FOUND_LIBS="no"],
[-llapack])
AS_IF([test "x${LAPACKE_FOUND_LIBS}" != "xyes"],
[AC_MSG_ERROR([Unable to find LAPACKE library.])])
LAPACKE_LIBS="-llapack"
AC_DEFINE([HAVE_LAPACKE], [1], [Define to 1 if you have LAPACKE support enabled.])
else
AC_MSG_WARN([
-----------------------------------------------
Unable to find LAPACKE on this system.
Disabling support for dependent methods.
-----------------------------------------------])
fi
fi
AC_SUBST([L_LIBS], ["${LAPACKE_LIBS}"])
AC_LANG_POP([C])
AC_LANG_PUSH([C++])
# Check for CUDA support.
if test "x${BUILD_GPU}" = "xyes"; then
CONFIGURE_HEADLINE([ CUDA support ])
AX_CUDA
NVCCFLAGS=
NVCCFLAGS+=" -ccbin=${CXX}"
if test "x${BUILD_DEBUG}" = "xyes"
then
NVCCFLAGS+=" -g -G"
fi
AC_DEFINE([HAVE_CUDA], [1], [Define to 1 if you have CUDA support enabled.])
else
AM_CONDITIONAL(USE_CUDA, test "x" = "xyes")
fi
if test "x${BUILD_GPROF}" = "xyes"
then
if test "x${BUILD_GPU}" = "xyes"; then
NVCCFLAGS+=" --compiler-options ${gprof_flags}"
else
CFLAGS+=" ${gprof_flags}"
fi
fi
AC_LANG_POP([C++])
fi
AM_CONDITIONAL([BUILD_MPI_GPU], [test "x${pack_mpi_enabled}" = "xyes" || test "x${pack_mpi_gpu_enabled}" = "xyes"])
# Moved from m4/ax_cuda.am to avoid conditionally calling inside AX_CUDA
AM_CONDITIONAL(USE_CUDA, [test "x${pack_gpu_enabled}" = "xyes" || test "x${pack_mpi_gpu_enabled}" = "xyes"])
AM_CONDITIONAL(CUDA_DEBUG, [(test "x${pack_gpu_enabled}" = "xyes" || test "x${pack_mpi_gpu_enabled}" = "xyes") && test "x${BUILD_DEBUG}" = "xyes"])
# Tests using Google C++ testing framework (gtest)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#ifndef __cplusplus
#error "broken C++"
#endif]])],,
[CXX=;])
if test "x${CXX}" != "x"
then
AC_CHECK_HEADER([gtest/gtest.h], [HAVE_GTEST_H="yes"])
if test "x${HAVE_GTEST_H}" != "xyes"
then
AC_MSG_WARN([gtest.h not found. Unable to build tests. Continuing...])
else
ACX_PTHREAD([have_pthread=yes])
# define gtest variables
if test "x${have_pthread}" = "xyes"; then
GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"
GTEST_CXXFLAGS="${PTHREAD_CFLAGS}"
GTEST_LDFLAGS=
GTEST_LIBS="${PTHREAD_LIBS}"
else
GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"
GTEST_CXXFLAGS=
GTEST_LDFLAGS=
GTEST_LIBS=
fi
fi
else
AC_MSG_WARN([C++ compiler not found. Unable to build tests. Continuing...])
fi
AM_CONDITIONAL([BUILD_TEST], [test "x${HAVE_GTEST_H}" = "xyes"])
AC_LANG_POP([C++])
Kurt A. O'Hearn
committed
AC_CONFIG_FILES([Makefile])
AC_OUTPUT