Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ldap.m4 « m4 - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e7659bdd5a2feedbe590cca628cc7e2df91295ed (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# LIBLDAP_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for ldap.  DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-ldap or --without-ldap.
# If not supplied, DEFAULT-ACTION is no.
#
# This macro #defines HAVE_LDAP if a required header files is
# found, and sets @LDAP_CPPFLAGS@, @LDAP_LDFLAGS@ and @LDAP_LIBS@
# to the necessary values.
#
# Users may override the detected values by doing something like:
# LDAP_LIBS="-lldap" LDAP_CPPFLAGS="-I/usr/myinclude" ./configure
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

AC_DEFUN([LIBLDAP_TRY_LINK],
[
_save_ldap_cppflags="$CPPFLAGS"
_save_ldap_cflags="$CFLAGS"
_save_ldap_ldflags="$LDFLAGS"
_save_ldap_libs="$LIBS"

LIBS="$LIBS $1"
LDFLAGS="$LDFLAGS $2"
CPPFLAGS="$CPPFLAGS $3"
CFLAGS="$CFLAGS $4"
ldap_link="no"

AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <ldap.h>
#include <lber.h>
#include <ldap_schema.h>
]], [[
printf("%p,%p", ldap_initialize, ldap_str2attributetype);
printf("%p", ber_free);
return 0;
]])],[
ldap_link="yes"
],[])

CPPFLAGS="$_save_ldap_cppflags"
CFLAGS="$_save_ldap_cflags"
LDFLAGS="$_save_ldap_ldflags"
LIBS="$_save_ldap_libs"
unset _save_ldap_cppflags
unset _save_ldap_cflags
unset _save_ldap_ldflags
unset _save_ldap_libs
]dnl
[AS_IF([test "x$ldap_link" = "xyes"], [$5], [$6])]dnl
)dnl


