1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.69])
5AC_INIT([cudd], [3.0.0], [Fabio@Colorado.EDU])
6AC_CONFIG_AUX_DIR([build-aux])
7AC_CONFIG_MACRO_DIR([m4])
8AC_CANONICAL_HOST
9AM_INIT_AUTOMAKE(
10  [1.14 -Wall -Werror foreign subdir-objects color-tests silent-rules]
11)
12AC_REQUIRE_AUX_FILE([tap-driver.sh])
13
14AC_ARG_ENABLE([dddmp],
15  [AS_HELP_STRING([--enable-dddmp],[include libdddmp in libcudd])])
16AM_CONDITIONAL([DDDMP], [test x$enable_dddmp = xyes])
17
18AC_ARG_ENABLE([obj],
19  [AS_HELP_STRING([--enable-obj],[include libobj in libcudd])])
20AM_CONDITIONAL([OBJ], [test x$enable_obj = xyes])
21
22AC_ARG_WITH([system-qsort],
23  [AS_HELP_STRING([--with-system-qsort],
24                  [use system qsort instead of portable one])],
25  [],[with_system_qsort=no])
26if test x$with_system_qsort != xno ; then
27  AC_DEFINE([USE_SYSTEM_QSORT], [1], [Define to 1 to use system qsort])
28fi
29
30# Set our own default (instead of "-g -O2") unless CFLAGS is already defined.
31: ${CFLAGS="-Wall -Wextra -g -O3"}
32: ${CXXFLAGS="-Wall -Wextra -std=c++0x -g -O3"}
33
34AC_PROG_CC
35AC_PROG_CXX
36AM_PROG_AR
37LT_PREREQ([2.4])
38LT_INIT([win32-dll disable-shared])
39
40AC_CONFIG_SRCDIR([st/st.c])
41AC_CONFIG_HEADERS([config.h])
42
43# Checks for programs.
44AC_C_BIGENDIAN
45AM_CONDITIONAL([CROSS_COMPILING],[test x$cross_compiling = xyes])
46
47# Building documentation requires doxygen, pdflatex, and makeindex.
48AC_CHECK_PROGS([DOXYGEN], [doxygen])
49if test -z "$DOXYGEN"; then
50   AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
51fi
52AM_CONDITIONAL([HAVE_DOXYGEN],[test -n "$DOXYGEN"])
53AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([Doxyfile])])
54
55AC_CHECK_PROGS([PDFLATEX], [pdflatex])
56if test -z "$PDFLATEX"; then
57    AC_MSG_WARN([pdflatex not found - unable to compile manual to PDF])
58fi
59AC_CHECK_PROGS([MAKEINDEX], [makeindex])
60if test -z "$MAKEINDEX"; then
61    AC_MSG_WARN([makeindex not found - unable to compile manual to PDF])
62fi
63AM_CONDITIONAL([HAVE_PDFLATEX],[test -n "$PDFLATEX" && test -n "$MAKEINDEX"])
64AM_COND_IF([HAVE_PDFLATEX], [AC_CONFIG_FILES([doc/cudd.tex])])
65
66# Checks for libraries.
67#AC_CHECK_LIB([m],[pow])
68AC_SEARCH_LIBS([pow],[m])
69AC_CHECK_LIB([pthread],[pthread_create],[have_pthreads=yes],[have_pthreads=no])
70AM_CONDITIONAL([HAVE_PTHREADS],[test x$have_pthreads = xyes])
71# Check for Windows API functions.
72AC_SEARCH_LIBS([WSAStartup],[ws2_32])
73AC_SEARCH_LIBS([GetProcessMemoryInfo],[psapi])
74
75# Checks for header files.
76# First check for mandatory headers...
77AC_CHECK_HEADERS([float.h inttypes.h limits.h stddef.h stdlib.h string.h assert.h math.h], [], [have_mandatory_headers=no])
78if test "x${have_mandatory_headers}" = xno; then
79  AC_MSG_ERROR([One or more mandatory headers missing.  Check 'config.log'.])
80fi
81# ...then check for optional C headers.
82AC_CHECK_HEADERS([unistd.h sys/time.h sys/times.h sys/resource.h sys/wait.h])
83# Finally, check C++ optional headers.
84AC_MSG_CHECKING([for working C++ thread header])
85AC_LANG_PUSH([C++])
86AC_COMPILE_IFELSE(
87  [AC_LANG_PROGRAM([#include <thread>], [[  std::thread([] {}).join()]])],
88  [have_working_thread=yes],[have_working_thread=no])
89AC_LANG_POP([C++])
90if test x$have_working_thread = xyes ; then
91  AC_MSG_RESULT(yes)
92  AC_DEFINE([HAVE_WORKING_THREAD], [1], [Define to 1 if C++ thread header is usable])
93else
94  AC_MSG_RESULT(no)
95fi
96
97# Checks for typedefs, structures, and compiler characteristics.
98AC_CHECK_HEADER_STDBOOL
99AC_C_INLINE
100AC_TYPE_SIZE_T
101AC_TYPE_UINT16_T
102AC_TYPE_UINT32_T
103AC_CHECK_TYPES([ptrdiff_t])
104AC_CHECK_SIZEOF([int])
105AC_CHECK_SIZEOF([long])
106AC_CHECK_SIZEOF([void *])
107AC_CHECK_SIZEOF([long double])
108MINGW_AC_WIN32_NATIVE_HOST
109AM_CONDITIONAL([MINGW64], [test x$mingw_cv_win32_host = xyes])
110if test x$mingw_cv_win32_host = xyes ; then
111  AC_DEFINE([__USE_MINGW_ANSI_STDIO], [1], [Define to 1 to enable C99-compliant printf on MinGW-w64])
112fi
113MODERN_CXX
114if test x$ac_cv_have_modern_cxx = xyes ; then
115  AC_DEFINE([HAVE_MODERN_CXX], [1], [Define to 1 if your compiler supports enough C++11])
116fi
117
118# Checks for library functions.
119# First the mandatory functions...
120AC_CHECK_FUNCS([pow sqrt strchr strstr],
121  [], [have_mandatory_functions=no])
122if test "x${have_mandatory_functions}" = xno; then
123  AC_MSG_ERROR([One or more mandatory functions missing.  Check 'config.log'.])
124fi
125# ...then check for optional functions.
126AC_CHECK_FUNCS([powl gethostname getrlimit getrusage sysconf])
127
128# Check for a working implementation of IEEE 754 floating point
129# Specifically, check for correct treatment of +Infinity
130AC_MSG_CHECKING([for +Infinity (IEEE 754 floating point)])
131AC_CACHE_VAL(ac_cv_have_ieee_754,
132[ AC_TRY_RUN([
133#include <math.h>
134main(void)
135{
136    if (HUGE_VAL != HUGE_VAL * 3 || HUGE_VAL != HUGE_VAL / 3) return 1;
137    return 0;
138}
139],ac_cv_have_ieee_754=yes,ac_cv_have_ieee_754=no,ac_cv_have_ieee_754=maybe)])
140if test x$ac_cv_have_ieee_754 = xmaybe ; then
141  AC_COMPILE_IFELSE(
142  [AC_LANG_PROGRAM([#include <math.h>], [  double x = INFINITY])],
143  [ac_cv_have_ieee_754=yes],[ac_cv_have_ieee_754=no])
144fi
145if test x$ac_cv_have_ieee_754 = xyes ; then
146  AC_MSG_RESULT(yes)
147  AC_DEFINE([HAVE_IEEE_754], [1], [Define to 1 if you have working floating-point infinities])
148else
149  AC_MSG_RESULT(no)
150fi
151
152
153AC_CONFIG_FILES([Makefile])
154AC_CONFIG_FILES([dddmp/exp/test1.sh], [chmod +x dddmp/exp/test1.sh])
155AC_CONFIG_FILES([dddmp/exp/test2.sh], [chmod +x dddmp/exp/test2.sh])
156AC_CONFIG_FILES([dddmp/exp/test3.sh], [chmod +x dddmp/exp/test3.sh])
157AC_CONFIG_FILES([dddmp/exp/test4.sh], [chmod +x dddmp/exp/test4.sh])
158AC_CONFIG_FILES([dddmp/exp/test5.sh], [chmod +x dddmp/exp/test5.sh])
159AC_CONFIG_FILES([dddmp/exp/test6.sh], [chmod +x dddmp/exp/test6.sh])
160AC_CONFIG_FILES([dddmp/exp/test7.sh], [chmod +x dddmp/exp/test7.sh])
161
162AC_OUTPUT
163
164echo \
165"--------------------------------------------------
166Configuration summary for ${PACKAGE_NAME} ${PACKAGE_VERSION}
167
168Build system   : ${build}
169Host system    : ${host}
170Prefix         : '${prefix}'
171Compilers      : '${CC} ${AM_CPPFLAGS} ${CPPFLAGS} ${AM_CFLAGS} ${CFLAGS}'
172               : '${CXX} ${AM_CPPFLAGS} ${CPPFLAGS} ${AM_CXXFLAGS} ${CXXFLAGS}'
173Shared library : ${enable_shared}
174 dddmp enabled : ${enable_dddmp:-no}
175 obj enabled   : ${enable_obj:-no}
176--------------------------------------------------"
177