This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
379 lines (312 loc) · 9.84 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
#
# Copyright (C) 2015 Y. Pouillon
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# ---------------------------------------------------------------------------- #
#
# IMPORTANT NOTE
#
# Please DO NOT EDIT this file unless you REALLY know what you are doing.
# Everything is important, in particular the order of the various commands
# executed here. YOU HAVE BEEN WARNED !
#
# ---------------------------------------------------------------------------- #
#
# Autotools startup
#
# Initialize Autoconf
AC_PREREQ(2.68)
AC_INIT([LibCIF], [0.0.0],
[https://github.com/jsspencer/libcif/issues], [libcif])
AC_REVISION([Autotools support for LibCIF])
AC_CONFIG_AUX_DIR([config/gnu])
AC_CONFIG_MACRO_DIR([config/m4])
AC_CONFIG_SRCDIR([.])
# Initialize Automake
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.11 parallel-tests color-tests])
AM_CONFIG_HEADER([config.h])
# ---------------------------------------------------------------------------- #
#
# Define global options
#
# Debugging
# FIXME: disable debug by default when releasing
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],
[Enable debug mode (default: enabled)]),
[],
[enable_debug="yes"])
AC_SUBST(enable_debug)
# Fortran - Optional support
AC_ARG_ENABLE([fortran],
AC_HELP_STRING([--enable-fortran],
[Enable Fortran bindings (default: disabled)]),
[],
[enable_fortran="no"])
AC_SUBST(enable_fortran)
# GCOV - Optional support
AC_ARG_ENABLE([gcov],
AC_HELP_STRING([--enable-gcov],
[Enable code coverage with GCOV (default: disabled)]),
[],
[enable_gcov="no"])
AC_SUBST(enable_gcov)
# Memory profiling - Optional support
AC_ARG_ENABLE([memprof],
AC_HELP_STRING([--enable-memprof],
[Enable memory profiling (default: disabled)]),
[],
[enable_memprof="no"])
AC_SUBST(enable_memprof)
# ---------------------------------------------------------------------------- #
#
# Startup
#
# Check for common programs
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_AWK
AC_PROG_GREP
# Workaround for the "grep -e" issue on Solaris systems
AC_PROG_EGREP
# Workaround for the wrong path to install-sh on Mac systems
AX_PROG_MKDIR_P
# Init variables
cif_core_incs=""
AC_SUBST(cif_core_incs)
# ---------------------------------------------------------------------------- #
#
# Languages
#
# Look for the C compiler
if test "${CC}" != "" -a ! -x "${CC}"; then
cif_cc_probe=`echo "${CC}" | sed -e 's/ .*//'`
if test ! -x "${cif_cc_probe}"; then
AC_PATH_PROG([cif_cc_path],[${cif_cc_probe}])
if test "${cif_cc_path}" = ""; then
AC_MSG_ERROR([could not run C compiler "${CC}"])
fi
fi
fi
AC_PROG_CC
AC_PROG_CPP
# C compiler peculiarities
AM_PROG_CC_C_O
AC_PROG_CC_C99
# Required headers
AC_CHECK_HEADERS([time.h])
# Required functions
AC_CHECK_FUNCS([strndup])
# ------------------------------------ #
# Look for the Fortran compiler
if test "${enable_fortran}" = "yes"; then
if test "${FC}" != "" -a ! -x "${FC}"; then
cif_fc_probe=`echo "${FC}" | sed -e 's/ .*//'`
if test ! -x "${cif_fc_probe}"; then
AC_PATH_PROG([cif_fc_path], [${cif_fc_probe}])
if test "${cif_fc_path}" = ""; then
AC_MSG_ERROR([could not run Fortran compiler "${FC}"])
fi
fi
fi
AC_PROG_FC
fi
# Adjust Fortran parameters
if test "${enable_fortran}" = "yes"; then
# Enforce strict file extensions
cif_fc_src_ok="unknown"
AC_FC_SRCEXT([F90], [cif_fc_src_ok="yes"], [cif_fc_src_ok="no"])
if test "${cif_fc_src_ok}" != "yes"; then
AC_MSG_WARN([Fortran file extension could not be changed])
AC_MSG_WARN([Fortran tests may fail])
fi
# Look for the iso_c_binding module
cif_fc_iso_c_binding="unknown"
AC_MSG_CHECKING([for the iso_c_binding Fortran module])
AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[use iso_c_binding]])],
[cif_fc_iso_c_binding="yes"],
[cif_fc_iso_c_binding="no"])
AC_LANG_POP([Fortran])
AC_MSG_RESULT([${cif_fc_iso_c_binding}])
if test "${cif_fc_iso_c_binding}" != "yes"; then
AC_MSG_ERROR([the Fortran compiler does not provide
the iso_c_binding module
This probably happens because this compiler
is an antiquity
Please disable Fortran support or use a modern
Fortran compiler])
fi
# Fortran compiler peculiarities
AX_F90_MODULE_EXTENSION
AC_SUBST(ax_cv_f90_modext)
AX_F90_MODULE_CASE
# Language mixing
AC_FC_WRAPPERS
# Need to know the size of a Fortran integer
ACX_FC_INTEGER_SIZE
ACX_CC_FORTRAN_INT
fi
# ------------------------------------ #
# Perl and Python
AC_PATH_PROGS([PERL], [perl perl6])
AC_PATH_PROGS([PYTHON], [python python2.7])
# ------------------------------------ #
# Inform Automake
AM_CONDITIONAL([DO_BUILD_FORTRAN],
[test "${enable_fortran}" = "yes"])
AM_CONDITIONAL([F90_MOD_UPPERCASE],
[test "${enable_fortran}" = "yes" -a "${ax_cv_f90_mod_uppercase}" = "yes"])
# ---------------------------------------------------------------------------- #
#
# Libtool (must be set once languages are known)
#
# Initialize Libtool
LT_INIT
LT_PREREQ([2.4])
LTOBJEXT="lo"
AC_SUBST(LTOBJEXT)
# ---------------------------------------------------------------------------- #
#
# Check that all required features are there
#
# Math libraries
AC_SEARCH_LIBS([exp], [m], [cif_math_ok="yes"], [cif_math_ok="no"], [])
if test "${cif_math_ok}" = "no"; then
AC_MSG_ERROR([no mathematical library found
please set the LIBS environment variable adequately when configuring])
fi
# ---------------------------------------------------------------------------- #
#
# Debugging
#
# Adjust verbosity
if test "${enable_debug}" = "yes"; then
AC_DEFINE([DEBUG_MODE], 1,
[Define to 1 if you want to enable debug mode.])
AC_DEFINE([DEBUG_LEVEL], 1,
[Set to 1 or above if you want to enable debug messages.])
else
AC_DEFINE([DEBUG_LEVEL], 0,
[Set to 1 or above if you want to enable debug messages.])
fi
# ---------------------------------------------------------------------------- #
#
# Profiling
#
# Memory profiling
if test "${enable_memprof}" = "yes"; then
AC_CHECK_PROGS([VALGRIND], [valgrind])
if test "${VALGRIND}" = ""; then
AC_MSG_ERROR([memory profiling tool not found
please install valgrind first to perform memory profiling])
fi
fi
AM_CONDITIONAL([DO_CHECKMEM], [test "${enable_memprof}" = "yes"])
# ------------------------------------ #
# Code coverage
AC_MSG_CHECKING([whether to enable code coverage (GCC only)])
AC_MSG_RESULT([${enable_gcov}])
CFLAGS_COVERAGE=""
FCFLAGS_COVERAGE=""
LDFLAGS_COVERAGE=""
LIBS_COVERAGE=""
if test "${enable_gcov}" = "yes"; then
if test "${ac_cv_c_compiler_gnu}" != "yes" -o \
\( "${enable_fortran}" = "yes" -a \
"${ac_cv_fc_compiler_gnu}" != "yes" \) -o \
"${lt_cv_prog_gnu_ld}" != "yes"; then
AC_MSG_ERROR([code coverage requires GNU compilers
please reconfigure using GCC compilers for both C and Fortran])
fi
AC_CHECK_PROGS([GCOV], [gcov])
if test "${GCOV}" = ""; then
AC_MSG_ERROR([gcov not found
please make sure that the gcov executable is in PATH])
fi
CFLAGS_COVERAGE="--coverage --no-inline"
if test "${enable_fortran}" = "yes"; then
FCFLAGS_COVERAGE="--coverage --no-inline"
fi
LDFLAGS_COVERAGE="--coverage"
LIBS_COVERAGE="-lgcov"
fi
AM_CONDITIONAL([DO_COVERAGE], [test "${enable_gcov}" = "yes"])
AC_SUBST(GCOV)
AC_SUBST(CFLAGS_COVERAGE)
AC_SUBST(FCFLAGS_COVERAGE)
AC_SUBST(LDFLAGS_COVERAGE)
AC_SUBST(LIBS_COVERAGE)
# ---------------------------------------------------------------------------- #
#
# Prepare data for the test suite
#
# Generate explicit dependencies for GCOV tests
if test "${enable_gcov}" = "yes"; then
echo "# Script-generated makefile targets for GCOV tests" \
>src/gcov-tests-deps.mf
for src in ${ac_top_srcdir}/src/test_*.c; do
exe=`basename "${src}" | sed -e 's/\.c//'`
echo "" >>src/gcov-tests-deps.mf
echo "${exe}.log: gcov_clean.log" >>src/gcov-tests-deps.mf
done
for src in ${ac_top_srcdir}/src/test_*.in; do
exe=`basename "${src}" | sed -e 's/\.in//'`
echo "" >>src/gcov-tests-deps.mf
echo "${exe}.log: gcov_clean.log" >>src/gcov-tests-deps.mf
done
echo "" >>src/gcov-tests-deps.mf
echo "gcov_report.log: gcov_clean.log" >>src/gcov-tests-deps.mf
fi
# ---------------------------------------------------------------------------- #
#
# Output configuration
#
AC_MSG_NOTICE([Fortran : ${enable_fortran}])
AC_MSG_NOTICE([Debugging : ${enable_debug}])
AC_MSG_NOTICE([Profiling : ${enable_memprof}])
AC_MSG_NOTICE([Coverage : ${enable_gcov}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([CPP = ${CPP}])
AC_MSG_NOTICE([CPPFLAGS = ${CPPFLAGS}])
AC_MSG_NOTICE([CC = ${CC}])
AC_MSG_NOTICE([CFLAGS = ${CFLAGS}])
if test "${enable_fortran}" = "yes"; then
AC_MSG_NOTICE([FC = ${FC}])
AC_MSG_NOTICE([FCFLAGS = ${FCFLAGS}])
fi
AC_MSG_NOTICE([LDFLAGS = ${LDFLAGS}])
AC_MSG_NOTICE([LIBS = ${LIBS}])
AC_CONFIG_COMMANDS([script-perms],
[chmod u+x \
src/gcov_check_coverage \
src/gcov_clean \
src/gcov_report \
src/test_memory
])
AC_CONFIG_FILES([
Makefile
src/Makefile
src/gcov_check_coverage
src/gcov_clean
src/gcov_report
src/test_memory])
AC_OUTPUT