1# $Id: configure.in,v 1.15 2005/07/18 10:53:40 mederchik Exp $
2#
3# Copyright (C) 2001 Fyodor Yarochkin <fygrave@tigerteam.net>,
4#                    Ofir Arkin       <ofir@sys-security.com>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20
21AC_INIT(src/xprobe.cc)
22AC_LANG_CPLUSPLUS
23AC_ARG_PROGRAM
24
25PACKAGE=xprobe2
26VERSION='0.3'
27
28if test "x$sysconfdir" != xNONE; then
29	if test "x$prefix" = xNONE; then
30		prefix="$ac_default_prefix"
31	fi
32    CFGDIR="`eval echo $sysconfdir`/xprobe2"
33else
34    CFGDIR="$ac_default_prefix/etc/xprobe2"
35fi
36
37AC_SUBST(PACKAGE)
38AC_SUBST(VERSION)
39AC_SUBST(CFGDIR)
40AC_CONFIG_HEADER(src/config.h)
41AC_CONFIG_AUX_DIR(cfg-scripts)
42AC_PROG_CC
43AC_PROG_CXX
44AC_PROG_RANLIB
45SOURCES=`cd src; ls *.cc | awk ' { printf "%s ", $1 } '`
46AC_SUBST(SOURCES)
47HEADERS=`cd src; ls *.h | awk '!/defines.h|config.h/{ printf "%s ", $1 }'`
48AC_SUBST(HEADERS)
49
50# XXX: add -Werror for the final version
51# remove -Wmissing-prototypes, as they cause warnings
52if test -n "$GCC"; then
53    CPPFLAGS="$CPPFLAGS -Wall -W -Wcast-align \
54-Wcast-qual -Wshadow" #-Wwrite-strings
55fi
56
57AC_ARG_ENABLE(debug,
58[ --enable-debug       enable debugging )],
59                [ if test -n "$GCC"; then
60                    CPPFLAGS="$CPPFLAGS -DDEBUG -ggdb"
61                  else
62                    CPPFLAGS="$CPPFLAGS -DDEBUG"
63                  fi
64                ], )
65AC_CANONICAL_HOST
66case "$host" in
67    *-solaris*)
68        AC_DEFINE(SOLARIS,,Solaris OS)
69        LDFLAGS="${LDFLAGS} -lsocket -lnsl -lresolv -ldl"
70        HAVE_LIBDL=1
71        ;;
72    *-linux*)
73        AC_DEFINE(LINUX,,Linux OS)
74        LDFLAGS="${LDFLAGS} -ldl -rdynamic"
75        HAVE_LIBDL=1
76        ;;
77esac
78
79
80AC_HEADER_STDC
81AC_CHECK_HEADERS(strings.h)
82AC_CHECK_HEADERS(string.h)
83AC_CHECK_HEADERS(stdlib.h)
84AC_CHECK_HEADERS(unistd.h)
85AC_CHECK_HEADERS(glib.h)
86AC_CHECK_HEADERS(dlfcn.h)
87#AC_C_CONST
88
89#AC_CHECK_TYPE(uint8_t,  unsigned char)
90#AC_CHECK_TYPE(uint16_t, unsigned short)
91#AC_CHECK_TYPE(uint32_t, unsigned long)
92
93AC_CACHE_CHECK([if sa_len is in struct sockaddr], ac_cv_sockaddr_sa_len,
94AC_TRY_COMPILE([
95#include <stdio.h>
96#include <sys/types.h>
97#include <sys/socket.h>]
98,[ printf("%i\n", ((struct sockaddr *)NULL)->sa_len); ],
99[
100   ac_cv_sockaddr_sa_len=yes
101]
102  ,[
103   ac_cv_sockaddr_sa_len=no
104   ]))
105
106if test "$ac_cv_sockaddr_sa_len" = "yes"; then
107	AC_DEFINE(HAVE_SOCKADDR_SA_LEN,,Struct sockaddr has sa_len member)
108fi
109
110AC_ARG_WITH(libpcap_includes,
111	[ --with-libpcap-includes=DIR  libpcap include directory],
112	[with_libpcap_includes="$withval"],[with_libpcap_includes=no])
113
114AC_ARG_WITH(libpcap_libraries,
115	[ --with-libpcap-libraries=DIR  libpcap library directory],
116	[with_libpcap_libraries="$withval"],[with_libpcap_libraries=no])
117
118if test "$with_libpcap_includes" != "no"; then
119   CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}"
120fi
121
122if test "$with_libpcap_libraries" != "no"; then
123   LDFLAGS="${LDFLAGS}  -L${with_libpcap_libraries}"
124fi
125
126LPCAP=""
127AC_CHECK_LIB(pcap, pcap_datalink,, LPCAP="no")
128
129if test "$LPCAP" = "no"; then
130  echo
131  echo "   ERROR!  Libpcap library/headers not found."
132  echo "   http://www.tcpdump.org/ is a good place to fetch one"
133  echo "   if libpcap library is installed, use the --with-libpcap-* options"
134  echo "   to specify pathes to include and library files locations."
135  exit
136fi
137
138AC_ARG_WITH(libusipp_includes,
139	[ --with-libusipp-includes=DIR  libusipp include directory],
140	[with_libusipp_includes="$withval"],[with_libusipp_includes=no])
141
142AC_ARG_WITH(libusipp_libraries,
143	[ --with-libusipp-libraries=DIR  libusipp library directory],
144	[with_libusipp_libraries="$withval"],[with_libusipp_libraries=no])
145
146if test "$with_libusipp_includes" != "no"; then
147   CPPFLAGS="${CPPFLAGS} -I${with_libusipp_includes}"
148fi
149
150if test "$with_libusipp_libraries" != "no"; then
151   LDFLAGS="${LDFLAGS}  -L${with_libusipp_libraries}"
152fi
153
154#AC_CACHE_CHECK(if libusi++ works, ac_cv_have_libusipp,
155#AC_TRY_COMPILE([
156#
157##include <stdio.h>
158##include <usi++/usi++.h>
159##include <usi++/tcp.h>
160##include <unistd.h>
161#
162#],[
163#    TCP *tmp = new TCP("foo");
164#
165#    TCP tcp(*tmp);
166#
167#], ac_cv_have_libusipp=yes,
168#   ac_cv_have_libusipp=no
169#   ))
170#
171#
172#if test "$ac_cv_have_libusipp" = "no"; then
173#  echo
174#  echo "   ERROR!  Libusi++ library/headers not found."
175#  echo "   http://www.cs.uni-potsdam.de/homepages/students/linuxer/"
176#  echo "   is a good place to fetch one. (a copy avail. at our page too)."
177#  echo "   if libusipp library is installed, use the --with-libusipp-* options"
178#  echo "   to specify pathes to include and library files locations."
179#  exit
180#fi
181#LIBS="-lusi++ $LIBS"
182
183AC_CHECK_HEADERS(dlfcn.h,HAVE_DLFCN_H=1, DL_FAIL=1)
184if test "$HAVE_DLCFCN_H" = 1; then
185    if test "$HAVE_LIBDL" = 1; then
186        AC_CHECK_LIB(dl,dlopen,,DL_FAIL=1)
187    else
188        AC_CHECK_LIB(c,dlopen,,DL_FAIL=1)
189    fi
190fi
191
192if test "$DL_FAIL" = 1; then
193    AC_MSG_WARN("Dynamically loadable tests will not be supported");
194    AC_DEFINE(STATIC_TESTS,, Static Tests)
195else
196    DYNFLAGS="-fPIC -shared"
197    AC_SUBST(DYNFLAGS)
198fi
199
200AC_PROG_INSTALL
201AC_PROG_MAKE_SET
202
203#subdirs="libs-external/USI++/src"
204
205AC_CONFIG_SUBDIRS("libs-external/USI++/src")
206
207AC_OUTPUT([
208Makefile
209src/defines.h
210src/Makefile
211src/xplib/Makefile
212src/xpmodules/Makefile
213src/xpmodules/alive_probe/Makefile
214src/xpmodules/alive_probe/ttl_calc/Makefile
215src/xpmodules/alive_probe/portscanner/Makefile
216src/xpmodules/os_probe/Makefile
217src/xpmodules/os_probe/icmp_echo_id/Makefile
218src/xpmodules/os_probe/icmp_timestamp/Makefile
219src/xpmodules/os_probe/icmp_addrmask/Makefile
220src/xpmodules/os_probe/icmp_inforeq/Makefile
221src/xpmodules/os_probe/icmp_port_unreach/Makefile
222src/xpmodules/os_probe/tcp_handshake/Makefile
223src/xpmodules/os_probe/tcp_rst/Makefile
224src/xpmodules/os_probe/smb/Makefile
225src/xpmodules/os_probe/snmp/Makefile
226])
227