-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
450 lines (396 loc) · 13 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
AC_INIT([BAT], 1.0.0-RC2, [], [BAT])
: ${CXXFLAGS=""}
: ${CFLAGS=""}
: ${FFLAGS=""}
AM_INIT_AUTOMAKE()
AM_CONFIG_HEADER(config.h)
AC_LANG(C++)
AC_PROG_CXX
LT_INIT
AC_HEADER_STDC
AC_FUNC_UTIME_NULL
# autoconf and libtool macros will be copied to m4/
AC_CONFIG_MACRO_DIR([m4])
dnl Get filename extension for dynamic libraries:
SHLIBEXT="${shrext_cmds}"
AC_SUBST(SHLIBEXT)
DEP_CFLAGS=""
DEP_LIBS=""
dnl
dnl Check for Darwin
dnl
AM_CONDITIONAL([IS_DARWIN], [test x$(uname) = xDarwin])
dnl
dnl Check for debug mode
dnl
AC_ARG_ENABLE(
[debug],
[ --enable-debug Compile in debug mode],
[
case "${enableval}" in
yes) debug=true ; echo compiling in debug mode ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac
],
[debug=false]
)
if test x$debug = xtrue ; then
AC_SUBST([AM_CXXFLAGS], '-g -O0 -Wall -Wextra -pedantic -Wno-long-long -Wno-unknown-pragmas')
else
AC_SUBST([AM_CXXFLAGS], '-O2 -Wno-unknown-pragmas')
fi
dnl
dnl Check for parallel mode
dnl
AC_ARG_ENABLE(
[parallel],
[AS_HELP_STRING([--enable-parallel],[compile with OpenMP thread parallelization (default no)])],
[
case "${enableval}" in
yes) parallelization=1 ;;
no) parallelization=0 ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-parallel]) ;;
esac
],
[parallelization=0]
)
m4_include(tools/build/ax_openmp.m4)
if test $parallelization = 1; then
AX_OPENMP(
[
CXXFLAGS+=" $OPENMP_CXXFLAGS";
LDFLAGS+=" $OPENMP_CXXFLAGS";
DEP_CFLAGS+=" $OPENMP_CXXFLAGS";
DEP_LIBS+=" $OPENMP_CXXFLAGS";
],
[AC_MSG_ERROR([Cannot enable parallelization without OpenMP])]
)
fi
AC_DEFINE_UNQUOTED([THREAD_PARALLELIZATION], [$parallelization], [OpenMP thread parallelization])
AM_CONDITIONAL([THREAD_PARALLELIZATION], [test $parallelization = 1])
dnl
dnl Check for Cuba
dnl
dnl temporarily use the C (not C++) compiler
AC_LANG_PUSH([C])
cuba_min_version=3.3
AC_DEFINE_UNQUOTED([CUBA_MIN_VERSION], [$cuba_min_version], [Minimum cuba version])
AC_ARG_WITH(
[cuba],
[AS_HELP_STRING([--with-cuba[[=DIR]]],[Compile with Cuba support (default: no). If a local build in 'cuba/' is found, it is used and Cuba is activated automatically. The optional DIR is the top of a Cuba installation. If DIR==download, a compatible version of cuba is downloaded from the official cuba website. If DIR is not given, the location is inferred from the 'partview' executable, else Cuba is assumed to be available in the system directories.])],
[
echo "compiling with Cuba support: requires version $cuba_min_version or later"
]
)
AC_ARG_WITH(cuba_include_dir, AS_HELP_STRING([--with-cuba-include-dir=DIR path to cuba.h file]))
AC_ARG_WITH(cuba_lib_dir, AS_HELP_STRING([--with-cuba-lib-dir=DIR path to libcuba.a file]))
AC_CHECK_PROGS(CURL, curl, false)
AC_CHECK_PROGS(WGET, wget, false)
if test "$with_cuba" = "yes"; then
use_cuba=yes
AC_PATH_PROG(cuba_bin_dir, [partview])
if test -f "$cuba_bin_dir" ; then
# up two levels: /usr/local/bin/partview -> /usr/local
with_cuba="$(dirname "$(dirname "$cuba_bin_dir")")"
AC_MSG_CHECKING([for cuba in $with_cuba])
AC_MSG_RESULT(yes)
fi
elif test "$with_cuba" = "no"; then
use_cuba=no
elif test "$with_cuba" = "download"; then
use_cuba=yes
cuba_version_default=4.2
local_cuba_dir="`pwd`/external/cuba-${cuba_version_default}"
cuba_url="http://www.feynarts.de/cuba/Cuba-${cuba_version_default}.tar.gz"
with_cuba_include_dir="$local_cuba_dir"
with_cuba_lib_dir="$local_cuba_dir"
if test ! -d "${local_cuba_dir}"; then
AC_MSG_NOTICE([Downloading and building in $local_cuba_dir])
if test "$CURL" != "false"; then
download_cmd="curl -L"
elif test "$WGET" != "false"; then
download_cmd="wget -O-"
else
AC_MSG_ERROR([Need either wget or curl to download Cuba.])
fi
# Fix #248
ARFLAGS_OLD=ARFLAGS
export ARFLAGS=rvU
mkdir -p "${local_cuba_dir}" \
&& (${download_cmd} "${cuba_url}" | tar --strip-components 1 -C "${local_cuba_dir}" --strip=1 -x -z) \
&& (
cd "${local_cuba_dir}" \
&& CFLAGS="-fPIC -O3 -fomit-frame-pointer -ffast-math -Wall" ./configure \
&& make lib
)
ARFLAGS=ARFLAGS_OLD
else
AC_MSG_NOTICE([Reusing existing local cuba build in $local_cuba_dir])
fi
elif test -n "$with_cuba"; then
use_cuba=yes
else
use_cuba=no
fi
dnl Save compiler/linker flags before modifications for cuba:
CPPFLAGS_BACKUP="$CPPFLAGS"
CXXFLAGS_BACKUP="$CXXFLAGS"
LDFLAGS_BACKUP="$LDFLAGS"
LIBS_BACKUP="$LIBS"
if test "x$use_cuba" != xno; then
dnl check to see if lib and include can be determined automatically from $with_cuba
dnl if cuba just compiled, everything is in one directory
if test -z "$with_cuba_include_dir" ; then
if test -d "$with_cuba/include" ; then
with_cuba_include_dir="$with_cuba/include"
elif test -d $with_cuba ; then
with_cuba_include_dir="$with_cuba"
fi
fi
if test -z "$with_cuba_lib_dir" ; then
if test -d "$with_cuba/lib" ; then
with_cuba_lib_dir="$with_cuba/lib"
elif test -d $with_cuba ; then
with_cuba_lib_dir="$with_cuba"
fi
fi
cubaincflags=""
if test -n "$with_cuba_include_dir"; then
echo "checking for cuba.h in $with_cuba_include_dir"
cubaincflags=-I$with_cuba_include_dir
CPPFLAGS+=" $cubaincflags"
CXXFLAGS+=" $cubaincflags"
else
echo "checking for cuba.h in system default directories"
fi
AC_CHECK_HEADERS(cuba.h, [], [AC_MSG_ERROR([Could not find cuba.h; use --with-cuba[[-include-dir]]=DIR or compile without cuba])])
cubaldflags=""
if test -n "$with_cuba_lib_dir"; then
echo "checking for cuba library in path $with_cuba_lib_dir"
cubaldflags="-L$with_cuba_lib_dir -lcuba"
LDFLAGS+=" $cubaldflags"
else
echo "checking for cuba library in system default directories"
fi
dnl Check for the right CUBA interface
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
[[
#include <cuba.h>
int integrand(const int * ndim, const double xx[], const int * ncomp, double ff[], void * userdata){return 0;}
int main()
{
int ndim, ncomp, nvec, flags, seed, mineval, maxeval, nnew;
double epsrel, epsabs, flatness;
int * nregions, *fail, *neval;
double * integral, *error, *prob;
const char * statefile = "";
void * userdata;
Suave(ndim, ncomp, &integrand, userdata, nvec,
epsrel, ebsabs, flags, seed, mineval, maxeval,
nnew, flatness, statefile,
nregions, neval, fail, integral, error, prob);
return 0;
}
]]
)],
[cuba_version=3.3
AC_DEFINE([CUBAVERSION], [33], [cuba interface version 3.3 detected])],
[])
if test x$cuba_version = x; then
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
[[
#include <cuba.h>
int integrand(const int * ndim, const double xx[], const int * ncomp, double ff[], void * userdata){return 0;}
int main()
{
int ndim, ncomp, nvec, flags, seed, mineval, maxeval, nnew, spin;
double epsrel, epsabs, flatness;
int * nregions, *fail, *neval;
double * integral, *error, *prob;
const char * statefile = "";
void * userdata;
Suave(ndim, ncomp, &integrand, userdata, nvec,
epsrel, ebsabs, flags, seed, mineval, maxeval,
nnew, flatness, statefile,
spin, /*spin was added in 4.0 */
nregions, neval, fail, integral, error, prob);
return 0;
}
]]
)],
[cuba_version=4.0
AC_DEFINE([CUBAVERSION], [40], [cuba interface version 4.0 detected])],
[])
fi
if test x$cuba_version = x; then
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
[[
#include <cuba.h>
int integrand(const int * ndim, const double xx[], const int * ncomp, double ff[], void * userdata){return 0;}
int main()
{
int ndim, ncomp, nvec, flags, seed, mineval, maxeval, nnew, nmin, spin;
double epsrel, epsabs, flatness;
int * nregions, *fail, *neval;
double * integral, *error, *prob;
const char * statefile = "";
void * userdata;
Suave(ndim, ncomp, &integrand, userdata, nvec,
epsrel, epsabs, flags, seed, mineval, maxeval, nnew,
nmin, /* nmin added in 4.1 */
flatness, statefile, spin,
nregions, neval, fail, integral, error, prob);
return 0;
}
]]
)],
[cuba_version=4.1
AC_DEFINE([CUBAVERSION], [41], [cuba interface version 4.1 detected])],
[])
fi
if test x$cuba_version = x; then
AC_MSG_ERROR([This version of cuba does not match
the interface of the supported version $cuba_min_version or later])
else
echo detected cuba matching the interface of version $cuba_version
fi
AC_CHECK_LIB(cuba,main,[],[AC_MSG_ERROR([Could not find libcuba.a; use --with-cuba-lib-dir=DIR or compile without cuba])])
AC_SUBST(CUBAINCLUDE,[$cubaincflags])
AC_SUBST(CUBALIB,[$cubaldflags])
dnl passed all tests, so build with cuba
AM_CONDITIONAL([CUBA], [test 1 -eq 1])
else
echo compiling without cuba
AM_CONDITIONAL([CUBA], [test 1 -eq 0])
fi
dnl back to C++
AC_LANG_POP([C])
dnl Restore compiler/linker flags (without cuba additions):
CPPFLAGS="$CPPFLAGS_BACKUP"
CXXFLAGS="$CXXFLAGS_BACKUP"
LDFLAGS="$LDFLAGS_BACKUP"
LIBS="$LIBS_BACKUP"
dnl
dnl Check for ROOT
dnl
AC_DEFUN(
[REQUIRE_ROOT_VERSION],
[require_ROOT_version=$1]
)
REQUIRE_ROOT_VERSION([5.34.19])
dnl RooStats
AC_ARG_ENABLE(
[roostats],
[AS_HELP_STRING([--enable-roostats],[compile with RooStats support (default: no)])],
[
use_roostats=${enableval};
],
[use_roostats=no]
)
dnl ROOT
m4_include(tools/build/root.m4)
ROOT_PATH(
$require_ROOT_version,
,
[
AC_MSG_ERROR([ROOT cannot be found. Please ensure that it is installed
and that either \$ROOTSYS is defined correctly or root-config is in the path.
One can pass --with-rootsys=/path/to/rootsys to configure as well.])
exit
]
)
dnl add some libraries to set of basic root libraries
ROOTLIBS="$ROOTLIBS -lMinuit"
dnl mathmore is a requirement of roostats and allows us to use
dnl features from the GSL. The check is done again inside HAS_ROOSTATS
dnl but we can't get that result. So the output `checking whether ROOT
dnl is compiled with MathMore support... ` can appear twice. No big deal.
AC_MSG_CHECKING(whether ROOT is compiled with MathMore support)
hasmathmore=`$ROOTCONF --has-mathmore`
AC_MSG_RESULT($hasmathmore)
if test x$hasmathmore = xyes; then
ROOTLIBS="$ROOTLIBS -lMathMore"
AC_DEFINE([ROOTMATHMORE], 1, [ROOT MathMore available])
fi
AM_CONDITIONAL([ROOTMATHMORE], [test x$hasmathmore = xyes])
dnl RooFit
if test x$use_roostats = xyes; then
HAS_ROOSTATS(
AC_MSG_RESULT([Compiling BAT with RooStats support.]),
[
AC_MSG_RESULT([ROOT was compiled without RooFit support.])
AC_MSG_RESULT([To add RooStats support, recompile ROOT or provide path to different version.])
AC_MSG_RESULT([Compiling BAT without RooStats support.])
use_roostats=no
]
)
fi
AM_CONDITIONAL([ROOSTATS], [test x$use_roostats = xyes])
if test x$use_roostats = xyes; then
ROOTLIBS="$ROOTLIBS -lRooFitCore -lRooFit -lRooStats -lFoam"
fi
USE_RPATH="no"
ROOTLIBDIRFLAGS="-L$ROOTLIBDIR"
PKG_LIBS="-lBAT -lBATmodels -lBATmtf"
case "${host_os}" in
darwin*)
USE_RPATH="yes"
ROOTLIBDIRFLAGS="-Wl,-rpath,$ROOTLIBDIR ${ROOTLIBDIRFLAGS}"
PKG_LIBS="-Wl,-rpath,\${libdir} ${PKG_LIBS}"
;;
esac
AM_CONDITIONAL([COND_USE_RPATH], [test "$USE_RPATH" = "yes"])
AC_SUBST(ROOTLIBDIRFLAGS)
AC_SUBST(PKG_LIBS)
DEP_CFLAGS="$DEP_CFLAGS $ROOTAUXCFLAGS $ROOTCFLAGS"
DEP_LIBS="$DEP_LIBS $ROOTLIBDIRFLAGS $ROOTLIBS"
AC_SUBST(DEP_CFLAGS)
AC_SUBST(DEP_LIBS)
AC_CHECK_PROGS(PKGCONFIG, pkg-config, false)
AM_CONDITIONAL([COND_PKGCONFIG], [test "$PKGCONFIG" != "false"])
dnl files that may not be part of the release but exist only in a checkout of the source repository
if test -f "$srcdir/doc/introduction/versions.tex.in" ; then
AC_OUTPUT(doc/introduction/versions.tex)
fi
dnl directories needed to store output files (e.g. from unit tests) in the proper place
AC_DEFINE_UNQUOTED([BAT_BUILDDIR], "$ac_pwd", [Absolute path to the build directory])
AC_DEFINE_UNQUOTED([BAT_SRCDIR], "`readlink -f $ac_pwd/$srcdir`", [Absolute path to the top-level source directory])
AC_DEFINE_UNQUOTED([BAT_TESTDIR], "$ac_pwd/test/", [Absolute path to the test directory])
AC_OUTPUT(
Makefile
bat.pc
bat-config
test-env.sh
src/Makefile
models/base/Makefile
models/mtf/Makefile
test/Makefile
tools/MakefileTemplate
examples/Makefile
examples/basic/Makefile
examples/basic/binomial/Makefile
examples/basic/combination1d/Makefile
examples/basic/combination2d/Makefile
examples/basic/efficiencyFitter/Makefile
examples/basic/errorPropagation/Makefile
examples/basic/graphFitter/Makefile
examples/basic/histogramFitter/Makefile
examples/basic/poisson/Makefile
examples/basic/rootOutput/Makefile
examples/advanced/Makefile
examples/advanced/advancedGraphFitter/Makefile
examples/advanced/mtf/Makefile
examples/advanced/mtf/ensembleTest/Makefile
examples/advanced/mtf/mcstat/Makefile
examples/advanced/mtf/singleChannel/Makefile
examples/advanced/mtf/systematics/Makefile
examples/advanced/mtf/twoChannels/Makefile
examples/advanced/polynomialFit/Makefile
examples/advanced/referenceCounting/Makefile
examples/advanced/rooInterface/Makefile
examples/advanced/trialFunction/Makefile
)