mozldap.m4 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2007 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # License: GPL (version 3 or any later version).
  6. # See LICENSE for details.
  7. # END COPYRIGHT BLOCK
  8. AC_CHECKING(for Mozilla LDAPSDK)
  9. # check for --with-ldapsdk
  10. AC_MSG_CHECKING(for --with-ldapsdk)
  11. AC_ARG_WITH(ldapsdk, AS_HELP_STRING([--with-ldapsdk@<:@=PATH@:>@],[Mozilla LDAP SDK directory]),
  12. [
  13. if test "$withval" = yes
  14. then
  15. AC_MSG_RESULT(yes)
  16. elif test "$withval" = no
  17. then
  18. AC_MSG_RESULT(no)
  19. elif test -e "$withval"/include/ldap.h -a -d "$withval"/lib
  20. then
  21. AC_MSG_RESULT([using $withval])
  22. LDAPSDKDIR=$withval
  23. ldapsdk_inc="-I$LDAPSDKDIR/include"
  24. ldapsdk_lib="-L$LDAPSDKDIR/lib"
  25. ldapsdk_libdir="$LDAPSDKDIR/lib"
  26. ldapsdk_bindir="$LDAPSDKDIR/bin"
  27. with_ldapsdk=yes
  28. else
  29. echo
  30. AC_MSG_ERROR([$withval not found])
  31. fi
  32. if test "$with_ldapsdk" = yes -a "$with_openldap" = yes
  33. then
  34. AC_MSG_ERROR([Cannot use both LDAPSDK and OpenLDAP.])
  35. fi
  36. if test "$with_ldapsdk" != yes -a "$with_openldap" != yes
  37. then
  38. AC_MSG_ERROR([Either LDAPSDK or OpenLDAP must be used.])
  39. fi
  40. ],
  41. [
  42. if test "$with_openldap" = yes
  43. then
  44. AC_MSG_RESULT(no)
  45. else
  46. AC_MSG_RESULT(yes)
  47. with_ldapsdk=yes
  48. fi
  49. ])
  50. # check for --with-ldapsdk-inc
  51. AC_MSG_CHECKING(for --with-ldapsdk-inc)
  52. AC_ARG_WITH(ldapsdk-inc, AS_HELP_STRING([--with-ldapsdk-inc=PATH],[Mozilla LDAP SDK include directory]),
  53. [
  54. if test -e "$withval"/ldap.h
  55. then
  56. AC_MSG_RESULT([using $withval])
  57. ldapsdk_inc="-I$withval"
  58. with_ldapsdk=yes
  59. else
  60. echo
  61. AC_MSG_ERROR([$withval not found])
  62. fi
  63. ],
  64. AC_MSG_RESULT(no))
  65. # check for --with-ldapsdk-lib
  66. AC_MSG_CHECKING(for --with-ldapsdk-lib)
  67. AC_ARG_WITH(ldapsdk-lib, AS_HELP_STRING([--with-ldapsdk-lib=PATH],[Mozilla LDAP SDK library directory]),
  68. [
  69. if test -d "$withval"
  70. then
  71. AC_MSG_RESULT([using $withval])
  72. ldapsdk_lib="-L$withval"
  73. ldapsdk_libdir="$withval"
  74. with_ldapsdk=yes
  75. else
  76. echo
  77. AC_MSG_ERROR([$withval not found])
  78. fi
  79. ],
  80. AC_MSG_RESULT(no))
  81. # check for --with-ldapsdk-bin
  82. AC_MSG_CHECKING(for --with-ldapsdk-bin)
  83. AC_ARG_WITH(ldapsdk-bin, AS_HELP_STRING([--with-ldapsdk-bin=PATH],[Mozilla LDAP SDK binary directory]),
  84. [
  85. if test -d "$withval"
  86. then
  87. AC_MSG_RESULT([using $withval])
  88. ldapsdk_bindir="$withval"
  89. with_ldapsdk=yes
  90. else
  91. echo
  92. AC_MSG_ERROR([$withval not found])
  93. fi
  94. ],
  95. AC_MSG_RESULT(no))
  96. # if LDAPSDK is not found yet, try pkg-config
  97. # last resort
  98. if test "$with_ldapsdk" = yes ; then
  99. if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib" -o -z "$ldapsdk_libdir" -o -z "$ldapsdk_bindir"; then
  100. AC_PATH_PROG(PKG_CONFIG, pkg-config)
  101. AC_MSG_CHECKING(for mozldap with pkg-config)
  102. if test -n "$PKG_CONFIG"; then
  103. if $PKG_CONFIG --exists mozldap6; then
  104. mozldappkg=mozldap6
  105. elif $PKG_CONFIG --exists mozldap; then
  106. mozldappkg=mozldap
  107. else
  108. AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
  109. fi
  110. ldapsdk_inc=`$PKG_CONFIG --cflags-only-I $mozldappkg`
  111. ldapsdk_lib=`$PKG_CONFIG --libs-only-L $mozldappkg`
  112. ldapsdk_libdir=`$PKG_CONFIG --libs-only-L $mozldappkg | sed -e s/-L// | sed -e s/\ .*$//`
  113. ldapsdk_bindir=`$PKG_CONFIG --variable=bindir $mozldappkg`
  114. AC_MSG_RESULT([using system $mozldappkg])
  115. fi
  116. fi
  117. fi
  118. if test "$with_ldapsdk" = yes ; then
  119. if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
  120. AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib|-bin].])
  121. fi
  122. dnl default path for the ldap c sdk tools (see [210947] for more details)
  123. if test -z "$ldapsdk_bindir" ; then
  124. if [ -d $libdir/mozldap6 ] ; then
  125. ldapsdk_bindir=$libdir/mozldap6
  126. else
  127. ldapsdk_bindir=$libdir/mozldap
  128. fi
  129. fi
  130. dnl make sure the ldap sdk version is 6 or greater - we do not support
  131. dnl the old 5.x or prior versions - the ldap server code expects the new
  132. dnl ber types and other code used with version 6
  133. save_cppflags="$CPPFLAGS"
  134. CPPFLAGS="$ldapsdk_inc $nss_inc $nspr_inc"
  135. AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=],
  136. [#include <ldap-standard.h>
  137. #if LDAP_VENDOR_VERSION < 600
  138. #error The LDAP C SDK version is not supported
  139. #endif
  140. ])
  141. CPPFLAGS="$save_cppflags"
  142. if test -z "$isversion6" ; then
  143. AC_MSG_ERROR([The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported])
  144. fi
  145. AC_DEFINE([USE_MOZLDAP], [1], [If defined, using MozLDAP for LDAP SDK])
  146. AC_DEFINE([HAVE_LDAP_URL_PARSE_NO_DEFAULTS], [1], [have the function ldap_url_parse_no_defaults])
  147. # where to find ldapsearch, et. al.
  148. ldaptool_bindir=$ldapsdk_bindir
  149. # default options to pass to the tools
  150. ldaptool_opts=
  151. # get plain output from ldapsearch - no version
  152. plainldif_opts=-1
  153. fi