summaryrefslogtreecommitdiff
path: root/config/cudd.m4
blob: d905c172569aaf274c674b5b18af88a5733c23d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# CVC4_CHECK_CUDD
# ---------------
# Check for CUDD libraries and headers.  Complicated because different
# packagers have packaged it differently.
AC_DEFUN([CVC4_CHECK_CUDD], [
CUDD_CPPFLAGS=
CUDD_LDFLAGS=
CUDD_LIBS=
cvc4cudd=no
AC_MSG_CHECKING([whether user requested CUDD support])
AC_ARG_WITH([cudd],
  [AS_HELP_STRING([--with-cudd], [force linking/not linking against CUDD])],
  [with_cudd_set=yes],
  [with_cudd=no; with_cudd_set=no])
AC_ARG_WITH([cudd-dir],
  [AS_HELP_STRING([--with-cudd-dir=DIR], [path to cudd installation])],
  [CUDD_DIR="$withval"],
  [if test "$with_cudd_set" = yes -a "$with_cudd" != yes -a "$with_cudd" != no -a "$with_cudd" != check; then
     dnl maybe the user gave --with-cudd=DIR ?
     CUDD_DIR="$with_cudd"
     with_cudd=yes
   fi])
if test -n "$CUDD_DIR" -a "$with_cudd_set" = no; then
  dnl if --with-cudd-dir or CUDD_DIR given, force --with-cudd
  dnl unless --with-cudd=... given explicitly
  with_cudd=yes
fi
if test "$with_cudd" = no; then
  if test "$with_cudd_set" = no; then
    AC_MSG_RESULT([no (enable with --with-cudd)])
  else
    AC_MSG_RESULT([no, CUDD disabled by user])
  fi
else
  if test "$with_cudd" = check; then
    AC_MSG_RESULT([no preference by user, will auto-detect])
  else
    AC_MSG_RESULT([yes, CUDD enabled by user])
  fi
  if test -z "$CUDD_DIR"; then
    dnl default location if unspecified
    CUDD_DIR=/usr
  fi
  AC_MSG_CHECKING([for C++ cudd includes under $CUDD_DIR])
  result="not found"
  cvc4save_CPPFLAGS="$CPPFLAGS"
  AC_LANG_PUSH([C++])
  for cuddinc in "$CUDD_DIR/include" "$CUDD_DIR/include/cudd" "$CUDD_DIR"; do
    CPPFLAGS="$cvc4save_CPPFLAGS -I$cuddinc"
    AC_COMPILE_IFELSE(
      [AC_LANG_PROGRAM([
#include <stdio.h>
#include "cuddObj.hh"],
         [
Cudd c;
BDD b = c.bddVar() | c.bddOne();
])],
      [ CUDD_CPPFLAGS="-I$cuddinc"
        result="$cuddinc"
        cvc4cudd=yes
        break
      ])
  done
  CPPFLAGS="$cvc4save_CPPFLAGS"
  AC_MSG_RESULT([$result])
  if test $cvc4cudd = yes; then
    AC_MSG_CHECKING([for C++ cudd libraries under $CUDD_DIR])
    cvc4cudd=no
    result="not found"
    cvc4save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $CUDD_CPPFLAGS"
    cvc4save_LDFLAGS="$LDFLAGS"
    cvc4save_LIBS="$LIBS"
    cvc4save_ac_link="$ac_link"
    ac_link="libtool --mode=link $ac_link"
    dnl This is messy.  We try to find Fedora packages, Debian packages, and
    dnl a built CUDD source directory.  We can't -lutil or -lst because these
    dnl names of CUDD libraries conflict with other libraries commonly
    dnl installed.  So we fall back to naming them directly.  The CUDD
    dnl sources build static libs only, so we go with that.
    for cuddlibdirs in "-L$CUDD_DIR/lib" "-L$CUDD_DIR/lib/cudd" "-L$CUDD_DIR"; do
      for cuddlibs in -lcuddxx -lcuddobj; do
        LDFLAGS="$cvc4save_LDFLAGS $cuddlibdirs"
        LIBS="$cvc4save_LIBS $cuddlibs"
        AC_LINK_IFELSE(
          [AC_LANG_PROGRAM([
#include <stdio.h>
#include "cuddObj.hh"],
             [
Cudd c;
BDD b = c.bddVar() | c.bddOne();
])],
          [ CUDD_LDFLAGS="$cuddlibdirs"
            CUDD_LIBS="$cuddlibs"
            result="$cuddlibdirs $cuddlibs"
            cvc4cudd=yes
            break
          ])
      done
      if test -n "$CUDD_LDFLAGS"; then break; fi
    done
    CPPFLAGS="$cvc4save_CPPFLAGS"
    LDFLAGS="$cvc4save_LDFLAGS"
    LIBS="$cvc4save_LIBS"
    ac_link="$cvc4save_ac_link"
    AC_MSG_RESULT([$result]);
    if test $cvc4cudd = yes; then
      AC_DEFINE_UNQUOTED(CVC4_CUDD, [], [Defined if using the CU Decision Diagram package (cudd).])
    fi
  fi
  AC_LANG_POP([C++])
fi
AC_SUBST([CUDD_CPPFLAGS])
AC_SUBST([CUDD_LDFLAGS])
AC_SUBST([CUDD_LIBS])

if test "$with_cudd" = yes -a "$cvc4cudd" = no; then
  AC_ERROR([--with-cudd was given, but cudd not available])
fi
])# CVC4_CHECK_CUDD
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback