summaryrefslogtreecommitdiff
path: root/configure.in
blob: 0211f9618243e6af73798529400626e631c02d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
AC_INIT(pcap.idl)

AC_MSG_CHECKING(for version)
VERSION="`etc/shtool version -l txt -d short VERSION`"
AC_MSG_RESULT "Configuring Version $VERSION"
AC_SUBST(VERSION)


AC_MSG_CHECKING(for platform)
ARCH="`etc/shtool guessos`"
AC_MSG_RESULT "$ARCH"
AC_SUBST(ARCH)
AC_CHECKING(for ocaml compiler and tools)
AC_CHECK_PROG(ocamlc,ocamlc,ocamlc)
AC_CHECK_PROG(ocamlopt,ocamlopt,ocamlopt)
AC_CHECK_PROG(ocamlfind,ocamlfind,ocamlfind,ocamlidl)

AC_PROG_INSTALL
AC_SUBST(INSTALL)

AC_CHECKING(for C compiler)
AC_PROG_CC

AC_CHECKING(for C header files)
AC_HEADER_STDC

#
camlidldir=""
camlidllibdir=""
ffcalldir=""
ffcallarchive=""
libpcapdir=""
cp4flag=""
#

AC_ARG_ENABLE(examples,
        [  --enable-examples       build example programs [default=no]],,enable_examples="no")

#
AC_CHECKING(libraries)

#AC_CHECKING(for pcap library)
#if test "$ac_cv_lib_pcap" == "no"; then
#	#dirs="/usr/local/lib
#	#      /usr/local/lib
#	#      /usr/lib
#        #      /lib"
#        dirs="/home/x25/code/MLpcap/libpcap-0.8.3"
#	for d in $dirs; do
#  	  	test -f "$d/libpcap.a" && LDFLAGS="-L$d"
#	done
#	AC_CHECKING(in more locations)
#        unset ac_cv_lib_pcap
#fi

if test "x$enable_examples" = "xyes"; then

AC_ARG_WITH(camlidl-lib,
[  --with-camlidl-lib[=DIR]  libcamlidl.a location],
[
        camlidllibdir=$withval
        if ! test -f "$camlidllibdir/libcamlidl.a"; then
                AC_MSG_ERROR(can't find libcamlidl.a in $camlidllibdir)
        fi
],
[
        AC_MSG_ERROR(missing --with-camlidl-lib)
])

AC_CHECKING(for ffcall callback library)
        dirs="/usr/local/lib
              /usr/lib
              /lib"
        for d in $dirs; do
                test -f "$d/libcallback.a" && ffcallarchive="$d/libcallback.a"
        done
fi

AC_ARG_WITH(libpcap,
[  --with-libpcap[=DIR]      libpcap.a/.so location],
[
        libpcapdir=$withval
        if ! test -f "$libpcapdir/libpcap.a"; then
                AC_MSG_ERROR(can't find libpcap.a in $libpcapdir)
        fi

        # check for libpcap >=0.8, set CFLAGS and camlp4 flag
        `which strings` "$libpcapdir/libpcap.a"|grep to_descr 2>&1 >/dev/null
        test $? && CFLAGS="$CFLAGS -DHAVE_PCAP08" && cp4flag="HAVE_PCAP08"
],
[
        #AC_MSG_ERROR(missing --with-libpcap)
        # try the default
        libpcapdir="/usr/lib"
])


AC_CHECKING(for pcap header files)

AC_ARG_WITH(pcap-header,
[  --with-pcap-header[=DIR]  pcap header installation directory],
[
	pcapheaderdir=$withval
	AC_CHECK_HEADER($pcapheaderdir/pcap.h,
	[ CFLAGS="$CFLAGS -I$pcapheaderdir"; HAVE_PCAP_HEADER="yes" ])
],
[
	AC_CHECK_HEADER(pcap.h, [HAVE_PCAP_HEADER="yes"])
])

if test -z "$HAVE_PCAP_HEADER"; then
	AC_MSG_ERROR(can't find pcap.h)
fi

AC_CHECKING(for camlidl header)

AC_ARG_WITH(camlidl,
[  --with-camlidl[=DIR]      camlidl installation directory], 
[       
	camlidldir=$withval 
	AC_CHECK_HEADER($camlidldir/caml/camlidlruntime.h,
	[ CFLAGS="$CFLAGS -I$camlidldir"; HAVE_CAMLIDLRUNTIME_H="yes" ])
],
[
	AC_CHECK_HEADER(caml/camlidlruntime.h, [HAVE_CAMLIDLRUNTIME_H="yes"])
])

if test -z "$HAVE_CAMLIDLRUNTIME_H"; then
	AC_MSG_ERROR(can't find camlidlruntime.h)
fi

AC_CHECKING(for ffcall callback header)

AC_ARG_WITH(ffcall,
[  --with-ffcall[=DIR]       ffcall installation directory], 
[ 
	ffcalldir=$withval 
	AC_CHECK_HEADER($ffcalldir/callback.h,
	[ CFLAGS="$CFLAGS -I$ffcalldir"; HAVE_CALLBACK_H="yes" ])
],
[
	AC_CHECK_HEADER(callback.h,[HAVE_CALLBACK_H="yes"])
])

if test -z "$HAVE_CALLBACK_H"; then
	AC_MSG_ERROR(can't find callback.h)
fi

AC_SUBST(camlidldir)
AC_SUBST(camlidllibdir)
AC_SUBST(ffcalldir)
AC_SUBST(ffcallarchive)
AC_SUBST(libpcapdir)
AC_SUBST(cp4flag)

if test "x$enable_examples" = "xyes"; then
        output="[Makefile tests/Makefile]"
else
        output="Makefile"
fi

AC_OUTPUT($output)