GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / cmulocal / libnet.m4
1 dnl libnet.m4--libnet and includes
2 dnl Derrick Brashear
3 dnl from KTH krb and Arla
4 dnl $Id: libnet.m4,v 1.8 2005/04/26 19:14:08 shadow Exp $
5
6 AC_DEFUN([CMU_LIBNET_CFG_WHERE1], [
7 ac_cv_found_libnet_bin=no
8 if test -f "$1/libnet-config" ; then
9   ac_cv_found_libnet_cfg=yes
10 fi
11 ])
12
13 AC_DEFUN([CMU_LIBNET_CFG_WHERE], [
14    for i in $1; do
15       AC_MSG_CHECKING(for libnet config in $i)
16       CMU_LIBNET_CFG_WHERE1($i)
17       if test "$ac_cv_found_libnet_cfg" = "yes"; then
18         ac_cv_libnet_where_cfg=$i
19         AC_MSG_RESULT(found)
20         break
21       else
22         AC_MSG_RESULT(not found)
23       fi
24     done
25 ])
26
27 AC_DEFUN([CMU_LIBNET_INC_WHERE1], [
28 ac_cv_found_libnet_inc=no
29 if test -f "$1/libnet.h" ; then
30   ac_cv_found_libnet_inc=yes
31 fi
32 ])
33
34 AC_DEFUN([CMU_LIBNET_INC_WHERE], [
35    for i in $1; do
36       AC_MSG_CHECKING(for libnet header in $i)
37       CMU_LIBNET_INC_WHERE1($i)
38       if test "$ac_cv_found_libnet_inc" = "yes"; then
39         ac_cv_libnet_where_inc=$i
40         AC_MSG_RESULT(found)
41         break
42       else
43         AC_MSG_RESULT(not found)
44       fi
45     done
46 ])
47
48 AC_DEFUN([CMU_LIBNET_LIB_WHERE1], [
49 saved_LIBS=$LIBS
50 LIBS="$saved_LIBS -L$1 -lnet"
51 AC_TRY_LINK(,
52 [open_link_interface("","");],
53 [ac_cv_found_libnet_lib=yes],
54 AC_TRY_LINK(,
55 [libnet_open_link_interface("","");],
56 [
57 CMU_LIBNET_CFLAGS_ADD="-DNEW_LIBNET_INTERFACE"
58 ac_cv_found_libnet_lib=yes
59 ],
60 ac_cv_found_libnet_lib=no)
61 )
62 LIBS=$saved_LIBS
63 ])
64
65 AC_DEFUN([CMU_LIBNET_LIB_WHERE], [
66    for i in $1; do
67       AC_MSG_CHECKING(for libnet library in $i)
68       CMU_LIBNET_LIB_WHERE1($i)
69       CMU_TEST_LIBPATH($i, net)
70       if test "$ac_cv_found_libnet_lib" = "yes" ; then
71         ac_cv_libnet_where_lib=$i
72         AC_MSG_RESULT(found)
73         break
74       else
75         AC_MSG_RESULT(not found)
76       fi
77     done
78 ])
79
80 AC_DEFUN([CMU_LIBNET], [
81 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
82 AC_ARG_WITH(libnet,
83         [  --with-libnet=PREFIX      Compile with LIBNET support],
84         [if test "X$with_libnet" = "X"; then
85                 with_libnet=yes
86         fi])
87 AC_ARG_WITH(libnet-config,
88         [  --with-libnet-config=dir  use libnet config program in dir],
89         [if test "$withval" = "yes" -o "$withval" = "no"; then
90                 AC_MSG_ERROR([No argument for --with-libnet-config])
91         fi])
92 AC_ARG_WITH(libnet-lib,
93         [  --with-libnet-lib=dir     use libnet libraries in dir],
94         [if test "$withval" = "yes" -o "$withval" = "no"; then
95                 AC_MSG_ERROR([No argument for --with-libnet-lib])
96         fi])
97 AC_ARG_WITH(libnet-include,
98         [  --with-libnet-include=dir use libnet headers in dir],
99         [if test "$withval" = "yes" -o "$withval" = "no"; then
100                 AC_MSG_ERROR([No argument for --with-libnet-include])
101         fi])
102
103         if test "X$with_libnet" != "X"; then
104           if test "$with_libnet" != "yes"; then
105             if test -f "$with_libnet/libnet-config"; then
106               ac_cv_libnet_where_cfg=$with_libnet
107             else
108               ac_cv_libnet_where_cfg=$with_libnet/bin
109             fi
110             ac_cv_libnet_where_lib=$with_libnet/$CMU_LIB_SUBDIR
111             ac_cv_libnet_where_inc=$with_libnet/include
112           fi
113         fi
114
115         if test "X$with_libnet_cfg" != "X"; then
116           ac_cv_libnet_where_cfg=$with_libnet_cfg
117         fi
118         if test "X$ac_cv_libnet_where_cfg" = "X"; then
119           CMU_LIBNET_CFG_WHERE(/usr/ng/bin /usr/bin /usr/local/bin)
120         fi
121
122         if test "X$with_libnet_lib" != "X"; then
123           ac_cv_libnet_where_lib=$with_libnet_lib
124         fi
125         if test "X$ac_cv_libnet_where_lib" = "X"; then
126           CMU_LIBNET_LIB_WHERE(/usr/ng/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR /usr/local/$CMU_LIB_SUBDIR)
127         fi
128
129         if test "X$with_libnet_include" != "X"; then
130           ac_cv_libnet_where_inc=$with_libnet_include
131         fi
132         if test "X$ac_cv_libnet_where_inc" = "X"; then
133           CMU_LIBNET_INC_WHERE(/usr/ng/include /usr/include /usr/local/include)
134         fi
135
136         AC_MSG_CHECKING(whether to include libnet)
137         if test "X$ac_cv_libnet_where_lib" = "X" -o "X$ac_cv_libnet_where_inc" = "X" -o "X$ac_cv_libnet_where_cfg" = "X"; then
138           ac_cv_found_libnet=no
139           AC_MSG_RESULT(no)
140         else
141           ac_cv_found_libnet=yes
142           AC_MSG_RESULT(yes)
143           LIBNET_CONFIG=$ac_cv_libnet_where_cfg/libnet-config
144           LIBNET_INC_DIR=$ac_cv_libnet_where_inc
145           LIBNET_LIB_DIR=$ac_cv_libnet_where_lib
146
147           LIBNET_CFLAGS="`$LIBNET_CONFIG --cflags` ${CMU_LIBNET_CFLAGS_ADD}"
148           LIBNET_DEF_FLAGS="`$LIBNET_CONFIG --defines`"
149           LIBNET_INC_FLAGS="-I${LIBNET_INC_DIR}"
150           LIBNET_LIB_FLAGS="-L${LIBNET_LIB_DIR} `${LIBNET_CONFIG} --libs`"
151
152           if test "X$RPATH" = "X"; then
153                 RPATH=""
154           fi
155           case "${host}" in
156             *-*-linux*)
157               if test "X$RPATH" = "X"; then
158                 RPATH="-Wl,-rpath,${LIBNET_LIB_DIR}"
159               else 
160                 RPATH="${RPATH}:${LIBNET_LIB_DIR}"
161               fi
162               ;;
163             *-*-hpux*)
164               if test "X$RPATH" = "X"; then
165                 RPATH="-Wl,+b${LIBNET_LIB_DIR}"
166               else 
167                 RPATH="${RPATH}:${LIBNET_LIB_DIR}"
168               fi
169               ;;
170             *-*-irix*)
171               if test "X$RPATH" = "X"; then
172                 RPATH="-Wl,-rpath,${LIBNET_LIB_DIR}"
173               else 
174                 RPATH="${RPATH}:${LIBNET_LIB_DIR}"
175               fi
176               ;;
177             *-*-solaris2*)
178               if test "$ac_cv_prog_gcc" = yes; then
179                 if test "X$RPATH" = "X"; then
180                   RPATH="-Wl,-R${LIBNET_LIB_DIR}"
181                 else 
182                   RPATH="${RPATH}:${LIBNET_LIB_DIR}"
183                 fi
184               else
185                 RPATH="${RPATH} -R${LIBNET_LIB_DIR}"
186               fi
187               ;;
188           esac
189           AC_SUBST(RPATH)
190         fi
191         ])
192