this repo has no description
1dnl
2dnl Main authors:
3dnl Guido Tack <tack@gecode.org>
4dnl
5dnl Contributing authors:
6dnl Samuel Gagnon <samuel.gagnon92@gmail.com>
7dnl Mikael Lagerkvist <lagerkvist@gecode.org>
8dnl
9dnl Copyright:
10dnl Guido Tack, 2004, 2005
11dnl Samuel Gagnon, 2018
12dnl Mikael Lagerkvist, 2020
13dnl
14dnl This file is part of Gecode, the generic constraint
15dnl development environment:
16dnl http://www.gecode.org
17dnl
18dnl Permission is hereby granted, free of charge, to any person obtaining
19dnl a copy of this software and associated documentation files (the
20dnl "Software"), to deal in the Software without restriction, including
21dnl without limitation the rights to use, copy, modify, merge, publish,
22dnl distribute, sublicense, and/or sell copies of the Software, and to
23dnl permit persons to whom the Software is furnished to do so, subject to
24dnl the following conditions:
25dnl
26dnl The above copyright notice and this permission notice shall be
27dnl included in all copies or substantial portions of the Software.
28dnl
29dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32dnl NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33dnl LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34dnl OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35dnl WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36dnl
37dnl
38
39AC_DEFUN([AC_GECODE_GET_OS],
40 [AC_ARG_WITH([host-os],
41 AC_HELP_STRING([--with-host-os],
42 [Override operating system test. Valid values are Linux, Darwin, FreeBSD, NetBSD, and Windows.]))
43 AC_MSG_CHECKING([for the host operating system])
44 if test "${with_host_os:-no}" = "no"; then
45 guess_host_os=$(uname -s 2>/dev/null)
46 else
47 guess_host_os=${with_host_os}
48 fi
49 dnl Try to find out operating system
50 case ${guess_host_os} in
51 GNU/kFreeBSD|*inux*|FreeBSD|NetBSD)
52 host_os=linux
53 AC_MSG_RESULT([Linux])
54 ;;
55 *arwin*)
56 host_os=darwin
57 AC_MSG_RESULT([Darwin])
58 ;;
59 CYGWIN*|*indows*)
60 host_os=windows
61 AC_MSG_RESULT([Windows])
62 ;;
63 *)
64 AC_MSG_ERROR([Host OS not supported.])
65 ;;
66 esac])
67
68dnl Macros:
69dnl AC_GECODE_ADD_TO_CXXFLAGS ([FLAG...])
70dnl
71dnl Description:
72dnl Add the flags to the corresponding variables
73dnl
74dnl Author:
75dnl Marco Kuhlmann <kuhlmann@ps.uni-sb.de>
76dnl
77AC_DEFUN([AC_GECODE_ADD_TO_CXXFLAGS],
78 [CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}"])
79AC_DEFUN([AC_GECODE_ADD_TO_COMPILERFLAGS],
80 [CFLAGS="$1${CFLAGS:+ }${CFLAGS}"
81 CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}"])
82AC_DEFUN([AC_GECODE_ADD_TO_CFLAGS],
83 [CFLAGS="$1${CFLAGS:+ }${CFLAGS}"])
84AC_DEFUN([AC_GECODE_ADD_TO_DLLFLAGS],
85 [DLLFLAGS="$1${DLLFLAGS:+ }${DLLFLAGS}"])
86
87
88dnl Macro:
89dnl AC_GECODE_CHECK_MS_CL_FLAG (FLAG, ACTION-IF-TRUE,
90dnl ACTION-IF-FALSE)
91dnl
92dnl Description:
93dnl Check whether FLAG is supported by the Microsoft C++ compiler. Run
94dnl the shell commands ACTION-IF-TRUE if it is, ACTION-IF-FALSE
95dnl otherwise.
96dnl
97dnl Authors:
98dnl Guido Tack <tack@gecode.org>
99dnl
100AC_DEFUN([AC_GECODE_CHECK_MS_CL_FLAG],
101 [AC_MSG_CHECKING(whether ${CXX} accepts [$1])
102 if ${CXX} $1 2>&1 | grep "ignoring unknown option" -q; then
103 AC_MSG_RESULT([no])
104 ifelse([$3], , :, [$3])
105 else
106 AC_MSG_RESULT([yes])
107 ifelse([$2], , :, [$2])
108 fi])
109
110dnl Macro:
111dnl AC_GECODE_CHECK_GXX_FLAG (FLAG, ACTION-IF-TRUE,
112dnl ACTION-IF-FALSE)
113dnl
114dnl Description:
115dnl Check whether FLAG is supported by the Gnu C++ compiler. Run
116dnl the shell commands ACTION-IF-TRUE if it is, ACTION-IF-FALSE
117dnl otherwise.
118dnl
119dnl Authors:
120dnl Guido Tack <tack@gecode.org>
121dnl
122AC_DEFUN([AC_GECODE_CHECK_GXX_FLAG],
123 [AC_MSG_CHECKING(whether ${CXX} accepts [$1])
124 ac_gecode_save_CXXFLAGS="${CXXFLAGS}"
125 CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS} -Werror"
126 AC_LANG_PUSH(C++)
127 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
128 [if grep -q "unrecognized\|argument unused" conftest.err; then
129 CXXFLAGS="${ac_gecode_save_CXXFLAGS}"
130 AC_MSG_RESULT([no])
131 ifelse([$3], , :, [$3])
132 else
133 CXXFLAGS="${ac_gecode_save_CXXFLAGS}"
134 AC_MSG_RESULT([yes])
135 ifelse([$2], , :, [$2])
136 fi
137 ],
138 [CXXFLAGS="${ac_gecode_save_CXXFLAGS}"
139 AC_MSG_RESULT([no])
140 ifelse([$3], , :, [$3])])
141 AC_LANG_POP])
142
143dnl Macro:
144dnl AC_GECODE_CHECK_GCC_FLAG (FLAG, ACTION-IF-TRUE,
145dnl ACTION-IF-FALSE)
146dnl
147dnl Description:
148dnl Check whether FLAG is supported by the Gnu C compiler. Run
149dnl the shell commands ACTION-IF-TRUE if it is, ACTION-IF-FALSE
150dnl otherwise.
151dnl
152dnl Authors:
153dnl Guido Tack <tack@gecode.org>
154dnl
155AC_DEFUN([AC_GECODE_CHECK_GCC_FLAG],[
156 AC_MSG_CHECKING(whether ${CC} accepts [$1])
157 ac_gecode_save_CFLAGS="${CFLAGS}"
158 CFLAGS="$1${CFLAGS:+ }${CFLAGS} -Werror"
159 AC_LANG_PUSH(C)
160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
161 [if grep -q "unrecognized\|argument unused" conftest.err; then
162 CFLAGS="${ac_gecode_save_CFLAGS}"
163 AC_MSG_RESULT([no])
164 ifelse([$3], , :, [$3])
165 else
166 CFLAGS="${ac_gecode_save_CFLAGS}"
167 AC_MSG_RESULT([yes])
168 ifelse([$2], , :, [$2])
169 fi
170 ],
171 [CFLAGS="${ac_gecode_save_CFLAGS}"
172 AC_MSG_RESULT([no])
173 ifelse([$3], , :, [$3])])
174 AC_LANG_POP])
175
176dnl Macro:
177dnl AC_GECODE_CHECK_CXXFLAG (FLAG, [ACTION-IF-TRUE,
178dnl [ACTION-IF-FALSE]])
179dnl
180dnl Description:
181dnl Check whether FLAG is supported by the C++ compiler. Run
182dnl the shell commands ACTION-IF-TRUE if it is, ACTION-IF-FALSE
183dnl otherwise. If ACTION-IF-TRUE is not given, append FLAG to
184dnl the contents of $CXXFLAGS.
185dnl
186dnl Authors:
187dnl Leif Kornstaedt <kornstae@ps.uni-sb.de>
188dnl Marco Kuhlmann <kuhlmann@ps.uni-sb.de>
189dnl
190AC_DEFUN([AC_GECODE_CHECK_CXXFLAG],
191 [if test "${ac_cv_cxx_compiler_vendor}" = "microsoft"; then
192 AC_GECODE_CHECK_MS_CL_FLAG($1,[
193 ifelse([$2], , CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}", [$2])],
194 [ifelse([$3], , :, [$3])])
195 else
196 AC_GECODE_CHECK_GXX_FLAG($1,[
197 ifelse([$2], , CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}", [$2])],
198 [ifelse([$3], , :, [$3])])
199 fi
200 ])dnl
201
202AC_DEFUN([AC_GECODE_CHECK_COMPILERFLAG],
203 [
204 if test "${ac_cv_cxx_compiler_vendor}" = "microsoft"; then
205 AC_GECODE_CHECK_MS_CL_FLAG($1,[
206 CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}"
207 CFLAGS="$1${CFLAGS:+ }${CFLAGS}"],[])
208 else
209 AC_GECODE_CHECK_GXX_FLAG($1,[
210 CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS}"],[])
211 AC_GECODE_CHECK_GCC_FLAG($1,[
212 CFLAGS="$1${CFLAGS:+ }${CFLAGS}"],[])
213 fi])dnl
214
215dnl @synopsis _AC_C_IFDEF(MACRO-NAME, ACTION-IF-DEF, ACTION-IF-NOT-DEF)
216dnl
217dnl Check for the definition of macro MACRO-NAME using the current
218dnl language's compiler.
219dnl
220dnl @category Misc
221dnl @author Ludovic Courtès <ludo@chbouib.org>
222dnl @version 2004-09-07
223dnl @license AllPermissive
224AC_DEFUN([_AC_C_IFDEF],
225 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifndef $1
226 # error "Macro $1 is undefined!"
227 /* For some compilers (eg. SGI's CC), #error is not
228 enough... */
229 please, do fail
230 #endif]],[[]])],
231 [$2], [$3])])
232
233dnl @synopsis AC_CXX_COMPILER_VENDOR(VENDOR-NAME)
234dnl
235dnl Set VENDOR-NAME to the lower-case name of the compiler vendor or `unknown'
236dnl if the compiler's vendor is unknown.
237dnl
238dnl @version 20040907
239dnl @author Ludovic Courtès <ludo@chbouib.org>
240dnl Modified by G. Tack to recognize only those compilers we need.
241AC_DEFUN([AC_ADD_DLL_ARCH],
242 [ac_gecode_library_architecture="-$1${ac_gecode_library_architecture}"])
243
244AC_DEFUN([AC_CXX_COMPILER_VENDOR],
245 [AC_ARG_WITH([compiler-vendor],
246 AC_HELP_STRING([--with-compiler-vendor],
247 [Override compiler test. Valid values are gnu, intel, and microsoft.]))
248 AC_REQUIRE([AC_PROG_CXX])
249 AC_REQUIRE([AC_PROG_CXXCPP])
250 if test "${with_compiler_vendor:-no}" = "no"; then
251 AC_LANG_PUSH([C++])
252 dnl GNU C++
253 _AC_C_IFDEF([__GNUG__],
254 [ac_cv_cxx_compiler_vendor=gnu],
255 [_AC_C_IFDEF([__INTEL_COMPILER],
256 [ac_cv_cxx_compiler_vendor=intel
257 _AC_C_IFDEF([_M_IX86],
258 [AC_ADD_DLL_ARCH([x86])],[])
259 _AC_C_IFDEF([_M_IA64],
260 [AC_ADD_DLL_ARCH([ia64])],[])
261 _AC_C_IFDEF([_M_X64],
262 [AC_ADD_DLL_ARCH([x64])],[])],
263 [dnl Note: We are using the C compiler because VC++ doesn't
264 dnl recognize `.cc'(which is used by `configure') as a C++ file
265 dnl extension and requires `/TP' to be passed.
266 AC_LANG_PUSH([C])
267 _AC_C_IFDEF([_MSC_VER],
268 [ac_cv_cxx_compiler_vendor=microsoft
269 _AC_C_IFDEF([_M_IX86],
270 [AC_ADD_DLL_ARCH([x86])],[])
271 _AC_C_IFDEF([_M_IA64],
272 [AC_ADD_DLL_ARCH([ia64])],[])
273 _AC_C_IFDEF([_M_X64],
274 [AC_ADD_DLL_ARCH([x64])],[])],
275 [ac_cv_cxx_compiler_vendor=unknown])
276 AC_LANG_POP()])])
277
278 AC_LANG_POP()
279 else
280 ac_cv_cxx_compiler_vendor=${with_compiler_vendor}
281 fi
282 $1="$ac_cv_cxx_compiler_vendor"])dnl
283
284
285AC_DEFUN([AC_CHECK_GCC_VERSION],
286 [
287 AC_LANG_PUSH(C)
288 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
289 #if __GNUC__ < $1 || (__GNUC__ == $1 && __GNUC_MINOR__ < $2)
290 #error Version too old
291 really, the version is too old
292 #endif]],[[]])],[],
293 [AC_MSG_ERROR([Your version of gcc is too old. You need at least version $1.$2.])]
294 )
295 AC_LANG_POP()
296 AC_LANG_PUSH(C++)
297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
298 #if __GNUC__ < $1 || (__GNUC__ == $1 && __GNUC_MINOR__ < $2)
299 #error Version too old
300 really, the version is too old
301 #endif]],[[]])],[],
302 [AC_MSG_ERROR([Your version of g++ is too old. You need at least version $1.$2.])]
303 )
304 AC_LANG_POP()
305 ])
306
307AC_DEFUN([AC_CHECK_MSVC_VERSION],
308 [
309 AC_LANG_PUSH(C)
310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
311 #if _MSC_VER < $1
312 #error Version too old
313 really, the version is too old
314 #endif]],[[]])],[],
315 [AC_MSG_ERROR([Your version of cl is too old. You need at least Microsoft Visual C++ $2.])]
316 AC_LANG_POP()
317 )
318 ])
319
320dnl Macro:
321dnl AC_GECODE_VTI (vartype, help-string, default, vtidef,
322dnl [ACTION-IF-ENABLED], [ACTION-IF-DISABLED])
323dnl
324dnl Description:
325dnl Introduce --enable-vartype-vars configure switch. The help-string
326dnl is used for the configure --help output.
327dnl default is either yes or no and says whether this option should be
328dnl enabled by default. ACTION-IF-ENABLED can be used to perform additional
329dnl actions in case this variable type is enabled.
330dnl
331dnl Authors:
332dnl Guido Tack <tack@gecode.org>
333AC_DEFUN([AC_GECODE_ADD_VTI],
334 [AC_DEFINE(GECODE_HAS_$1_VARS, [], [Whether to build $1 variables])])
335AC_DEFUN([AC_GECODE_VIS],[
336 AC_ARG_WITH([vis],
337 AC_HELP_STRING([--with-vis],
338 [additional variable implementation specifications]))
339 if test "${with_vis:-no}" != "no"; then
340 with_vis=${with_vis//,/ }
341 ac_gecode_vis="${with_vis}${ac_gecode_vis:+ }${ac_gecode_vis}"
342 fi])
343AC_DEFUN([AC_GECODE_VTI],
344 [
345 AC_ARG_ENABLE([$1-vars],
346 AC_HELP_STRING([--enable-$1-vars],[build $2 @<:@default=$3@:>@]))
347 ac_gecode_vis="$4${ac_gecode_vis:+ }${ac_gecode_vis}"
348 AC_MSG_CHECKING(whether to build the $1 variables library)
349 if test "${enable_$1_vars:-$3}" = "yes"; then
350 AC_MSG_RESULT(yes)
351 enable_$1_vars="yes";
352 $5
353 AC_GECODE_ADD_VTI(translit($1,`a-z', `A-Z'))
354 else
355 enable_$1_vars="no";
356 $6
357 AC_MSG_RESULT(no)
358 fi
359 AC_SUBST(enable_$1_vars, ${enable_$1_vars})
360 ])
361
362dnl Macro:
363dnl AC_GECODE_ENABLE_MODULE (module, default, help-string,
364dnl [ACTION-IF-ENABLED])
365dnl
366dnl Description:
367dnl Produces a configure switch --enable-<module>.
368dnl
369dnl Authors:
370dnl Guido Tack <tack@gecode.org>
371AC_DEFUN([AC_GECODE_ENABLE_MODULE],
372 [
373 AC_ARG_ENABLE([$1],
374 AC_HELP_STRING([--enable-$1],
375 [$3 @<:@default=$2@:>@]))
376 AC_MSG_CHECKING(whether to build $1)
377 if test "${enable_$1:-$2}" = "yes"; then
378 enable_$1="yes";
379 AC_MSG_RESULT(yes)
380 $4
381 else
382 enable_$1="no";
383 AC_MSG_RESULT(no)
384 fi
385 AC_SUBST(enable_$1, ${enable_$1})])
386
387dnl Description:
388dnl Makes an enable check for a contrib
389dnl The third argument can be used for dependency checking
390dnl
391dnl Authors:
392dnl Grégoire Dooms <dooms@info.ucl.ac.be>
393AC_DEFUN([AC_GECODE_ENABLE_CONTRIB],
394[
395 AC_ARG_ENABLE([$1],
396 AC_HELP_STRING([--enable-$1],[build $2 @<:@default=yes@:>@]))
397 AC_MSG_CHECKING(whether to build the $1 contrib library)
398 if test "${enable_$1:-yes}" = "yes"; then
399 AC_MSG_RESULT(yes)
400 enable_$1="yes";
401 $3
402 else
403 enable_$1="no";
404 AC_MSG_RESULT(no)
405 fi
406 AC_SUBST(enable_$1, ${enable_$1})])
407
408
409AC_DEFUN([AC_GECODE_STATICLIBS],
410 [if test "${host_os}" = "windows" -a \
411 "${ac_gecode_compiler_vendor}" = "gnu"; then
412 enable_static="yes"
413 enable_shared="no"
414 fi
415 AC_ARG_ENABLE([static],
416 AC_HELP_STRING([--enable-static],
417 [build static libraries @<:@default=no@:>@]))
418 AC_MSG_CHECKING(whether to build static libraries)
419 if test "${enable_static:-no}" = "yes"; then
420 AC_DEFINE([GECODE_STATIC_LIBS],[],
421 [Whether we are compiling static libraries])
422 AC_SUBST(BUILDSTATIC, "yes")
423 AC_MSG_RESULT(yes)
424 enable_shared=no
425 else
426 AC_SUBST(BUILDSTATIC, "no")
427 enable_shared=yes
428 AC_MSG_RESULT(no)
429 fi
430 AC_ARG_ENABLE([shared],
431 AC_HELP_STRING([--enable-shared],
432 [build shared libraries @<:@default=yes@:>@]))
433 AC_MSG_CHECKING(whether to build shared libraries)
434 if test "${enable_shared:-yes}" = "yes"; then
435 AC_SUBST(BUILDDLL, "yes")
436 AC_MSG_RESULT(yes)
437 else
438 AC_SUBST(BUILDDLL, "no")
439 if test "${enable_static:-no}" = "no"; then
440 AC_MSG_ERROR([One of --enable-static or --enable-shared must be given])
441 fi
442 AC_MSG_RESULT(no)
443 fi
444 ])
445
446AC_DEFUN([AC_GECODE_CODESIZE],
447 [AC_ARG_ENABLE([small-codesize],
448 AC_HELP_STRING([--enable-small-codesize],
449 [optimize for code size @<:@default=no@:>@]))
450 AC_MSG_CHECKING(whether to optimize for code size)
451 if test "${enable_debug:-no}" = "yes"; then
452 AC_MSG_RESULT(not in debug builds)
453 elif test "${enable_small_codesize:-no}" = "yes"; then
454 AC_MSG_RESULT(yes)
455 case $host_os in
456 darwin*)
457 ac_gecode_gcc_optimize_flag=-Oz
458 ;;
459 *)
460 ac_gecode_gcc_optimize_flag=-Os
461 ac_gecode_cl_optimize_flag=-O1
462 ;;
463 esac
464 else
465 AC_MSG_RESULT(no)
466 ac_gecode_gcc_optimize_flag=-O3
467 ac_gecode_cl_optimize_flag=-O2
468 fi])
469
470
471AC_DEFUN([AC_GECODE_DEBUG],
472 [AC_ARG_ENABLE([debug],
473 AC_HELP_STRING([--enable-debug],
474 [build with assertions @<:@default=no@:>@]))
475 AC_MSG_CHECKING(whether to build with debug symbols and assertions)
476 if test "${enable_debug:-no}" = "yes"; then
477 AC_ADD_DLL_ARCH([d])
478 AC_SUBST(DEBUG_BUILD, [yes])
479 AC_MSG_RESULT(yes)
480 else
481 AC_ADD_DLL_ARCH([r])
482 AC_SUBST(DEBUG_BUILD, [no])
483 AC_MSG_RESULT(no)
484 AC_GECODE_ADD_TO_COMPILERFLAGS(-DNDEBUG)
485 fi])
486
487AC_DEFUN([AC_GECODE_LEAK_DEBUG],
488 [AC_ARG_ENABLE([leak-debug],
489 AC_HELP_STRING([--enable-leak-debug],
490 [build with support for finding memory leaks @<:@default=no@:>@]))
491 AC_MSG_CHECKING(whether to build with support for finding memory leaks)
492 if test "${enable_leak_debug:-no}" = "yes"; then
493 AC_MSG_RESULT(yes)
494 AC_CHECK_DECL(mtrace,
495 [AC_DEFINE([GECODE_HAS_MTRACE],[],
496 [Whether we have mtrace for memory leak debugging])],
497 [AC_MSG_ERROR(mtrace not available.)],
498 [[#include <mcheck.h>]])
499 else
500 AC_MSG_RESULT(no)
501 fi])
502
503AC_DEFUN([AC_GECODE_PEAKHEAP],
504 [AC_ARG_ENABLE([peakheap],
505 AC_HELP_STRING([--enable-peakheap],
506 [build with peak heap size tracking @<:@default=no@:>@]))
507 if test "${enable_peakheap:-no}" = "yes"; then
508 AC_CHECK_FUNC(_msize,
509 [
510 AC_DEFINE([GECODE_PEAKHEAP],[],[Whether to track peak heap size])
511 AC_DEFINE([GECODE_PEAKHEAP_MALLOC_H],[],[Whether we need malloc.h])
512 AC_DEFINE([GECODE_MSIZE],[_msize],[How to check allocation size])
513 AC_MSG_CHECKING(whether to build with peak heap size tracking)
514 AC_MSG_RESULT(yes)
515 ],
516 [
517 AC_CHECK_HEADERS([malloc/malloc.h],
518 [
519 AC_CHECK_FUNC(malloc_size,
520 [
521 AC_DEFINE([GECODE_PEAKHEAP],[],[])
522 AC_DEFINE([GECODE_PEAKHEAP_MALLOC_MALLOC_H],[],[Whether we need malloc/malloc.h])
523 AC_DEFINE([GECODE_MSIZE],[malloc_size],[])
524 AC_MSG_CHECKING(whether to build with peak heap size tracking)
525 AC_MSG_RESULT(yes)
526 ],
527 [
528 AC_MSG_CHECKING(whether to build with peak heap size tracking)
529 AC_MSG_RESULT(no)
530 ])
531 ],
532 [
533 AC_CHECK_HEADERS([malloc.h],
534 [
535 AC_CHECK_FUNC(malloc_usable_size,
536 [
537 AC_DEFINE([GECODE_PEAKHEAP],[],[])
538 AC_DEFINE([GECODE_PEAKHEAP_MALLOC_H],[],[Whether we need malloc.h])
539 AC_DEFINE([GECODE_MSIZE],[malloc_usable_size],[])
540 AC_MSG_CHECKING(whether to build with peak heap size tracking)
541 AC_MSG_RESULT(yes)
542 ],
543 [
544 AC_MSG_CHECKING(whether to build with peak heap size tracking)
545 AC_MSG_RESULT(no)
546 ])
547 ],
548 [
549 AC_MSG_CHECKING(whether to build with peak heap size tracking)
550 AC_MSG_RESULT(no)
551 ])
552 ]
553 )
554 ])
555 else
556 AC_MSG_CHECKING(whether to build with peak heap size tracking)
557 AC_MSG_RESULT(no)
558 fi])
559
560AC_DEFUN([AC_GECODE_ALLOCATOR],
561 [AC_ARG_ENABLE([allocator],
562 AC_HELP_STRING([--enable-allocator],
563 [build with default memory allocator @<:@default=yes@:>@]))
564 AC_MSG_CHECKING(whether to build with default memory allocator)
565 if test "${enable_allocator:-yes}" = "yes"; then
566 AC_DEFINE([GECODE_ALLOCATOR],[],
567 [Whether to build with default memory allocator])
568 AC_MSG_RESULT(yes)
569 else
570 AC_MSG_RESULT(no)
571 fi])
572
573
574AC_DEFUN([AC_GECODE_AUDIT],
575 [AC_ARG_ENABLE([audit],
576 AC_HELP_STRING([--enable-audit],
577 [build with auditing code @<:@default=no@:>@]))
578 AC_MSG_CHECKING(whether to build with auditing code)
579 if test "${enable_audit:-no}" = "yes"; then
580 AC_DEFINE([GECODE_AUDIT],[],
581 [Whether to include audit code])
582 AC_MSG_RESULT(yes)
583 else
584 AC_MSG_RESULT(no)
585 fi])
586
587
588AC_DEFUN([AC_GECODE_PROFILE],
589 [AC_ARG_ENABLE([profile],
590 AC_HELP_STRING([--enable-profile],
591 [build with profiling information @<:@default=no@:>@]))
592 AC_MSG_CHECKING(whether to build with profiling information)
593 if test "${enable_profile:-no}" = "yes"; then
594 AC_MSG_RESULT(yes)
595 AC_GECODE_CHECK_CXXFLAG(-pg,
596 AC_GECODE_ADD_TO_COMPILERFLAGS(-pg),
597 AC_GECODE_CHECK_COMPILERFLAG(-p))
598 else
599 AC_MSG_RESULT(no)
600 fi])
601
602AC_DEFUN([AC_GECODE_GCOV],
603 [AC_ARG_ENABLE([gcov],
604 AC_HELP_STRING([--enable-gcov],
605 [build with gcov support @<:@default=no@:>@]))
606 AC_MSG_CHECKING(whether to build with gcov support)
607 if test "${enable_gcov:-no}" = "yes"; then
608 AC_MSG_RESULT(yes)
609 AC_GECODE_CHECK_COMPILERFLAG(-fprofile-arcs)
610 AC_GECODE_CHECK_COMPILERFLAG(-ftest-coverage)
611 AC_GECODE_ADD_TO_DLLFLAGS("-fprofile-arcs")
612 AC_GECODE_ADD_TO_DLLFLAGS("-ftest-coverage")
613 else
614 AC_MSG_RESULT(no)
615 fi])
616
617AC_DEFUN([AC_GECODE_FREELIST_32_SIZE],
618 [dnl max size of freelist on 32 bit platforms
619 AC_ARG_WITH([freelist32-size-max],
620 AC_HELP_STRING([--with-freelist32-size-max],
621 [max size of freelist on 32 bit platforms]))
622 if test "${with_freelist32_size_max:-no}" != "no"; then
623 AC_DEFINE_UNQUOTED([GECODE_FREELIST_SIZE_MAX32],[${with_freelist32_size_max}],[max freelist size on 32 bit platforms])
624 fi
625 ]
626)
627
628AC_DEFUN([AC_GECODE_FREELIST_64_SIZE],
629 [dnl max size of freelist on 64 bit platforms
630 AC_ARG_WITH([freelist64-size-max],
631 AC_HELP_STRING([--with-freelist64-size-max],
632 [max size of freelist on 64 bit platforms]))
633 if test "${with_freelist64_size_max:-no}" != "no"; then
634 AC_DEFINE_UNQUOTED([GECODE_FREELIST_SIZE_MAX64],[${with_freelist64_size_max}],[max freelist size on 64 bit platforms])
635 fi
636 ]
637)
638
639# Test for platform specific behaviour of arithmetic
640
641AC_DEFUN([AC_GECODE_CHECK_ARITH],
642 [AC_LANG_PUSH([C])
643 AC_CHECK_SIZEOF(int)
644 AC_MSG_CHECKING([if int has at least 32 bit])
645 AC_TRY_COMPILE([],
646 [
647 #if SIZEOF_INT>=4
648 #else
649 blablub
650 #endif
651 ],
652 [AC_MSG_RESULT(yes)],
653 [AC_MSG_ERROR([Gecode needs at least 32 bit integers.])])
654
655 AC_MSG_CHECKING([if doubles have a big enough mantissa])
656 AC_TRY_COMPILE([#include <float.h>],
657 [
658 #if DBL_MANT_DIG>=53
659 #else
660 blablub
661 #endif
662 ],
663 [AC_MSG_RESULT(yes)],
664 [AC_MSG_ERROR([Gecode needs a double mantissa of at least 53 bits.])])
665
666 AC_LANG_POP([C])])
667
668AC_DEFUN([AC_GECODE_GCC_GENERAL_SWITCHES],
669 [AC_GECODE_CHECK_COMPILERFLAG([-fPIC])
670 AC_GECODE_CHECK_COMPILERFLAG([-Wextra])
671 AC_GECODE_CHECK_COMPILERFLAG([-Wall])
672 AC_GECODE_CHECK_COMPILERFLAG([-Wno-unknown-pragmas])
673 AC_GECODE_CHECK_COMPILERFLAG([-pipe])
674
675 AC_ARG_ENABLE([cpp11],
676 AC_HELP_STRING([--enable-cpp11],
677 [compile for C++11 standard @<:@default=yes@:>@]))
678 if test "${enable_cpp11:-yes}" = "yes"; then
679 AC_GECODE_CHECK_COMPILERFLAG([-std=c++11])
680 else
681 AC_MSG_CHECKING(whether to compile for C++11 standard)
682 AC_MSG_RESULT(no)
683 fi
684
685 AC_GECODE_CHECK_CXXFLAG(-ggdb,
686 AC_GECODE_ADD_TO_COMPILERFLAGS(-ggdb),
687 AC_GECODE_CHECK_COMPILERFLAG(-g))
688 AC_CHECK_FUNC([__builtin_ffsll],
689 [AC_DEFINE([GECODE_HAS_BUILTIN_FFSLL],[],
690 [whether __builtin_ffsll is available])])
691 AC_CHECK_FUNC([__builtin_popcountll],
692 [AC_DEFINE([GECODE_HAS_BUILTIN_POPCOUNTLL],[],
693 [whether __builtin_popcountll is available])])
694
695 AC_SUBST(docdir, "${datadir}/doc/gecode")
696
697 dnl do not use manifest tool with gcc
698 AC_SUBST(MANIFEST, "@true")
699
700 dnl file extensions
701 AC_SUBST(SBJEXT, "s")
702 AC_SUBST(LIBEXT, "${DLLEXT}")
703 AC_SUBST(LIBPREFIX, "lib${ac_gecode_userprefix}gecode")
704 AC_SUBST(STATICLIBEXT, "a")
705 AC_SUBST(MINUSLDIR, "-L${libdir}")
706 AC_SUBST(LINKLIBDIR, "")
707
708 cygpathprefix=$prefix
709 test "x$cygpathprefix" = xNONE && cygpathprefix=$ac_default_prefix
710 AC_SUBST(cygpathprefix, "${cygpathprefix}")
711
712 AC_SUBST(COMPILEOBJ, "-c -o ")
713 AC_SUBST(COMPILESBJ, "-S -o ")
714 AC_SUBST(CXXIN, " ")
715 AC_SUBST(CCIN, " ")
716 AC_SUBST(EXAMPLES_EXTRA_CXXFLAGS, "")
717
718 dnl Do not install stub .lib files (required for msvc)
719 AC_SUBST(INSTALLLIBS, "no")
720
721 AC_SUBST(LINKPREFIX, "-l${ac_gecode_userprefix}gecode")
722 AC_SUBST(LINKSUFFIX, "")
723
724 dnl how to tell the compiler to output an object file
725 AC_SUBST(LINKOUTPUT, "-o ")
726 dnl how to tell the compiler to output an executable
727 AC_SUBST(EXEOUTPUT, "-o ")
728
729 dnl the names of the generated dlls
730 AC_SUBST(SUPPORT, "support")
731 AC_SUBST(KERNEL, "kernel")
732 AC_SUBST(SEARCH, "search")
733 AC_SUBST(INT, "int")
734 AC_SUBST(FLOAT, "float")
735 AC_SUBST(SET, "set")
736 AC_SUBST(MM, "minimodel")
737 AC_SUBST(GIST, "gist")
738 AC_SUBST(FLATZINC, "flatzinc")
739 AC_SUBST(DRIVER, "driver")])
740
741
742AC_DEFUN([AC_GECODE_GCC_OPTIMIZED_SWITCHES],
743 [AC_MSG_CHECKING([if compiler supports forced inlining])
744 AC_LANG_PUSH([C++])
745 ac_gecode_save_CXXFLAGS="${CXXFLAGS}"
746 CXXFLAGS="$1${CXXFLAGS:+ }${CXXFLAGS} -Werror"
747 _AC_C_IFDEF([__clang__],
748 [AC_MSG_RESULT(no)
749 AC_DEFINE(forceinline, [inline],
750 [How to tell the compiler to really, really inline])],
751 [AC_COMPILE_IFELSE(
752 [AC_LANG_PROGRAM([
753 [inline __attribute__ ((__always_inline__)) void foo(void) {}]],
754 [])],
755 [AC_MSG_RESULT(yes)
756 AC_DEFINE(forceinline, [inline __attribute__ ((__always_inline__))],
757 [How to tell the compiler to really, really inline])],
758 [AC_MSG_RESULT(no)
759 AC_DEFINE(forceinline, [inline],
760 [How to tell the compiler to really, really inline])])])
761 CXXFLAGS=${ac_gecode_save_CXXFLAGS}
762 AC_LANG_POP([C++])
763 AC_GECODE_CHECK_COMPILERFLAG([${ac_gecode_gcc_optimize_flag}])
764 AC_GECODE_CHECK_COMPILERFLAG([-fno-strict-aliasing])])
765
766AC_DEFUN([AC_GECODE_GCC_VISIBILITY],
767 [AC_ARG_ENABLE([gcc-visibility],
768 AC_HELP_STRING([--enable-gcc-visibility],
769 [use gcc visibility attributes @<:@default=yes@:>@]))
770 AC_MSG_CHECKING(whether to use gcc visibility attributes)
771 if test "${enable_gcc_visibility:-yes}" = "yes"; then
772 AC_MSG_RESULT(yes)
773 AC_GECODE_CHECK_CXXFLAG([-fvisibility=hidden],
774 [AC_DEFINE([GECODE_GCC_HAS_CLASS_VISIBILITY],[],
775 [Whether gcc understands visibility attributes])
776 AC_GECODE_ADD_TO_COMPILERFLAGS([-fvisibility=hidden])],
777 [])
778 else
779 AC_MSG_RESULT(no)
780 fi])
781
782AC_DEFUN([AC_GECODE_GCC_DEBUG_SWITCHES],
783 [AC_DEFINE(forceinline, [inline],
784 [How to tell the compiler to really, really inline])
785 AC_GECODE_CHECK_COMPILERFLAG([-fno-inline-functions])
786 AC_GECODE_CHECK_COMPILERFLAG([-fimplement-inlines])])
787
788AC_DEFUN([AC_GECODE_NO_BUILDFLAGS],
789 [AC_SUBST(GECODE_BUILD_SUPPORT_FLAG, "")
790 AC_SUBST(GECODE_BUILD_KERNEL_FLAG, "")
791 AC_SUBST(GECODE_BUILD_SEARCH_FLAG, "")
792 AC_SUBST(GECODE_BUILD_INT_FLAG, "")
793 AC_SUBST(GECODE_BUILD_FLOAT_FLAG, "")
794 AC_SUBST(GECODE_BUILD_SET_FLAG, "")
795 AC_SUBST(GECODE_BUILD_MINIMODEL_FLAG, "")
796 AC_SUBST(GECODE_BUILD_GIST_FLAG, "")
797 AC_SUBST(GECODE_BUILD_FLATZINC_FLAG, "")
798 AC_SUBST(GECODE_BUILD_DRIVER_FLAG, "")])
799
800AC_DEFUN([AC_GECODE_BUILDFLAGS],
801 [AC_SUBST(GECODE_BUILD_SUPPORT_FLAG, "-DGECODE_BUILD_SUPPORT")
802 AC_SUBST(GECODE_BUILD_KERNEL_FLAG, "-DGECODE_BUILD_KERNEL")
803 AC_SUBST(GECODE_BUILD_SEARCH_FLAG, "-DGECODE_BUILD_SEARCH")
804 AC_SUBST(GECODE_BUILD_INT_FLAG, "-DGECODE_BUILD_INT")
805 AC_SUBST(GECODE_BUILD_FLOAT_FLAG, "-DGECODE_BUILD_FLOAT")
806 AC_SUBST(GECODE_BUILD_SET_FLAG, "-DGECODE_BUILD_SET")
807 AC_SUBST(GECODE_BUILD_MINIMODEL_FLAG, "-DGECODE_BUILD_MINIMODEL")
808 AC_SUBST(GECODE_BUILD_GIST_FLAG, "-DGECODE_BUILD_GIST")
809 AC_SUBST(GECODE_BUILD_FLATZINC_FLAG, "-DGECODE_BUILD_FLATZINC")
810 AC_SUBST(GECODE_BUILD_DRIVER_FLAG, "-DGECODE_BUILD_DRIVER")])
811
812
813AC_DEFUN([AC_GECODE_UNIX_PATHS],
814 [AC_SUBST(DLLPATH, [-L.])
815 dnl flags for creating dlls
816 case $host_os in
817 darwin*)
818 AC_SUBST(need_soname, "yes")
819 AC_GECODE_ADD_TO_DLLFLAGS([-Wl,-single_module])
820 AC_GECODE_ADD_TO_DLLFLAGS("-dynamiclib")
821 AC_SUBST(DLLEXT, "${ac_gecode_soversion}.0.dylib")
822 AC_SUBST(SOSUFFIX, ".${ac_gecode_soversion}.dylib")
823 AC_SUBST(SOLINKSUFFIX, ".dylib")
824 AC_SUBST(sharedlibdir, "${libdir}")
825 AC_SUBST(WLSONAME, "-compatibility_version ${ac_gecode_soversion}.0 -current_version ${ac_gecode_soversion}.0 -install_name ${libdir}/")
826 AC_GECODE_NO_BUILDFLAGS
827 ;;
828 windows*)
829 AC_SUBST(need_soname, "no")
830 if test "${enable_static:-no}" = "yes" -a \
831 "${enable_shared:-yes}" = "yes"; then
832 AC_MSG_ERROR([Only either static or shared libraries can be built.])
833 fi
834 AC_GECODE_ADD_TO_DLLFLAGS("-shared")
835 AC_SUBST(DLLEXT, "dll")
836 AC_SUBST(SOSUFFIX, "")
837 AC_SUBST(SOLINKSUFFIX, "")
838 AC_SUBST(WLSONAME, "")
839 if test "${enable_static:-no}" = "no"; then
840 AC_SUBST(sharedlibdir, "${bindir}")
841 else
842 AC_SUBST(sharedlibdir, "${libdir}")
843 fi
844 AC_GECODE_BUILDFLAGS
845 ;;
846 *)
847 AC_SUBST(need_soname, "yes")
848 AC_GECODE_ADD_TO_DLLFLAGS("-shared")
849 AC_SUBST(DLLEXT, "so.${ac_gecode_soversion}.0")
850 AC_SUBST(SOSUFFIX, ".so.${ac_gecode_soversion}")
851 AC_SUBST(SOLINKSUFFIX, ".so")
852 AC_SUBST(WLSONAME, ["-Wl,-soname="])
853 AC_SUBST(sharedlibdir, "${libdir}")
854 AC_GECODE_NO_BUILDFLAGS
855 ;;
856 esac])
857
858AC_DEFUN([AC_GECODE_MSVC_SWITCHES],
859 [dnl general compiler flags
860 AC_DEFINE(forceinline,[__forceinline])
861 AC_GECODE_ADD_TO_COMPILERFLAGS([-nologo -bigobj])
862 AC_GECODE_ADD_TO_CFLAGS([-D_CRT_SECURE_NO_DEPRECATE])
863 AC_GECODE_ADD_TO_CXXFLAGS([-EHsc])
864 AC_DEFINE([GECODE_MEMORY_ALIGNMENT], [sizeof(void*)],
865 [Heap memory alignment])
866 if test "${enable_debug:-no}" = "no"; then
867 dnl compiler flags for an optimized build
868 AC_GECODE_ADD_TO_COMPILERFLAGS([${ac_gecode_cl_optimize_flag}])
869 AC_GECODE_ADD_TO_COMPILERFLAGS([-MD -GS- -wd4355 -wd4068])
870 AC_GECODE_CHECK_COMPILERFLAG([-arch:SSE2])
871
872 dnl flags for creating optimized dlls
873 AC_GECODE_ADD_TO_DLLFLAGS([${CXXFLAGS} -LD])
874 dnl linker flags
875 GLDFLAGS="-link -DEBUG -OPT:REF -OPT:ICF -MANIFEST -INCREMENTAL:NO"
876 else
877 dnl compiler flags for a debug build
878 AC_GECODE_ADD_TO_COMPILERFLAGS([-MDd -Zi -wd4355 -wd4068])
879
880 dnl flags for creating debug dlls
881 AC_GECODE_ADD_TO_DLLFLAGS([${CXXFLAGS} -LDd])
882 GLDFLAGS="-link -MANIFEST -INCREMENTAL:NO"
883 fi
884
885 AC_SUBST(sharedlibdir, "${bindir}")
886 AC_SUBST(docdir, "${prefix}")
887 if test "${enable_static:-no}" = "yes"; then
888 AC_MSG_ERROR([Static linking not supported for Windows/cl.])
889 fi
890
891 AC_CHECK_PROG(MANIFEST, mt.exe, mt.exe)
892
893 AC_SUBST(DLLPATH, "")
894
895 dnl file extensions
896 AC_SUBST(SBJEXT, "sbj")
897 AC_SUBST(DLLEXT, "dll")
898 AC_SUBST(SOSUFFIX, "")
899 AC_SUBST(SOLINKSUFFIX, "")
900 AC_SUBST(WLSONAME, "")
901 AC_SUBST(LIBEXT, "lib")
902 AC_SUBST(LIBPREFIX, "${ac_gecode_userprefix}Gecode")
903 AC_SUBST(LINKPREFIX, "${ac_gecode_userprefix}Gecode")
904 AC_SUBST(LINKSUFFIX, ".lib")
905 AC_SUBST(MINUSLDIR, "")
906 AC_SUBST(LINKLIBDIR, "${libdir}/")
907
908 cygpathprefix=$prefix
909 test "x$cygpathprefix" = xNONE && cygpathprefix=$ac_default_prefix
910 cygpathprefix=`cygpath -m ${cygpathprefix}`
911
912 AC_SUBST(cygpathprefix, "${cygpathprefix}")
913 AC_GECODE_BUILDFLAGS
914
915 dnl compiler options
916 AC_SUBST(COMPILEOBJ, "-c -Fo")
917 AC_SUBST(COMPILESBJ, "-c -Fa")
918 AC_SUBST(CXXIN, "-Tp")
919 AC_SUBST(CCIN, "-Tc")
920
921 dnl Install stub .lib files (required for msvc)
922 AC_SUBST(INSTALLLIBS, "yes")
923
924 dnl how to tell the compiler to output an object file
925 AC_SUBST(LINKOUTPUT, "-Fe")
926 dnl how to tell the compiler to output an executable
927 AC_SUBST(EXEOUTPUT, "-Fe")
928
929 dnl the names of the generated dlls
930 AC_SUBST(SUPPORT, "Support")
931 AC_SUBST(KERNEL, "Kernel")
932 AC_SUBST(SEARCH, "Search")
933 AC_SUBST(INT, "Int")
934 AC_SUBST(FLOAT, "Float")
935 AC_SUBST(SET, "Set")
936 AC_SUBST(MM, "Minimodel")
937 AC_SUBST(GIST, "Gist")
938 AC_SUBST(FLATZINC, "FlatZinc")
939 AC_SUBST(DRIVER, "Driver")])
940
941dnl Macro:
942dnl AC_GECODE_DOC_SWITCHES
943dnl
944dnl Description:
945dnl Produces the configure switches --enable-doc-search,
946dnl --enable-doc-chm, and --enable-doc-tagfile.
947dnl
948dnl Authors:
949dnl Guido Tack <tack@gecode.org>
950AC_DEFUN([AC_GECODE_DOC_SWITCHES],
951 [dnl check if we can use dot for generating graphs in the documentation
952 AC_ARG_ENABLE([doc-dot],
953 AC_HELP_STRING([--enable-doc-dot],
954 [enable graphs in documentation @<:@default=yes@:>@]))
955 AC_CHECK_PROG(DOT, dot, dot)
956 AC_MSG_CHECKING(whether to enable graphs in the documentation)
957 if test "${enable_doc_dot:-yes}" = "yes"; then
958 if test x$DOT = x; then
959 if test x"${enable_doc_dot}" = x; then
960 AC_MSG_RESULT(no)
961 AC_SUBST(GECODE_DOXYGEN_DOT, NO)
962 else
963 AC_MSG_ERROR(you need the dot tool from graphviz to generate graphs in the documentation)
964 fi
965 else
966 AC_MSG_RESULT(yes)
967 AC_SUBST(GECODE_DOXYGEN_DOT, YES)
968 fi
969 else
970 AC_MSG_RESULT(no)
971 AC_SUBST(GECODE_DOXYGEN_DOT, NO)
972 fi
973
974 AC_ARG_ENABLE([doc-search],
975 AC_HELP_STRING([--enable-doc-search],
976 [enable documentation search engine @<:@default=no@:>@]))
977 AC_MSG_CHECKING(whether to enable the documentation search engine)
978 if test "${enable_doc_search:-no}" = "yes"; then
979 AC_MSG_RESULT(yes)
980 AC_SUBST(ENABLEDOCSEARCH, "yes")
981 else
982 AC_MSG_RESULT(no)
983 AC_SUBST(ENABLEDOCSEARCH, "no")
984 fi
985 AC_ARG_ENABLE([doc-tagfile],
986 AC_HELP_STRING([--enable-doc-tagfile],
987 [generate doxygen tagfile @<:@default=yes@:>@]))
988 AC_MSG_CHECKING(whether to generate a doxygen tagfile)
989 if test "${enable_doc_tagfile:-yes}" = "yes"; then
990 AC_MSG_RESULT(yes)
991 AC_SUBST(GECODE_DOXYGEN_TAGFILE, "doc/gecode-doc.tag")
992 else
993 AC_MSG_RESULT(no)
994 AC_SUBST(GECODE_DOXYGEN_TAGFILE, [])
995 fi
996 AC_ARG_ENABLE([doc-chm],
997 AC_HELP_STRING([--enable-doc-chm],
998 [build compressed html documentation @<:@default=yes on Windows@:>@]))
999 AC_MSG_CHECKING(whether to build compressed html documentation)
1000 case $host_os in
1001 windows*)
1002 if test "${enable_doc_chm:-yes}" = "yes"; then
1003 AC_MSG_RESULT(yes)
1004 AC_SUBST(ENABLEDOCCHM, "yes")
1005 AC_SUBST(ENABLEDOCSEARCH, "no")
1006 else
1007 AC_MSG_RESULT(no)
1008 AC_SUBST(ENABLEDOCCHM, "no")
1009 fi
1010 ;;
1011 *)
1012 if test "${enable_doc_chm:-no}" = "yes"; then
1013 AC_MSG_ERROR([building chms is only supported on Windows.])
1014 else
1015 AC_MSG_RESULT(no)
1016 AC_SUBST(ENABLEDOCCHM, "no")
1017 fi
1018 ;;
1019 esac
1020 AC_ARG_ENABLE([doc-docset],
1021 AC_HELP_STRING([--enable-doc-docset],
1022 [build docset documentation for XCode @<:@default=no@:>@]))
1023 AC_MSG_CHECKING(whether to build docset documentation for XCode)
1024 case $host_os in
1025 darwin*)
1026 if test "${enable_doc_docset:-no}" = "yes"; then
1027 AC_MSG_RESULT(yes)
1028 AC_SUBST(ENABLEDOCDOCSET, "yes")
1029 AC_SUBST(ENABLEDOCSEARCH, "no")
1030 else
1031 AC_MSG_RESULT(no)
1032 AC_SUBST(ENABLEDOCDOCSET, "no")
1033 fi
1034 ;;
1035 *)
1036 if test "${enable_doc_docset:-no}" = "yes"; then
1037 AC_MSG_ERROR([building docsets is only supported on Mac OS X.])
1038 else
1039 AC_MSG_RESULT(no)
1040 AC_SUBST(ENABLEDOCDOCSET, "no")
1041 fi
1042 ;;
1043 esac
1044 ])
1045
1046dnl Macro:
1047dnl AC_GECODE_UNIVERSAL
1048dnl
1049dnl Description:
1050dnl Produces the configure switches --enable-universal and --with-sdk
1051dnl for compiling universal binaries on Mac OS X.
1052dnl
1053dnl Authors:
1054dnl Guido Tack <tack@gecode.org>
1055AC_DEFUN([AC_GECODE_UNIVERSAL],
1056 [dnl build universal binaries on Mac OS X
1057 AC_ARG_WITH([sdk],
1058 AC_HELP_STRING([--with-sdk],
1059 [SDK to use on Mac OS X]))
1060 if test "${host_os}" = "darwin"; then
1061 if test "${with_sdk:-no}" != "no"; then
1062 AC_GECODE_CHECK_COMPILERFLAG([-isysroot ${with_sdk}])
1063 AC_GECODE_ADD_TO_DLLFLAGS([-Wl,-syslibroot,${with_sdk}])
1064 fi
1065 fi
1066 AC_ARG_WITH([macosx-version-min],
1067 AC_HELP_STRING([--with-macosx-version-min],
1068 [minimum version of Mac OS X to support]))
1069 if test "${host_os}" = "darwin"; then
1070 if test "${with_macosx_version_min:-no}" != "no"; then
1071 AC_GECODE_CHECK_COMPILERFLAG(
1072 [-mmacosx-version-min=${with_macosx_version_min}])
1073 AC_GECODE_ADD_TO_DLLFLAGS(
1074 [-mmacosx-version-min=${with_macosx_version_min}])
1075 fi
1076 fi
1077 AC_ARG_WITH([architectures],
1078 AC_HELP_STRING([--with-architectures],
1079 [architectures to compile for on Mac OS X]))
1080 AC_MSG_CHECKING(Whether to build for different architectures)
1081 if test "${host_os}" = "darwin"; then
1082 if test "${with_architectures:-no}" != "no"; then
1083 archflags="";
1084 for a in `echo ${with_architectures} | sed -e "s/,/ /g"`; do
1085 archflags="${archflags} -arch $a";
1086 done
1087 AC_GECODE_CHECK_COMPILERFLAG([${archflags}])
1088 AC_GECODE_ADD_TO_DLLFLAGS([${archflags}])
1089 AC_MSG_RESULT(yes)
1090 else
1091 AC_MSG_RESULT(no)
1092 fi
1093 else
1094 AC_MSG_RESULT(no)
1095 fi
1096])
1097
1098dnl Macro:
1099dnl AC_GECODE_FRAMEWORK
1100dnl
1101dnl Description:
1102dnl Produces the configure switch --enable-framework
1103dnl for creating a Mac OS X framework instead of individual libraries.
1104dnl
1105dnl Authors:
1106dnl Guido Tack <tack@gecode.org>
1107AC_DEFUN([AC_GECODE_FRAMEWORK],
1108 [dnl build framework bundle on Mac OS X
1109 AC_ARG_ENABLE([framework],
1110 AC_HELP_STRING([--enable-framework],
1111 [build framework bundle on Mac OS X @<:@default=no@:>@]))
1112 if test "${host_os}" = "darwin"; then
1113 AC_MSG_CHECKING(whether to build framework bundle on Mac OS X)
1114 if test "${enable_framework:-no}" = "yes"; then
1115 AC_MSG_RESULT(yes)
1116 AC_SUBST(BUILD_MACOS_FRAMEWORK, "yes")
1117 enable_static="yes";
1118 enable_shared="no";
1119 else
1120 AC_MSG_RESULT(no)
1121 AC_SUBST(BUILD_MACOS_FRAMEWORK, "no")
1122 fi
1123 fi
1124])
1125
1126dnl Macro:
1127dnl AC_GECODE_MPFR_INCLUDE
1128dnl
1129dnl Description:
1130dnl Produces the configure switch --with-mpfr-include
1131dnl for supplying the path to the mpfr header.
1132dnl
1133AC_DEFUN([AC_GECODE_MPFR_INCLUDE],
1134 [dnl build with support for the mpfr header
1135 AC_ARG_WITH([mpfr-include],
1136 AC_HELP_STRING([--with-mpfr-include],
1137 [path to the mpfr header file]))
1138 if test "${with_mpfr_include:-no}" != "no"; then
1139 AC_SUBST(MPFR_CPPFLAGS,[-I${with_mpfr_include}])
1140 fi
1141])
1142
1143dnl Macro:
1144dnl AC_GECODE_MPFR_LIB
1145dnl
1146dnl Description:
1147dnl Produces the configure switch --with-mpfr-lib
1148dnl for supplying the path to the mpfr library.
1149dnl
1150AC_DEFUN([AC_GECODE_MPFR_LIB],
1151 [dnl build with support for the mpfr library
1152 AC_ARG_WITH([mpfr-lib],
1153 AC_HELP_STRING([--with-mpfr-lib],
1154 [path to the mpfr library]))
1155 if test "${with_mpfr_lib:-no}" != "no"; then
1156 case $ac_gecode_compiler_vendor in
1157 gnu)
1158 AC_SUBST(MPFR_LIB_PATH,["-L${with_mpfr_lib}"])
1159 ;;
1160 microsoft)
1161 AC_SUBST(MPFR_LIB_PATH,["/LIBPATH:${with_mpfr_lib}"])
1162 ;;
1163 esac
1164 else
1165 AC_SUBST(MPFR_LIB_PATH,[""])
1166 fi
1167 case $ac_gecode_compiler_vendor in
1168 gnu)
1169 AC_SUBST(MPFR_LINK,["-lmpfr"])
1170 ;;
1171 microsoft)
1172 AC_SUBST(MPFR_LINK,["mpfr.lib"])
1173 ;;
1174 esac
1175])
1176
1177dnl Macro:
1178dnl AC_GECODE_GMP_INCLUDE
1179dnl
1180dnl Description:
1181dnl Produces the configure switch --with-gmp-include
1182dnl for supplying the path to the gmp or mpir headers.
1183dnl
1184AC_DEFUN([AC_GECODE_GMP_INCLUDE],
1185 [dnl build with support for the gmp headers
1186 AC_ARG_WITH([gmp-include],
1187 AC_HELP_STRING([--with-gmp-include],
1188 [path to the gmp or mpir header files]))
1189 if test "${with_gmp_include:-no}" != "no"; then
1190 AC_SUBST(GMP_CPPFLAGS,[-I${with_gmp_include}])
1191 fi
1192])
1193
1194dnl Macro:
1195dnl AC_GECODE_GMP_LIB
1196dnl
1197dnl Description:
1198dnl Produces the configure switch --with-gmp-lib
1199dnl for supplying the path to the GMP library.
1200dnl
1201AC_DEFUN([AC_GECODE_GMP_LIB],
1202 [dnl build with support for the GMP library
1203 AC_ARG_WITH([gmp-lib],
1204 AC_HELP_STRING([--with-gmp-lib],
1205 [path to the gmp or mpir library]))
1206
1207 ac_gecode_tmp_gmp_lib=""
1208 if test "${with_gmp_lib:-no}" != "no"; then
1209 case $ac_gecode_compiler_vendor in
1210 gnu)
1211 AC_SUBST(GMP_LIB_PATH,["-L${with_gmp_lib}"])
1212 ;;
1213 microsoft)
1214 AC_SUBST(GMP_LIB_PATH,["/LIBPATH:${with_gmp_lib}"])
1215 ;;
1216 esac
1217 else
1218 AC_SUBST(GMP_LIB_PATH,[""])
1219 fi
1220
1221 ac_gecode_save_CPPFLAGS="${CPPFLAGS}"
1222 ac_gecode_save_LIBS="${LIBS}"
1223 case $ac_gecode_compiler_vendor in
1224 gnu)
1225 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ } ${GMP_CPPFLAGS}"
1226 LIBS="${LIBS}${LIBS:+ } ${GMP_LIB_PATH}"
1227 AC_CHECK_LIB(gmp, __gmpz_init,[
1228 AC_SUBST(GMP_LINK,"${ac_gecode_tmp_gmp_lib} -lgmp")
1229 ],[
1230 AC_CHECK_LIB(mpir, __gmpz_init,[
1231 AC_SUBST(GMP_LINK,"${ac_gecode_tmp_gmp_lib} -lmpir")
1232 ],[
1233 enable_mpfr=no;
1234 ])
1235 ])
1236 ;;
1237 microsoft)
1238 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ } ${GMP_CPPFLAGS}"
1239 LIBS="${LIBS}${LIBS:+ } /link ${GMP_LIB_PATH} gmp.lib"
1240 AC_CHECK_LIB(gmp, __gmpz_init,[
1241 AC_SUBST(GMP_LINK,"${ac_gecode_tmp_gmp_lib} gmp.lib")
1242 ],[
1243 LIBS="${ac_gecode_save_LIBS}"
1244 LIBS="${LIBS}${LIBS:+ } /link ${GMP_LIB_PATH} mpir.lib"
1245 AC_CHECK_LIB(mpir, __gmpz_init,[
1246 AC_SUBST(GMP_LINK,"${ac_gecode_tmp_gmp_lib} mpir.lib")
1247 ],[
1248 enable_mpfr=no;
1249 ])
1250 ])
1251 ;;
1252 esac
1253 CPPFLAGS="${ac_gecode_save_CPPFLAGS}"
1254 LIBS="${ac_gecode_save_LIBS}"
1255 ])
1256
1257
1258dnl Macro:
1259dnl AC_GECODE_MPFR
1260dnl
1261dnl Description:
1262dnl Produces the configure switch --enable-mpfr
1263dnl for compiling parts of Gecode that need the MPFR library.
1264dnl
1265dnl Authors:
1266AC_DEFUN([AC_GECODE_MPFR],
1267 [
1268 AC_ARG_ENABLE([mpfr],
1269 AC_HELP_STRING([--enable-mpfr],
1270 [build with MPFR support @<:@default=yes@:>@]))
1271 if test "${enable_float_vars:-yes}" = "yes"; then
1272 AC_MSG_CHECKING(whether to build with MPFR support)
1273 if test "${enable_mpfr:-yes}" = "yes"; then
1274 AC_MSG_RESULT(yes)
1275 AC_GECODE_GMP_INCLUDE
1276 AC_GECODE_GMP_LIB
1277 AC_GECODE_MPFR_INCLUDE
1278 AC_GECODE_MPFR_LIB
1279 ac_gecode_save_CPPFLAGS="${CPPFLAGS}"
1280 ac_gecode_save_LIBS="${LIBS}"
1281 case $ac_gecode_compiler_vendor in
1282 gnu)
1283 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ } ${MPFR_CPPFLAGS} ${GMP_CPPFLAGS}"
1284 LIBS="${LIBS}${LIBS:+ } ${MPFR_LIB_PATH} ${GMP_LIB_PATH} ${MPFR_LINK} ${GMP_LINK}"
1285 AC_CHECK_HEADERS([gmp.h],
1286 AC_CHECK_HEADERS([mpfr.h],
1287 AC_CHECK_LIB(mpfr, mpfr_add,
1288 AC_DEFINE([GECODE_HAS_MPFR],[],[Whether MPFR is available])
1289 enable_mpfr=yes;,
1290 enable_mpfr=no;),
1291 enable_mpfr=no; ),
1292 enable_mpfr=no; )
1293 ;;
1294 microsoft)
1295 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ } ${MPFR_CPPFLAGS} ${GMP_CPPFLAGS}"
1296 LIBS="${LIBS}${LIBS:+ } /link ${MPFR_LIB_PATH} ${GMP_LIB_PATH} ${MPFR_LINK} ${GMP_LINK}"
1297 AC_CHECK_HEADERS([gmp.h],
1298 AC_CHECK_HEADERS([mpfr.h],
1299 AC_CHECK_FUNC(mpfr_add,
1300 AC_DEFINE([GECODE_HAS_MPFR],[],[Whether MPFR is available])
1301 enable_mpfr=yes;,
1302 enable_mpfr=no;),
1303 enable_mpfr=no; ),
1304 enable_mpfr=no; )
1305 ;;
1306 esac
1307 CPPFLAGS="${ac_gecode_save_CPPFLAGS}"
1308 LIBS="${ac_gecode_save_LIBS}"
1309 else
1310 AC_MSG_RESULT(no)
1311 enable_mpfr=no;
1312 fi
1313 else
1314 enable_mpfr=no;
1315 fi
1316 AC_SUBST(enable_mpfr, ${enable_mpfr})
1317])
1318
1319
1320dnl Macro:
1321dnl AC_GECODE_QT
1322dnl
1323dnl Description:
1324dnl Produces the configure switch --enable-qt
1325dnl for compiling parts of Gecode that need the Qt library.
1326dnl
1327dnl Authors:
1328dnl Guido Tack <tack@gecode.org>
1329AC_DEFUN([AC_GECODE_QT],
1330 [
1331 AC_ARG_ENABLE([qt],
1332 AC_HELP_STRING([--enable-qt],
1333 [build with Qt support, requires at least Qt 4.3 @<:@default=yes@:>@]))
1334 AC_CHECK_PROGS(QMAKE, [qmake-qt4 qmake])
1335 AC_CHECK_PROGS(MOC, [moc-qt4 moc])
1336 AC_MSG_CHECKING(whether to build with Qt support)
1337 if test "${enable_qt:-yes}" = "yes"; then
1338 if test "${QMAKE}x" = "x" -o "${MOC}x" = "x"; then
1339 AC_MSG_RESULT(no)
1340 else
1341 ac_gecode_qt_version=`${QMAKE} -query QT_VERSION`
1342 ac_gecode_qt_major=`echo ${ac_gecode_qt_version} | grep -o '^[[0-9]]*'`
1343 ac_gecode_qt_minor=`echo ${ac_gecode_qt_version} | sed -e 's/^[[0-9]]*\\.//g' -e 's/\\.[[0-9]]*$//g'`
1344 ac_gecode_qt_ok="yes"
1345 if test ${ac_gecode_qt_major} -lt 4; then ac_gecode_qt_ok="no";
1346 else if test ${ac_gecode_qt_major} -eq 4 \
1347 -a ${ac_gecode_qt_minor} -lt 3; then ac_gecode_qt_ok="no";
1348 fi
1349 fi
1350 if test "${ac_gecode_qt_ok}" != "yes"; then
1351 AC_MSG_RESULT(no)
1352 else
1353 AC_MSG_RESULT(yes)
1354 AC_DEFINE([GECODE_HAS_QT],[],[Whether Qt is available])
1355 dnl use qmake to find the Qt installation
1356 ac_gecode_qt_tmpdir=`mktemp -d gistqt.XXXXXX` || exit 1
1357 cd ${ac_gecode_qt_tmpdir}
1358 echo "CONFIG += release" > a.pro
1359 if test ${ac_gecode_qt_major} -eq 5; then
1360 echo "QT += widgets printsupport" >> a.pro
1361 fi
1362 ${QMAKE}
1363 if test -d a.xcodeproj; then
1364 ac_gecode_qt_makefile=a.xcodeproj/qt_preprocess.mak
1365 elif test -d a.pbproj; then
1366 ac_gecode_qt_makefile=a.pbproj/qt_preprocess.mak
1367 elif test -f Makefile.Debug; then
1368 if test "${enable_debug:-no}" = "no"; then
1369 ac_gecode_qt_makefile=Makefile.Release
1370 else
1371 ac_gecode_qt_makefile=Makefile.Debug
1372 fi
1373 else
1374 ac_gecode_qt_makefile=Makefile
1375 fi
1376 ac_gecode_qt_defines=`grep ${ac_gecode_qt_makefile} -e 'DEFINES.*=' | sed -e 's/.*=//' -e 's|\\\\|/|g' -e 's|-I\\("*\\)\\.\\./\\.\\.|-I\\1..|g'`
1377 ac_gecode_qt_inc=`grep ${ac_gecode_qt_makefile} -e 'INCPATH.*=' | sed -e 's/.*=//' -e 's|\\\\|/|g' -e 's|-I\\("*\\)\\.\\./\\.\\.|-I\\1..|g'`
1378 ac_gecode_qt_libs=`grep ${ac_gecode_qt_makefile} -e 'LIBS.*=' | sed -e 's/.*=//' -e 's|\\\\|/|g' -e 's|-I\\("*\\)\\.\\./\\.\\.|-I\\1..|g'`
1379 if test -d a.xcodeproj -o -d a.pbproj; then
1380 ac_gecode_qt_libs="-framework QtGui -framework QtCore"
1381 fi
1382 cd ..
1383 rm -r ${ac_gecode_qt_tmpdir}
1384 AC_SUBST(QTINCLUDES, ${ac_gecode_qt_inc})
1385 AC_SUBST(QTDEFINES, ${ac_gecode_qt_defines})
1386 AC_SUBST(QTLIBS, ${ac_gecode_qt_libs})
1387 AC_SUBST(enable_qt,yes)
1388 enable_qt=yes;
1389 fi
1390 fi
1391 else
1392 AC_MSG_RESULT(no)
1393 enable_qt=no;
1394 fi
1395 AC_SUBST(enable_qt, ${enable_qt})
1396])
1397
1398dnl Macro:
1399dnl AC_GECODE_GIST
1400dnl
1401dnl Description:
1402dnl Produces the configure switch --enable-gist
1403dnl for compiling the Gecode Interactive Search Tool.
1404dnl
1405dnl Authors:
1406dnl Guido Tack <tack@gecode.org>
1407AC_DEFUN([AC_GECODE_GIST],
1408 [
1409 AC_ARG_ENABLE([gist],
1410 AC_HELP_STRING([--enable-gist],
1411 [build Gecode Interactive Search Tool @<:@default=yes@:>@]))
1412 AC_MSG_CHECKING(whether to build Gist)
1413 if test "${enable_gist:-yes}" = "yes" -a "${enable_qt}" = "yes"; then
1414 AC_MSG_RESULT(yes)
1415 AC_SUBST(enable_gist, yes)
1416 AC_DEFINE([GECODE_HAS_GIST],[],[Whether Gist is available])
1417 else
1418 AC_MSG_RESULT(no)
1419 fi
1420])
1421
1422dnl
1423dnl Macro:
1424dnl AC_GECODE_CBS
1425dnl
1426dnl Description:
1427dnl Produces the configure switch --enable-cbs
1428dnl for compiling with support for counting-based search.
1429dnl
1430dnl Authors:
1431dnl Samuel Gagnon <samuel.gagnon92@gmail.com>
1432AC_DEFUN([AC_GECODE_CBS],
1433 [
1434 AC_ARG_ENABLE([cbs],
1435 AC_HELP_STRING([--enable-cbs],
1436 [build with support for counting-based search @<:@default=no@:>@]))
1437 AC_MSG_CHECKING(whether to build with support for cbs)
1438 if test "${enable_cbs:-no}" = "yes"; then
1439 AC_MSG_RESULT(yes)
1440 AC_SUBST(enable_cbs, yes)
1441 AC_DEFINE([GECODE_HAS_CBS],[],[Whether counting-based search support available])
1442 else
1443 AC_MSG_RESULT(no)
1444 fi
1445])
1446
1447dnl Macro:
1448dnl AC_GECODE_CPPROFILER
1449dnl
1450dnl Description:
1451dnl Produces the configure switch --enable-cpprofiler
1452dnl for compiling with support for the CPProfiler.
1453dnl
1454dnl Authors:
1455dnl Guido Tack <tack@gecode.org>
1456dnl Christian Schulte <schulte@gecode.org>
1457AC_DEFUN([AC_GECODE_CPPROFILER],
1458 [
1459 AC_ARG_ENABLE([cpprofiler],
1460 AC_HELP_STRING([--enable-cpprofiler],
1461 [build with support for CPProfiler @<:@default=yes@:>@]))
1462 AC_MSG_CHECKING(whether to build with support for CPProfiler)
1463 if test "${enable_cpprofiler:-no}" = "yes"; then
1464 AC_MSG_RESULT(yes)
1465 AC_SUBST(enable_cpprofiler, yes)
1466 AC_DEFINE([GECODE_HAS_CPPROFILER],[],[Whether CPProfiler support available])
1467 else
1468 AC_MSG_RESULT(no)
1469 fi
1470])
1471
1472AC_DEFUN([AC_GECODE_USER_SUFFIX],
1473 [
1474 AC_ARG_WITH([lib-prefix],
1475 AC_HELP_STRING([--with-lib-prefix],
1476 [add user-defined prefix to library names]))
1477 AC_MSG_CHECKING(for user-defined library name prefix)
1478 if test "x${with_lib_prefix}" != "x"; then
1479 ac_gecode_userprefix=${with_lib_prefix}
1480 AC_MSG_RESULT(${with_lib_prefix})
1481 else
1482 ac_gecode_userprefix=
1483 AC_MSG_RESULT(no)
1484 fi
1485 AC_DEFINE_UNQUOTED(GECODE_DLL_USERPREFIX,"${ac_gecode_userprefix}",
1486 [User-defined prefix of dll names])
1487 AC_ARG_WITH([lib-suffix],
1488 AC_HELP_STRING([--with-lib-suffix],
1489 [add user-defined suffix to library names]))
1490 AC_MSG_CHECKING(for user-defined library name suffix)
1491 if test "x${with_lib_suffix}" != "x"; then
1492 ac_gecode_usersuffix=${with_lib_suffix}
1493 AC_SUBST(USERSUFFIX,${with_lib_suffix})
1494 AC_MSG_RESULT(${with_lib_suffix})
1495 else
1496 ac_gecode_usersuffix=
1497 AC_SUBST(USERSUFFIX,[""])
1498 AC_MSG_RESULT(no)
1499 fi
1500 AC_DEFINE_UNQUOTED(GECODE_DLL_USERSUFFIX,"${ac_gecode_usersuffix}",
1501 [User-defined suffix of dll names])
1502])
1503
1504AC_DEFUN([AC_GECODE_THREADS],[
1505 AC_ARG_ENABLE([thread],
1506 AC_HELP_STRING([--enable-thread],
1507 [build with multi-threading support @<:@default=yes@:>@]))
1508 AC_MSG_CHECKING(whether to build with multi-threading support)
1509 if test "${enable_thread:-yes}" = "yes"; then
1510 AC_MSG_RESULT(yes)
1511 AC_CHECK_HEADER(unistd.h,
1512 [AC_DEFINE(GECODE_HAS_UNISTD_H,1,[Whether unistd.h is available])]
1513 )
1514 AC_CHECK_HEADER(pthread.h,
1515 [AC_DEFINE(GECODE_THREADS_PTHREADS,1,[Whether we have posix threads])
1516 AC_GECODE_ADD_TO_COMPILERFLAGS([-pthread])
1517 AC_GECODE_ADD_TO_DLLFLAGS([-pthread])
1518 AC_CHECK_HEADER([os/lock.h],
1519 [AC_DEFINE(GECODE_THREADS_OSX_UNFAIR,1,[Whether we have Mac OS threads (new version)])],
1520 AC_CHECK_HEADER([libkern/OSAtomic.h],
1521 [AC_DEFINE(GECODE_THREADS_OSX,1,[Whether we have Mac OS threads])],
1522 AC_MSG_CHECKING([for spin locks])
1523 AC_TRY_COMPILE([#include <pthread.h>],
1524 [pthread_spinlock_t t;],
1525 [AC_MSG_RESULT(yes)
1526 AC_DEFINE(GECODE_THREADS_PTHREADS_SPINLOCK,1,Whether we have posix spinlocks)],
1527 [AC_MSG_RESULT(no)]
1528 )
1529 )
1530 )],
1531 [AC_CHECK_HEADER(windows.h,
1532 [AC_DEFINE(GECODE_THREADS_WINDOWS,1,[Whether we have windows threads])])]
1533 )
1534 else
1535 AC_MSG_RESULT(no)
1536 fi
1537])
1538
1539AC_DEFUN([AC_GECODE_TIMER],[
1540 AC_CHECK_HEADER(sys/time.h,
1541 [AC_DEFINE(GECODE_USE_GETTIMEOFDAY,1,[Use gettimeofday for time-measurement])],
1542 [AC_DEFINE(GECODE_USE_CLOCK,1,[Use clock() for time-measurement])])
1543])
1544
1545dnl check whether we have suifficiently recent versions of flex/bison
1546AC_DEFUN([AC_GECODE_FLEXBISON],
1547 [AC_CHECK_TOOL(HAVEFLEX, flex)
1548 AC_MSG_CHECKING(whether we have at least flex 2.5.33)
1549 if test "${HAVEFLEX}x" = "x"; then
1550 AC_MSG_RESULT(no)
1551 AC_SUBST(HAVE_FLEXBISON, "no")
1552 else
1553 if flex --version | grep ' 2\.5\.3[[3-9]].*$' >/dev/null 2>&1 ||
1554 flex --version | grep ' 2\.5\.4[[0-9]].*$' >/dev/null 2>&1 ||
1555 flex --version | grep ' 2\.[[6-9]]\.[[0-9]]*$' >/dev/null 2>&1
1556 then
1557 AC_MSG_RESULT(yes)
1558 AC_CHECK_TOOL(HAVEBISON, bison)
1559 AC_MSG_CHECKING(whether we have at least bison 2.3)
1560 if test "${HAVEBISON}x" = "x"; then
1561 AC_MSG_RESULT(no)
1562 AC_SUBST(HAVE_FLEXBISON, "no")
1563 else
1564 if bison --version | grep -e ' 2\.[[3-9]][[0-9]]*' >/dev/null 2>&1 ||
1565 bison --version | grep -e ' 3\.*' >/dev/null 2>&1
1566 then
1567 AC_MSG_RESULT(yes)
1568 AC_SUBST(HAVE_FLEXBISON, "yes")
1569 else
1570 AC_MSG_RESULT(no)
1571 AC_SUBST(HAVE_FLEXBISON, "no")
1572 fi
1573 fi
1574 else
1575 AC_MSG_RESULT(no)
1576 AC_SUBST(HAVE_FLEXBISON, "no")
1577 fi
1578 fi])
1579
1580AC_DEFUN([AC_GECODE_RESOURCE],[
1581 AC_ARG_ENABLE([resource],
1582 AC_HELP_STRING([--enable-resource],
1583 [build Gecode with resource files for Microsoft Visual Studio @<:@default=no@:>@]))
1584 AC_CHECK_PROG(HAVE_RC, rc.exe, [found])
1585 AC_MSG_CHECKING(whether to build with Visual Studio resource files)
1586 if test "${enable_resource:-no}" = "yes" -a \
1587 "${ac_gecode_compiler_vendor}" = "microsoft"; then
1588 if test "${HAVE_RC}x" = "x"; then
1589 AC_MSG_RESULT(no)
1590 AC_SUBST(RESCOMP, [@true])
1591 AC_SUBST(enable_resource, no)
1592 else
1593 AC_MSG_RESULT(yes)
1594 AC_SUBST(RESCOMP, ["rc.exe"])
1595 AC_SUBST(enable_resource, yes)
1596 fi
1597 else
1598 AC_MSG_RESULT(no)
1599 AC_SUBST(enable_resource, no)
1600 AC_SUBST(RESCOMP, [@true])
1601 fi
1602])
1603
1604dnl Macro:
1605dnl AC_GECODE_RUNENVIRONMENT
1606dnl
1607dnl Description:
1608dnl Configure appropriate run environment flags for different platforms for running
1609dnl executables from the makefile with compiled but not installed shared libraries
1610dnl
1611dnl Authors:
1612dnl Mikael Lagerkvist <lagerkvist@gecode.org>
1613dnl
1614AC_DEFUN([AC_GECODE_RUNENVIRONMENT],
1615 [case $host_os in
1616 darwin*)
1617 AC_SUBST(RUNENVIRONMENT, [DYLD_LIBRARY_PATH=.])
1618 ;;
1619 windows*)
1620 AC_SUBST(RUNENVIRONMENT, [''])
1621 ;;
1622 *)
1623 AC_SUBST(RUNENVIRONMENT, [LD_LIBRARY_PATH=.])
1624 ;;
1625 esac])