AC_DEFUN([LIBLDAP_CHECK_CONFIG],
[
  AC_ARG_WITH(ldap,[
If you want to check LDAP servers:
AS_HELP_STRING([--with-ldap@<:@=DIR@:>@],[Include LDAP support @<:@default=no@:>@. DIR is the LDAP base install directory, default is to search through a number of common places for the LDAP files.])],
     [ if test "$withval" = "no"; then
            want_ldap="no"
            _libldap_with="no"
        elif test "$withval" = "yes"; then
            want_ldap="yes"
            _libldap_with="yes"
        else
            want_ldap="yes"
            _libldap_with=$withval
        fi
     ],[_libldap_with=ifelse([$1],,[no],[$1])])

  if test "x$_libldap_with" != x"no"; then
        AC_MSG_CHECKING([for LDAP support of ldap.h])

        if test "$_libldap_with" = "yes"; then
                if test -f /usr/local/openldap/include/ldap.h; then
                        LDAP_INCDIR=/usr/local/openldap/include/
                        LDAP_LIBDIR=/usr/local/openldap/lib/
                        found_ldap="yes"
                elif test -f /usr/include/ldap.h; then
                        LDAP_INCDIR=/usr/include
                        LDAP_LIBDIR=/usr/lib
                        found_ldap="yes"
                elif test -f /usr/local/include/ldap.h; then
                        LDAP_INCDIR=/usr/local/include
                        LDAP_LIBDIR=/usr/local/lib
                        found_ldap="yes"
                else
                        found_ldap="no"
                        AC_MSG_RESULT(no)
                fi
        else
                if test -f $_libldap_with/include/ldap.h; then
                        LDAP_INCDIR=$_libldap_with/include
                        LDAP_LIBDIR=$_libldap_with/lib
                        _ldap_dir_lib="$LDAP_LIBDIR"

                        found_ldap="yes"
                else
                        found_ldap="no"
                        AC_MSG_RESULT(no)
                fi
        fi

        if test "x$found_ldap" != "xno"; then

                AC_MSG_RESULT(yes)
                LDAP_CPPFLAGS="-I$LDAP_INCDIR"
                LDAP_LDFLAGS="-L$LDAP_LIBDIR"

                ldap_ver=$(strings `find $LDAP_LIBDIR -name libldap.so` | grep OpenLDAP | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | tr -d '.')
                if test -n "$ldap_ver" && test "$ldap_ver" -ge 261; then
                        AC_DEFINE(HAVE_LDAP_SOURCEIP, 1, [Define to 1 if SourceIP is supported.])
                fi

                LDAP_LIBS="-lldap -llber $LDAP_LIBS"

                if test "x$enable_static" = "xyes"; then
                        LDAP_LIBS="$LDAP_LIBS -lgnutls -lpthread -lsasl2"
                elif test "x$enable_static_libs" = "xyes"; then
                        AC_MSG_CHECKING([compatibility of static LDAP libs])
                        test "x$static_linking_support" = "xno" -a -z "$_ldap_dir_lib" && AC_MSG_ERROR(["Compiler not support statically linked libs from default folders"])

                        if test "x$static_linking_support" = "xno"; then
                                LDAP_LIBS=`echo "$LDAP_LIBS"|sed "s|-lldap|$_ldap_dir_lib/libldap.a|g"|sed "s|-llber|$_ldap_dir_lib/liblber.a|g"`
                        fi

                        # without SSL and SASL
                        if test "x$static_linking_support" = "xno"; then
                                TRY_LDAP_LIBS="$LDAP_LIBS -lpthread"
                        else
                                TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lpthread"
                        fi
                        LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                LDAP_LIBS=$TRY_LDAP_LIBS
                                AC_MSG_RESULT([without SSL])
                        ])

                        # without SSL
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lpthread -lsasl2"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lpthread -lsasl2"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([without SSL])
                                ])
                        fi

                        # without SSL for Solaris
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lpthread -lsasl"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lpthread -lsasl"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([without SSL and with sasl])
                                ])
                        fi

                        # with system GnuTLS
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lgnutls -lsasl2 -lgssapi_krb5 -lpthread"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lgnutls -lsasl2 -lgssapi_krb5 -lpthread"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([with system GnuTLS linking])
                                ])
                        fi

                        # with static OpenSSL and SASL2
                        if test "x$ldap_link" = "xno" -a "x$want_openssl" = "xyes"; then
                                if test "x$static_linking_support" = "xno"; then
                                        OSSL_LDAP_LIBS="$LDAP_LIBS $OPENSSL_LIBS -lsasl2"
                                else
                                        OSSL_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS -lsasl2 ${static_linking_support}dynamic $OPENSSL_LIBS"
                                fi
                                OSSL_LDAP_CPPFLAGS="$LDAP_CPPFLAGS $OPENSSL_CPPFLAGS"
                                OSSL_LDAP_CFLAGS="$LDAP_CPPFLAGS $OPENSSL_CFLAGS"
                                OSSL_LDAP_LDFLAGS="$LDAP_LDFLAGS $OPENSSL_LDFLAGS"
                                LIBLDAP_TRY_LINK([$OSSL_LDAP_LIBS], [$OSSL_LDAP_LDFLAGS], [$OSSL_LDAP_CPPFLAGS], [$OSSL_LDAP_CFLAGS],[
                                        LDAP_LIBS="$OSSL_LDAP_LIBS"
                                        AC_MSG_RESULT([with static OpenSSL and static sasl2])
                                ])
                        fi

                        # with static OpenSSL
                        if test "x$ldap_link" = "xno" -a "x$want_openssl" = "xyes"; then
                                if test "x$static_linking_support" = "xno"; then
                                        OSSL_LDAP_LIBS="$LDAP_LIBS $OPENSSL_LIBS -lsasl2"
                                else
                                        OSSL_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic $OPENSSL_LIBS -lsasl2"
                                fi
                                OSSL_LDAP_CPPFLAGS="$LDAP_CPPFLAGS $OPENSSL_CPPFLAGS"
                                OSSL_LDAP_CFLAGS="$LDAP_CPPFLAGS $OPENSSL_CFLAGS"
                                OSSL_LDAP_LDFLAGS="$LDAP_LDFLAGS $OPENSSL_LDFLAGS"
                                LIBLDAP_TRY_LINK([$OSSL_LDAP_LIBS], [$OSSL_LDAP_LDFLAGS], [$OSSL_LDAP_CPPFLAGS], [$OSSL_LDAP_CFLAGS],[
                                        LDAP_LIBS="$OSSL_LDAP_LIBS"
                                        AC_MSG_RESULT([with static OpenSSL])
                                ])
                        fi

                        # with static OpenSSL for Solaris
                        if test "x$ldap_link" = "xno" -a "x$want_openssl" = "xyes"; then
                                if test "x$static_linking_support" = "xno"; then
                                        OSSL_LDAP_LIBS="$LDAP_LIBS $OPENSSL_LIBS -lsasl"
                                else
                                        OSSL_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic $OPENSSL_LIBS -lsasl"
                                fi
                                OSSL_LDAP_CPPFLAGS="$LDAP_CPPFLAGS $OPENSSL_CPPFLAGS"
                                OSSL_LDAP_CFLAGS="$LDAP_CPPFLAGS $OPENSSL_CFLAGS"
                                OSSL_LDAP_LDFLAGS="$LDAP_LDFLAGS $OPENSSL_LDFLAGS"
                                LIBLDAP_TRY_LINK([$OSSL_LDAP_LIBS], [$OSSL_LDAP_LDFLAGS], [$OSSL_LDAP_CPPFLAGS], [$OSSL_LDAP_CFLAGS],[
                                        LDAP_LIBS="$OSSL_LDAP_LIBS"
                                        AC_MSG_RESULT([with static OpenSSL and sasl])
                                ],[
                                        AC_MSG_ERROR([Not compatible with static OpenLDAP libs version of static OpenSSL: "$OPENSSL_LDFLAGS"])
                                ])
                        fi

                        # with system OpenSSL and SASL2
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lssl -lsasl2 -lcrypto"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS -lsasl2 ${static_linking_support}dynamic -lssl -lcrypto"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([with system OpenSSL and static sasl2 linking])
                                ])
                        fi

                        # with system OpenSSL
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lssl -lsasl2 -lcrypto"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lssl -lsasl2 -lcrypto"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([with system OpenSSL linking])
                                ])
                        fi

                        # with system OpenSSL for Solaris
                        if test "x$ldap_link" = "xno"; then
                                if test "x$static_linking_support" = "xno"; then
                                        TRY_LDAP_LIBS="$LDAP_LIBS -lssl -lsasl -lcrypto"
                                else
                                        TRY_LDAP_LIBS="${static_linking_support}static $LDAP_LIBS ${static_linking_support}dynamic -lssl -lsasl -lcrypto"
                                fi
                                LIBLDAP_TRY_LINK([$TRY_LDAP_LIBS], [$LDAP_LDFLAGS], [$LDAP_CPPFLAGS], ,[
                                        LDAP_LIBS=$TRY_LDAP_LIBS
                                        AC_MSG_RESULT([with system OpenSSL and sasl linking])
                                ])
                        fi

                        if test "x$ldap_link" = "xno"; then
                                AC_MSG_ERROR([Not found compatible version of OpenLDAP static libs])
                        fi
                fi

                found_ldap="yes"
                AC_DEFINE(HAVE_LDAP,1,[Define to 1 if LDAP should be enabled.])
                AC_DEFINE(LDAP_DEPRECATED, 1, [Define to 1 if LDAP deprecated functions is used.])

                if test "x$enable_static" = "xyes"; then
                        AC_CHECK_LIB(gnutls, main, , AC_MSG_ERROR([Not found GnuTLS library]))
                        AC_CHECK_LIB(pthread, main, , AC_MSG_ERROR([Not found Pthread library]))
                        AC_CHECK_LIB(sasl2, main, , AC_MSG_ERROR([Not found SASL2 library]))
                fi
        fi
  fi

  AC_SUBST(LDAP_CPPFLAGS)
  AC_SUBST(LDAP_LDFLAGS)
  AC_SUBST(LDAP_LIBS)

  unset _libldap_with
])dnl