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.6 2002/12/21 18:44:24 cg2v 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_ARG_WITH(libnet, |
82 |
[ --with-libnet=PREFIX Compile with LIBNET support], |
83 |
[if test "X$with_libnet" = "X"; then |
84 |
with_libnet=yes |
85 |
fi]) |
86 |
AC_ARG_WITH(libnet-config, |
87 |
[ --with-libnet-config=dir use libnet config program in dir], |
88 |
[if test "$withval" = "yes" -o "$withval" = "no"; then |
89 |
AC_MSG_ERROR([No argument for --with-libnet-config]) |
90 |
fi]) |
91 |
AC_ARG_WITH(libnet-lib, |
92 |
[ --with-libnet-lib=dir use libnet libraries in dir], |
93 |
[if test "$withval" = "yes" -o "$withval" = "no"; then |
94 |
AC_MSG_ERROR([No argument for --with-libnet-lib]) |
95 |
fi]) |
96 |
AC_ARG_WITH(libnet-include, |
97 |
[ --with-libnet-include=dir use libnet headers in dir], |
98 |
[if test "$withval" = "yes" -o "$withval" = "no"; then |
99 |
AC_MSG_ERROR([No argument for --with-libnet-include]) |
100 |
fi]) |
101 |
|
102 |
if test "X$with_libnet" != "X"; then |
103 |
if test "$with_libnet" != "yes"; then |
104 |
if test -f "$with_libnet/libnet-config"; then |
105 |
ac_cv_libnet_where_cfg=$with_libnet |
106 |
else |
107 |
ac_cv_libnet_where_cfg=$with_libnet/bin |
108 |
fi |
109 |
ac_cv_libnet_where_lib=$with_libnet/lib |
110 |
ac_cv_libnet_where_inc=$with_libnet/include |
111 |
fi |
112 |
fi |
113 |
|
114 |
if test "X$with_libnet_cfg" != "X"; then |
115 |
ac_cv_libnet_where_cfg=$with_libnet_cfg |
116 |
fi |
117 |
if test "X$ac_cv_libnet_where_cfg" = "X"; then |
118 |
CMU_LIBNET_CFG_WHERE(/usr/ng/bin /usr/bin /usr/local/bin) |
119 |
fi |
120 |
|
121 |
if test "X$with_libnet_lib" != "X"; then |
122 |
ac_cv_libnet_where_lib=$with_libnet_lib |
123 |
fi |
124 |
if test "X$ac_cv_libnet_where_lib" = "X"; then |
125 |
CMU_LIBNET_LIB_WHERE(/usr/ng/lib /usr/lib /usr/local/lib) |
126 |
fi |
127 |
|
128 |
if test "X$with_libnet_include" != "X"; then |
129 |
ac_cv_libnet_where_inc=$with_libnet_include |
130 |
fi |
131 |
if test "X$ac_cv_libnet_where_inc" = "X"; then |
132 |
CMU_LIBNET_INC_WHERE(/usr/ng/include /usr/include /usr/local/include) |
133 |
fi |
134 |
|
135 |
AC_MSG_CHECKING(whether to include libnet) |
136 |
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 |
137 |
ac_cv_found_libnet=no |
138 |
AC_MSG_RESULT(no) |
139 |
else |
140 |
ac_cv_found_libnet=yes |
141 |
AC_MSG_RESULT(yes) |
142 |
LIBNET_CONFIG=$ac_cv_libnet_where_cfg/libnet-config |
143 |
LIBNET_INC_DIR=$ac_cv_libnet_where_inc |
144 |
LIBNET_LIB_DIR=$ac_cv_libnet_where_lib |
145 |
|
146 |
LIBNET_CFLAGS="`$LIBNET_CONFIG --cflags` ${CMU_LIBNET_CFLAGS_ADD}" |
147 |
LIBNET_DEF_FLAGS="`$LIBNET_CONFIG --defines`" |
148 |
LIBNET_INC_FLAGS="-I${LIBNET_INC_DIR}" |
149 |
LIBNET_LIB_FLAGS="-L${LIBNET_LIB_DIR} `${LIBNET_CONFIG} --libs`" |
150 |
|
151 |
if test "X$RPATH" = "X"; then |
152 |
RPATH="" |
153 |
fi |
154 |
case "${host}" in |
155 |
*-*-linux*) |
156 |
if test "X$RPATH" = "X"; then |
157 |
RPATH="-Wl,-rpath,${LIBNET_LIB_DIR}" |
158 |
else |
159 |
RPATH="${RPATH}:${LIBNET_LIB_DIR}" |
160 |
fi |
161 |
;; |
162 |
*-*-hpux*) |
163 |
if test "X$RPATH" = "X"; then |
164 |
RPATH="-Wl,+b${LIBNET_LIB_DIR}" |
165 |
else |
166 |
RPATH="${RPATH}:${LIBNET_LIB_DIR}" |
167 |
fi |
168 |
;; |
169 |
*-*-irix*) |
170 |
if test "X$RPATH" = "X"; then |
171 |
RPATH="-Wl,-rpath,${LIBNET_LIB_DIR}" |
172 |
else |
173 |
RPATH="${RPATH}:${LIBNET_LIB_DIR}" |
174 |
fi |
175 |
;; |
176 |
*-*-solaris2*) |
177 |
if test "$ac_cv_prog_gcc" = yes; then |
178 |
if test "X$RPATH" = "X"; then |
179 |
RPATH="-Wl,-R${LIBNET_LIB_DIR}" |
180 |
else |
181 |
RPATH="${RPATH}:${LIBNET_LIB_DIR}" |
182 |
fi |
183 |
else |
184 |
RPATH="${RPATH} -R${LIBNET_LIB_DIR}" |
185 |
fi |
186 |
;; |
187 |
esac |
188 |
AC_SUBST(RPATH) |
189 |
fi |
190 |
]) |