1AC_INIT([isl], [0.22.1], [isl-development@googlegroups.com])
2AC_CONFIG_AUX_DIR([.])
3AC_CONFIG_MACRO_DIR([m4])
4AM_INIT_AUTOMAKE([foreign])
5m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
6AC_SUBST(versioninfo)
7versioninfo=22:1:0
8
9if test "x$prefix" != "xNONE"; then
10	prefix_wd=`cd $prefix && pwd`
11	srcdir_wd=`cd $srcdir && pwd`
12	wd=`pwd`
13	if test "x$prefix_wd" = "x$srcdir_wd"; then
14		AC_MSG_ERROR(Installation in source directory not supported)
15	fi
16	if test "x$prefix_wd" = "x$wd"; then
17		AC_MSG_ERROR(Installation in build directory not supported)
18	fi
19fi
20
21AC_PROG_CC
22AC_PROG_CXX
23AX_PROG_CC_FOR_BUILD
24
25AX_CC_MAXOPT
26AX_GCC_WARN_UNUSED_RESULT
27AX_C___ATTRIBUTE__
28
29AX_CXX_COMPILE_STDCXX_11_NO_OVERRIDE
30
31AC_PROG_GREP
32AC_PROG_LIBTOOL
33AC_PROG_SED
34AM_PATH_PYTHON([2.5], [], [:])
35AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
36
37AC_CHECK_PROG(CYGPATH, cygpath, cygpath, [])
38AC_CHECK_PROG(PERL, perl, perl, [])
39AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex, [])
40AC_CHECK_PROG(POD2HTML, pod2html, pod2html, [])
41
42AC_SUBST(OS_SRCDIR)
43if test "$host_os" = "mingw32" -a -n "$CYGPATH"; then
44	OS_SRCDIR=`$CYGPATH -m "$srcdir"`
45else
46	OS_SRCDIR="$srcdir"
47fi
48
49AM_CONDITIONAL(GENERATE_DOC, test -n "$PERL" -a -n "$PDFLATEX" -a -n "$POD2HTML")
50
51AX_CREATE_STDINT_H(include/isl/stdint.h)
52
53AC_ARG_WITH([int],
54	    [AS_HELP_STRING([--with-int=gmp|imath|imath-32],
55			    [Which package to use to represent
56				multi-precision integers [default=gmp]])],
57	    [], [with_int=gmp])
58case "$with_int" in
59gmp|imath|imath-32)
60	;;
61*)
62	AC_MSG_ERROR(
63	    [bad value ${withval} for --with-int (use gmp, imath or imath-32)])
64esac
65
66AC_SUBST(MP_CPPFLAGS)
67AC_SUBST(MP_CFLAGS)
68AC_SUBST(MP_LDFLAGS)
69AC_SUBST(MP_LIBS)
70case "$with_int" in
71gmp)
72	AX_DETECT_GMP
73	;;
74imath|imath-32)
75	AX_DETECT_IMATH
76	;;
77esac
78if test "x$with_int" = "ximath-32" -a "x$GCC" = "xyes"; then
79	MP_CFLAGS="-std=gnu99 $MP_CFLAGS"
80fi
81
82AM_CONDITIONAL(IMATH_FOR_MP, test x$with_int = ximath -o x$with_int = ximath-32)
83AM_CONDITIONAL(GMP_FOR_MP, test x$with_int = xgmp)
84
85AM_CONDITIONAL(HAVE_CXX11, test "x$HAVE_CXX11" = "x1")
86AM_CONDITIONAL(SMALL_INT_OPT, test "x$with_int" == "ximath-32")
87AS_IF([test "x$with_int" == "ximath-32"], [
88	AC_DEFINE([USE_SMALL_INT_OPT], [], [Use small integer optimization])
89])
90
91AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
92AC_CHECK_DECLS(__builtin_ffs,[],[],[])
93AC_CHECK_DECLS([_BitScanForward],[],[],[#include <intrin.h>])
94if test "x$ac_cv_have_decl_ffs" = xno -a \
95		"x$ac_cv_have_decl___builtin_ffs" = xno -a \
96		"x$ac_cv_have_decl__BitScanForward" = xno; then
97	AC_MSG_ERROR([No ffs implementation found])
98fi
99AC_CHECK_DECLS([strcasecmp,strncasecmp],[],[],[#include <strings.h>])
100AC_CHECK_DECLS([_stricmp,_strnicmp],[],[],[#include <string.h>])
101if test "x$ac_cv_have_decl_strcasecmp" = xno -a \
102		"x$ac_cv_have_decl__stricmp" = xno; then
103	AC_MSG_ERROR([No strcasecmp implementation found])
104fi
105if test "x$ac_cv_have_decl_strncasecmp" = xno -a \
106		"x$ac_cv_have_decl__strnicmp" = xno; then
107	AC_MSG_ERROR([No strncasecmp implementation found])
108fi
109AC_CHECK_DECLS([snprintf,_snprintf],[],[],[#include <stdio.h>])
110if test "x$ac_cv_have_decl_snprintf" = xno -a \
111		"x$ac_cv_have_decl__snprintf" = xno; then
112	AC_MSG_ERROR([No snprintf implementation found])
113fi
114
115AX_SUBMODULE(clang,system|no,no)
116AM_CONDITIONAL(HAVE_CLANG, test $with_clang = system)
117AM_CONDITIONAL(HAVE_CPP_ISL_H,
118    [(test $with_clang = system -a "x$HAVE_CXX11" = "x1") || \
119     test -f $srcdir/include/isl/cpp.h])
120
121AX_SET_WARNING_FLAGS
122
123AC_SUBST(WARNING_FLAGS)
124
125PACKAGE_CFLAGS="$MP_CPPFLAGS"
126PACKAGE_LDFLAGS="$MP_LDFLAGS"
127PACKAGE_LIBS="-lisl $MP_LIBS"
128AX_CREATE_PKGCONFIG_INFO
129
130AX_DETECT_GIT_HEAD
131
132AH_BOTTOM([#include <isl_config_post.h>])
133AC_CONFIG_HEADERS(isl_config.h)
134AC_CONFIG_FILES(isl_srcdir.c)
135AC_CONFIG_FILES(Makefile)
136AC_CONFIG_FILES(doc/Makefile)
137if test $with_clang = system; then
138	AC_CONFIG_SUBDIRS(interface)
139fi
140AC_CONFIG_FILES([bound_test.sh], [chmod +x bound_test.sh])
141AC_CONFIG_FILES([codegen_test.sh], [chmod +x codegen_test.sh])
142AC_CONFIG_FILES([pip_test.sh], [chmod +x pip_test.sh])
143AC_CONFIG_FILES([flow_test.sh], [chmod +x flow_test.sh])
144AC_CONFIG_FILES([schedule_test.sh], [chmod +x schedule_test.sh])
145AC_OUTPUT
146