Merge branch 'maint'
[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|build,system)
27
28 AC_SUBST(GMP_CPPFLAGS)
29 AC_SUBST(GMP_LDFLAGS)
30 AC_SUBST(GMP_LIBS)
31 case "$with_gmp" in
32 system)
33         if test "x$with_gmp_prefix" != "x"; then
34                 isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
35                 GMP_CPPFLAGS="-I$with_gmp_prefix/include"
36                 GMP_LDFLAGS="-L$with_gmp_prefix/lib"
37         fi
38         GMP_LIBS=-lgmp
39         ;;
40 build)
41         GMP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"
42         GMP_LIBS="$with_gmp_builddir/libgmp.la"
43         ;;
44 esac
45 SAVE_CPPFLAGS="$CPPFLAGS"
46 CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
47 need_get_memory_functions=false
48 AC_CHECK_DECLS(mp_get_memory_functions,[],[
49         need_get_memory_functions=true
50 ],[#include <gmp.h>])
51 CPPFLAGS="$SAVE_CPPFLAGS"
52 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
53
54 AX_SUBMODULE(piplib,no|system|build,no)
55
56 have_piplib=false
57 AC_SUBST(PIPLIB_CPPFLAGS)
58 AC_SUBST(PIPLIB_LDFLAGS)
59 AC_SUBST(PIPLIB_LIBS)
60 case "$with_piplib" in
61         build)
62                 PIPLIB_CPPFLAGS="-I$piplib_srcdir/include"
63                 PIPLIB_LIBS="$with_piplib_builddir/libpiplibMP.la"
64         ;;
65         system)
66                 PIPLIB_LIBS="-lpiplibMP"
67                 if test "x$with_piplib_prefix" != "x"; then
68                         PIPLIB_CPPFLAGS="-I$with_piplib_prefix/include"
69                         PIPLIB_LDFLAGS="-L$with_piplib_prefix/lib"
70                 fi
71                 SAVE_CPPFLAGS="$CPPFLAGS"
72                 SAVE_LDFLAGS="$LDFLAGS"
73                 CPPFLAGS="$PIPLIB_CPPFLAGS $CPPFLAGS"
74                 LDFLAGS="$PIPLIB_LDFLAGS $LDFLAGS"
75                 AC_CHECK_LIB(piplibMP, pip_solve,[
76                         AC_CHECK_MEMBER(PipOptions.Urs_parms, [], [
77                                 AC_MSG_ERROR([Piplib too old; please install version 1.3.6 or newer])
78                         ],[#include <piplib/piplibMP.h>])
79                 ],[
80                         AC_MSG_ERROR([Piplib not found])
81                 ])
82                 CPPFLAGS="$SAVE_CPPFLAGS"
83                 LDFLAGS="$SAVE_LDFLAGS"
84         ;;
85         no)
86         ;;
87         *)
88                 AC_MSG_ERROR(unsupported)
89         ;;
90 esac
91 if test "$with_piplib" != "no"; then
92         AC_DEFINE(ISL_PIPLIB,,piplib is available)
93         have_piplib=true
94 fi
95 AM_CONDITIONAL(HAVE_PIPLIB, test x$have_piplib = xtrue)
96
97 AC_SUBST(CLANG_CXXFLAGS)
98 AC_SUBST(CLANG_LDFLAGS)
99 AC_SUBST(CLANG_LIBS)
100 AX_SUBMODULE(clang,system|no,no)
101 case "$with_clang" in
102 system)
103         llvm_config="llvm-config"
104         AC_CHECK_PROG([llvm_config_found], ["$llvm_config"], [yes])
105         if test "x$with_clang_prefix" != "x"; then
106                 llvm_config="$with_clang_prefix/bin/llvm-config"
107                 if test -x "$llvm_config"; then
108                         llvm_config_found=yes
109                 fi
110         fi
111         if test "$llvm_config_found" != yes; then
112                 AC_MSG_ERROR([llvm-config not found])
113         fi
114         CLANG_CXXFLAGS=`$llvm_config --cxxflags`
115         CLANG_LDFLAGS=`$llvm_config --ldflags`
116         CLANG_LIBS=`$llvm_config --libs`
117         CLANG_PREFIX=`$llvm_config --prefix`
118         AC_DEFINE_UNQUOTED(CLANG_PREFIX, ["$CLANG_PREFIX"],
119                                 [Clang installation prefix])
120
121         SAVE_CPPFLAGS="$CPPFLAGS"
122         CPPFLAGS="$CLANG_CXXFLAGS $CPPFLAGS"
123         AC_LANG_PUSH(C++)
124         AC_CHECK_HEADER([clang/Basic/SourceLocation.h], [],
125                 [AC_ERROR([clang header file not found])])
126         AC_EGREP_HEADER([getDefaultTargetTriple], [llvm/Support/Host.h], [],
127                 [AC_DEFINE([getDefaultTargetTriple], [getHostTriple],
128                 [Define to getHostTriple for older versions of clang])])
129         AC_EGREP_HEADER([getExpansionLineNumber],
130                 [clang/Basic/SourceLocation.h], [],
131                 [AC_DEFINE([getExpansionLineNumber],
132                         [getInstantiationLineNumber],
133             [Define to getInstantiationLineNumber for older versions of clang])])
134         AC_EGREP_HEADER([DiagnosticsEngine],
135                 [clang/Basic/Diagnostic.h], [],
136                 [AC_DEFINE([DiagnosticsEngine],
137                         [Diagnostic],
138             [Define to Diagnostic for older versions of clang])])
139         AC_EGREP_HEADER([ArrayRef], [clang/Driver/Driver.h],
140                 [AC_DEFINE([USE_ARRAYREF], [],
141                         [Define if Driver::BuildCompilation takes ArrayRef])])
142         AC_EGREP_HEADER([CXXIsProduction], [clang/Driver/Driver.h],
143                 [AC_DEFINE([HAVE_CXXISPRODUCTION], [],
144                 [Define if Driver constructor takes CXXIsProduction argument])])
145         AC_LANG_POP
146         CPPFLAGS="$SAVE_CPPFLAGS"
147         ;;
148 esac
149 AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
150
151 AX_SET_WARNING_FLAGS
152
153 AC_SUBST(WARNING_FLAGS)
154
155 PACKAGE_CFLAGS="$GMP_CPPFLAGS"
156 PACKAGE_LDFLAGS="$GMP_LDFLAGS"
157 PACKAGE_LIBS="-lisl -lgmp"
158 AX_CREATE_PKGCONFIG_INFO
159
160 AX_DETECT_GIT_HEAD
161 echo '#define GIT_HEAD_ID "'$GIT_HEAD_ID'"' > gitversion.h
162
163 AH_BOTTOM([#include <isl_config_post.h>])
164 AC_CONFIG_HEADERS(isl_config.h)
165 AC_CONFIG_HEADERS(include/isl/config.h)
166 AC_CONFIG_FILES(Makefile)
167 AC_CONFIG_FILES(doc/Makefile)
168 AC_CONFIG_FILES(interface/Makefile)
169 AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
170 AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
171 AC_CONFIG_COMMANDS_POST([
172         dnl pass on arguments to subdir configures, but don't
173         dnl add them to config.status
174         ac_configure_args="$ac_configure_args $isl_configure_args"
175 ])
176 AC_OUTPUT