GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / cmulocal / zephyr.m4
1 dnl zephyr.m4--Zephyr libraries and includes
2 dnl based on kafs.m4, by
3 dnl Derrick Brashear
4 dnl from KTH kafs and Arla
5 dnl $Id: zephyr.m4,v 1.2 2005/04/26 19:14:08 shadow Exp $
6
7 AC_DEFUN([CMU_ZEPHYR_INC_WHERE1], [
8 saved_CPPFLAGS=$CPPFLAGS
9 CPPFLAGS="$saved_CPPFLAGS -I$1"
10 AC_TRY_COMPILE(
11 [#include <zephyr/zephyr.h>],
12 [ZNotice_t foo;],
13 ac_cv_found_zephyr_inc=yes,
14 ac_cv_found_zephyr_inc=no)
15 CPPFLAGS=$saved_CPPFLAGS
16 ])
17
18 AC_DEFUN([CMU_ZEPHYR_INC_WHERE], [
19    for i in $1; do
20       AC_MSG_CHECKING(for zephyr headers in $i)
21       CMU_ZEPHYR_INC_WHERE1($i)
22       CMU_TEST_INCPATH($i, zephyr/zephyr)
23       if test "$ac_cv_found_zephyr_inc" = "yes"; then
24         ac_cv_zephyr_where_inc=$i
25         AC_MSG_RESULT(found)
26         break
27       else
28         AC_MSG_RESULT(not found)
29       fi
30     done
31 ])
32
33 AC_DEFUN([CMU_ZEPHYR_LIB_WHERE1], [
34 saved_LIBS=$LIBS
35 LIBS="$saved_LIBS -L$1 -lzephyr $KRB_LIB_FLAGS"
36 AC_TRY_LINK(,
37 [ZInitialize();],
38 [ac_cv_found_zephyr_lib=yes],
39 ac_cv_found_zephyr_lib=no)
40 LIBS=$saved_LIBS
41 ])
42
43 AC_DEFUN([CMU_ZEPHYR_LIB_WHERE], [
44    for i in $1; do
45       AC_MSG_CHECKING(for zephyr libraries in $i)
46       CMU_ZEPHYR_LIB_WHERE1($i)
47       dnl deal with false positives from implicit link paths
48       CMU_TEST_LIBPATH($i, zephyr)
49       if test "$ac_cv_found_zephyr_lib" = "yes" ; then
50         ac_cv_zephyr_where_lib=$i
51         AC_MSG_RESULT(found)
52         break
53       else
54         AC_MSG_RESULT(not found)
55       fi
56     done
57 ])
58
59 AC_DEFUN([CMU_ZEPHYR], [
60 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
61 AC_REQUIRE([CMU_SOCKETS])
62 AC_REQUIRE([CMU_KRB4])
63 AC_ARG_WITH(zephyr,
64         [  --with-zephyr=PREFIX      Compile with Zephyr support],
65         [if test "X$with_zephyr" = "X"; then
66                 with_zephyr=yes
67         fi])
68 AC_ARG_WITH(zephyr-lib,
69         [  --with-zephyr-lib=dir     use zephyr libraries in dir],
70         [if test "$withval" = "yes" -o "$withval" = "no"; then
71                 AC_MSG_ERROR([No argument for --with-zephyr-lib])
72         fi])
73 AC_ARG_WITH(zephyr-include,
74         [  --with-zephyr-include=dir use zephyr headers in dir],
75         [if test "$withval" = "yes" -o "$withval" = "no"; then
76                 AC_MSG_ERROR([No argument for --with-zephyr-include])
77         fi])
78
79         if test "X$with_zephyr" != "X"; then
80           if test "$with_zephyr" != "yes" -a "$with_zephyr" != no; then
81             ac_cv_zephyr_where_lib=$with_zephyr/$CMU_LIB_SUBDIR
82             ac_cv_zephyr_where_inc=$with_zephyr/include
83           fi
84         fi
85
86         if test "$with_zephyr" != "no"; then 
87           if test "X$with_zephyr_lib" != "X"; then
88             ac_cv_zephyr_where_lib=$with_zephyr_lib
89           fi
90           if test "X$ac_cv_zephyr_where_lib" = "X"; then
91             CMU_ZEPHYR_LIB_WHERE(/usr/athena/$CMU_LIB_SUBDIR /usr/local/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR)
92           fi
93
94           if test "X$with_zephyr_include" != "X"; then
95             ac_cv_zephyr_where_inc=$with_zephyr_include
96           fi
97           if test "X$ac_cv_zephyr_where_inc" = "X"; then
98             CMU_ZEPHYR_INC_WHERE(/usr/athena/include /usr/local/include /usr/include)
99           fi
100         fi
101
102         AC_MSG_CHECKING(whether to include zephyr)
103         if test "X$ac_cv_zephyr_where_lib" = "X" -a "X$ac_cv_zephyr_where_inc" = "X"; then
104           ac_cv_found_zephyr=no
105           AC_MSG_RESULT(no)
106         else
107           ac_cv_found_zephyr=yes
108           AC_MSG_RESULT(yes)
109           ZEPHYR_INC_DIR=$ac_cv_zephyr_where_inc
110           ZEPHYR_LIB_DIR=$ac_cv_zephyr_where_lib
111           ZEPHYR_INC_FLAGS="-I${ZEPHYR_INC_DIR}"
112           ZEPHYR_LIB_FLAGS="-L${ZEPHYR_LIB_DIR} -lzephyr"
113           AC_SUBST(ZEPHYT_INC_FLAGS)
114           AC_SUBST(ZEPHYR_LIB_FLAGS)
115           if test "X$RPATH" = "X"; then
116                 RPATH=""
117           fi
118           case "${host}" in
119             *-*-linux*)
120               if test "X$RPATH" = "X"; then
121                 RPATH="-Wl,-rpath,${ZEPHYR_LIB_DIR}"
122               else 
123                 RPATH="${RPATH}:${ZEPHYR_LIB_DIR}"
124               fi
125               ;;
126             *-*-hpux*)
127               if test "X$RPATH" = "X"; then
128                 RPATH="-Wl,+b${ZEPHYR_LIB_DIR}"
129               else 
130                 RPATH="${RPATH}:${ZEPHYR_LIB_DIR}"
131               fi
132               ;;
133             *-*-irix*)
134               if test "X$RPATH" = "X"; then
135                 RPATH="-Wl,-rpath,${ZEPHYR_LIB_DIR}"
136               else 
137                 RPATH="${RPATH}:${ZEPHYR_LIB_DIR}"
138               fi
139               ;;
140             *-*-solaris2*)
141               if test "$ac_cv_prog_gcc" = yes; then
142                 if test "X$RPATH" = "X"; then
143                   RPATH="-Wl,-R${ZEPHYR_LIB_DIR}"
144                 else 
145                   RPATH="${RPATH}:${ZEPHYR_LIB_DIR}"
146                 fi
147               else
148                 RPATH="${RPATH} -R${ZEPHYR_LIB_DIR}"
149               fi
150               ;;
151           esac
152           AC_SUBST(RPATH)
153         fi
154         ])
155