36be86004cabcace1a152103a7a056a158771c22
[platform/upstream/isl.git] / configure.ac
1 AC_INIT([isl], [0.08], [isl-development@googlegroups.com])
2 AC_CONFIG_AUX_DIR([.])
3 AC_CONFIG_MACRO_DIR([m4])
4 AM_INIT_AUTOMAKE([foreign])
5 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
6 AC_SUBST(versioninfo)
7 versioninfo=8:0:0
8
9 AC_PROG_CC
10 AC_PROG_CXX
11
12 AX_CC_MAXOPT
13 AX_GCC_WARN_UNUSED_RESULT
14 AX_C___ATTRIBUTE__
15
16 AC_PROG_LIBTOOL
17
18 AC_CHECK_PROG(PERL, perl, perl, [])
19 AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex, [])
20 AC_CHECK_PROG(POD2HTML, pod2html, pod2html, [])
21
22 AM_CONDITIONAL(GENERATE_DOC, test -n "$PERL" -a -n "$PDFLATEX" -a -n "$POD2HTML")
23
24 AX_CREATE_STDINT_H(include/isl/stdint.h)
25
26 AX_SUBMODULE(gmp,system,system)
27
28 AC_SUBST(GMP_CPPFLAGS)
29 AC_SUBST(GMP_LDFLAGS)
30 if test "x$with_gmp_prefix" != "x"; then
31         isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
32         GMP_CPPFLAGS="-I$with_gmp_prefix/include"
33         GMP_LDFLAGS="-L$with_gmp_prefix/lib"
34 fi
35 SAVE_CPPFLAGS="$CPPFLAGS"
36 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
37 need_get_memory_functions=false
38 AC_CHECK_DECLS(mp_get_memory_functions,[],[
39         need_get_memory_functions=true
40 ],[#include <gmp.h>])
41 CPPFLAGS="$SAVE_CPPFLAGS"
42 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
43
44 AX_SUBMODULE(piplib,no|system|build,no)
45
46 have_piplib=false
47 AC_SUBST(PIPLIB_CPPFLAGS)
48 AC_SUBST(PIPLIB_LDFLAGS)
49 AC_SUBST(PIPLIB_LIBS)
50 case "$with_piplib" in
51         build)
52                 PIPLIB_CPPFLAGS="-I$piplib_srcdir/include"
53                 PIPLIB_LIBS="$with_piplib_builddir/libpiplibMP.la"
54         ;;
55         system)
56                 PIPLIB_LIBS="-lpiplibMP"
57                 if test "x$with_piplib_prefix" != "x"; then
58                         PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
59                         PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
60                 fi
61                 SAVE_CPPFLAGS="$CPPFLAGS"
62                 SAVE_LDFLAGS="$LDFLAGS"
63                 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
64                 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
65                 AC_CHECK_LIB(piplibMP, pip_solve,[
66                         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
67                                 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
68                         ],[#include <piplib/piplibMP.h>])
69                 ],[
70                         AC_MSG_ERROR([Piplib not found])
71                 ])
72                 CPPFLAGS="$SAVE_CPPFLAGS"
73                 LDFLAGS="$SAVE_LDFLAGS"
74         ;;
75         no)
76         ;;
77         *)
78                 AC_MSG_ERROR(unsupported)
79         ;;
80 esac
81 if test "$with_piplib" != "no"; then
82         AC_DEFINE(ISL_PIPLIB,,piplib is available)
83         have_piplib=true
84 fi
85 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
86
87 AC_SUBST(CLANG_CXXFLAGS)
88 AC_SUBST(CLANG_LDFLAGS)
89 AC_SUBST(CLANG_LIBS)
90 AX_SUBMODULE(clang,system|no,no)
91 case "$with_clang" in
92 system)
93         llvm_config="llvm-config"
94         AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
95         if test "x$with_clang_prefix" != "x"; then
96                 llvm_config="$with_clang_prefix/bin/llvm-config"
97                 if test -x "$llvm_config"; then
98                         llvm_config_found=yes
99                 fi
100         fi
101         if test "$llvm_config_found" != yes; then
102                 AC_MSG_ERROR([llvm-config not found])
103         fi
104         CLANG_CXXFLAGS=`$llvm_config --cxxflags`
105         CLANG_LDFLAGS=`$llvm_config --ldflags`
106         CLANG_LIBS=`$llvm_config --libs`
107         CLANG_PREFIX=`$llvm_config --prefix`
108         AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
109                                 [Clang installation prefix])
110
111         SAVE_CPPFLAGS="$CPPFLAGS"
112         CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
113         AC_LANG_PUSH(C++)
114         AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
115                 [AC_ERROR([clang header file not found])])
116         AC_EGREP_HEADER([getExpansionLineNumber],
117                 [clang/Basic/SourceLocation.h], [],
118                 [AC_DEFINE([getExpansionLineNumber],
119                         [getInstantiationLineNumber],
120             [Define to getInstantiationLineNumber for older versions of clang])])
121         AC_EGREP_HEADER([DiagnosticsEngine],
122                 [clang/Basic/Diagnostic.h], [],
123                 [AC_DEFINE([DiagnosticsEngine],
124                         [Diagnostic],
125             [Define to Diagnostic for older versions of clang])])
126         AC_LANG_POP
127         CPPFLAGS="$SAVE_CPPFLAGS"
128         ;;
129 esac
130 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
131
132 AX_SET_WARNING_FLAGS
133
134 AC_SUBST(WARNING_FLAGS)
135
136 PACKAGE_CFLAGS="$GMP_CPPFLAGS"
137 PACKAGE_LDFLAGS="$GMP_LDFLAGS"
138 PACKAGE_LIBS="-lisl -lgmp"
139 AX_CREATE_PKGCONFIG_INFO
140
141 AX_DETECT_GIT_HEAD
142 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
143
144 AH_BOTTOM([#include <isl_config_post.h>])
145 AC_CONFIG_HEADERS(isl_config.h)
146 AC_CONFIG_HEADERS(include/isl/config.h)
147 AC_CONFIG_FILES(Makefile)
148 AC_CONFIG_FILES(doc/Makefile)
149 AC_CONFIG_FILES(interface/Makefile)
150 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
151 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
152 AC_CONFIG_COMMANDS_POST([
153         dnl pass on arguments to subdir configures, but don't
154         dnl add them to config.status
155         ac_configure_args="$ac_configure_args $isl_configure_args"
156 ])
157 AC_OUTPUT