summaryrefslogtreecommitdiffstats
path: root/kioslave/ldap/configure.in.in
blob: b23c1238789b4e058bbf3d111d0ee6a690487021 (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
AC_MSG_CHECKING(for LDAP support)
AC_ARG_WITH(ldap,
AC_HELP_STRING([--with-ldap=PATH],[Set path for LDAP files [default=check]]),
[ case "$withval" in
  yes)
    with_ldap=CHECK
    ;;
  esac ],
[ with_ldap=CHECK ]
)dnl

if test "x$with_ldap" = "xCHECK" ; then
  with_ldap=NOTFOUND
  search_incs="$kde_includes /usr/include /usr/local/include"
  AC_FIND_FILE(ldap.h, $search_incs, ldap_incdir)
  if test -r $ldap_incdir/ldap.h ; then
    test "x$ldap_incdir" != "x/usr/include" && LDAP_INCS="-I$ldap_incdir"
    with_ldap=FOUND
  fi
  if test $with_ldap = FOUND ; then
    with_ldap=NOTFOUND
    for ext in la so sl a dylib ; do
      AC_FIND_FILE(libldap.$ext, $kde_libraries /usr/lib /usr/local/lib /usr/lib64,
        ldap_libdir)
      if test -r $ldap_libdir/libldap.$ext ; then
        if test "x$ldap_libdir" != "x/usr/lib" ; then
          LDAP_LIBS="-L$ldap_libdir "
          test "$USE_RPATH" = yes && LDAP_RPATH="-R $ldap_libdir"
        fi
        LDAP_LIBS="${LDAP_LIBS}-lldap"
        with_ldap=FOUND
        break
      fi
    done
  fi
fi

case "$with_ldap" in
no) AC_MSG_RESULT(no) ;;
framework)
  LDAP_LIBS="-Xlinker -framework -Xlinker LDAP"
  AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
  LDAP_SUBDIR="ldap"
  AC_MSG_RESULT(Apple framework)
  ;;
FOUND)
  AC_MSG_RESULT(incs=$ldap_incdir libs=$ldap_libdir)
  ;;
NOTFOUND) AC_MSG_RESULT(searched but not found) ;;
*)
  AC_MSG_RESULT($with_ldap)
  ;;
esac

LIB_LBER=
KDE_CHECK_LIB(lber, ber_alloc, [LIB_LBER=-llber], [], -L$ldap_libdir)
AC_SUBST(LIB_LBER)

AC_MSG_CHECKING(whether LDAP support can be compiled)

  if test "x$with_ldap" != "xFOUND" ; then
    LDAP_ROOT="$with_ldap"
    if test "x$LDAP_ROOT" != "x/usr" ; then
      LDAP_INCS="-I${LDAP_ROOT}/include"
      LDAP_LIBS="-L${LDAP_ROOT}/lib "
      if test "$USE_RPATH" = "yes" ; then
        LDAP_RPATH="-R ${LDAP_ROOT}/lib"
      fi
    fi
    LDAP_LIBS="${LDAP_LIBS}-lldap"
  fi
  LDAP_LIBS="${LDAP_LIBS} ${LIB_LBER} ${LIBRESOLV}"

  kde_safe_LIBS="$LIBS"
  kde_safe_CFLAGS="$CFLAGS"
  LIBS="$LIBS $all_libraries $LDAP_LIBS $KRB4_LIBS $X_EXTRA_LIBS"
  CFLAGS="$CFLAGS $all_includes $LDAP_INCS $KRB4_INCS"
  AC_LANG_SAVE
  AC_LANG_C
  AC_TRY_LINK(dnl
  [
  #include <ldap.h>
  #if LDAP_API_VERSION < 2004
  #error LDAP version too old, please upgrade to a library supporting API 2004 or higher
  #endif
  ],
  [
  LDAP *ldap;
  ],
  , with_ldap=no
  )
  AC_LANG_RESTORE
  CFLAGS=$kde_safe_CFLAGS
  LIBS=$kde_safe_LIBS
  if test "$with_ldap" = "no" ; then
    LDAP_INCS=
    LDAP_LIBS=
    LDAP_RPATH=
    LDAP_SUBDIR=
    AC_MSG_RESULT(no (but first try gave $msg))
  else
    AC_DEFINE_UNQUOTED(HAVE_LIBLDAP, 1, [Define if you have LDAP libraries])
    LDAP_SUBDIR="ldap"
    AC_MSG_RESULT(yes)
  fi

AC_SUBST(LDAP_INCS)
AC_SUBST(LDAP_LIBS)
AC_SUBST(LDAP_RPATH)

AM_CONDITIONAL(include_kioslave_ldap, test -n "$LDAP_SUBDIR")