summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Le Gall <gildor@debian.org>2023-09-12 07:50:01 +0200
committerStéphane Glondu <glondu@debian.org>2023-09-12 07:50:01 +0200
commit250f90c5a843e8b4f7373872b6ed87fbdcae9acf (patch)
tree3ac4926e37ce48e2d59d37e1e603fc73e1ccc41e
parent61a1c5d41e20568740309bde2881958076b017fc (diff)
configure_in
Gbp-Pq: Name 05_configure_in.diff
-rw-r--r--Makefile.in2
-rw-r--r--configure.in204
-rw-r--r--tests/Makefile.in4
3 files changed, 69 insertions, 141 deletions
diff --git a/Makefile.in b/Makefile.in
index c1f41c0..b2f802d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,7 +4,7 @@ RESULT=pcap
LIBINSTALL_FILES=$(wildcard *.mli *.cmi *.cma *.cmx *.cmxa *.a *.so)
CC=@CC@
-CFLAGS=@CFLAGS@
+CFLAGS=@CFLAGS@ @cp4flag@
CLIBS=$(foreach lib, @LIBS@, $(subst -l,,${lib}))
LDFLAGS=@LDFLAGS@
IDLFLAGS=-no-include
diff --git a/configure.in b/configure.in
index 0211f96..0ace885 100644
--- a/configure.in
+++ b/configure.in
@@ -1,162 +1,90 @@
+dnl Standard configuration
+
AC_INIT(pcap.idl)
-AC_MSG_CHECKING(for version)
+AC_MSG_CHECKING([for version])
VERSION="`etc/shtool version -l txt -d short VERSION`"
-AC_MSG_RESULT "Configuring Version $VERSION"
+AC_MSG_RESULT([Configuring Version $VERSION])
AC_SUBST(VERSION)
-
-AC_MSG_CHECKING(for platform)
-ARCH="`etc/shtool guessos`"
-AC_MSG_RESULT "$ARCH"
+AC_MSG_CHECKING([for platform])
+ARCH="`etc/shtool platform`"
+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
+dnl Ocaml
+
+AC_CHECK_PROG(ocamlc,ocamlc,ocamlc,no)
+if test "x$ocamlc" = "xno"; then
+ AC_MSG_ERROR([Cannot find ocamlc.])
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)
+AC_CHECK_PROG(ocamlopt,ocamlopt,ocamlopt)
+if test "x$ocamlopt" = "xno"; then
+ AC_MSG_ERROR([Cannot find ocamlopt.])
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)
+AC_CHECK_PROG(ocamlfind,ocamlfind,ocamlfind)
+if test "x$ocamlfind" = "xno"; then
+ AC_MSG_ERROR([Cannot find ocamlfind.])
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)
+dnl -------
+dnl Camlidl
+dnl -------
+
+AC_CHECK_PROG(camlidl,camlidl,camlidl)
+if test "x$camlidl" = "xno"; then
+ AC_MSG_ERROR([Cannot find camlidl.])
fi
-AC_SUBST(camlidldir)
-AC_SUBST(camlidllibdir)
-AC_SUBST(ffcalldir)
-AC_SUBST(ffcallarchive)
-AC_SUBST(libpcapdir)
-AC_SUBST(cp4flag)
+dnl Header
+
+AC_CHECK_HEADER(caml/camlidlruntime.h,,
+ AC_MSG_ERROR([can't find camlidlruntime.h]))
+
+dnl -------
+dnl Libpcap
+dnl -------
-if test "x$enable_examples" = "xyes"; then
- output="[Makefile tests/Makefile]"
-else
- output="Makefile"
+dnl Version 0.8
+AC_CHECK_LIB(pcap,
+ pcap_datalink_val_to_description,
+ [AC_DEFINE(HAVE_PCAP08)
+ cp4flag="-DHAVE_PCAP08"
+ LIBS="-lpcap $LIBS"])
+
+if test "x$cp4flag" = "x"; then
+ AC_CHECK_LIB(pcap,
+ pcap_open_live,,
+ AC_MSG_ERROR([can't find pcap library].))
fi
-AC_OUTPUT($output)
+AC_SUBST(cp4flag)
+
+dnl Header
+
+AC_CHECK_HEADER(pcap.h,,
+ AC_MSG_ERROR(can't find pcap.h))
+
+dnl ---------------
+dnl Ffcall callback
+dnl ---------------
+
+AC_CHECK_LIB(callback,
+ alloc_trampoline_r,,
+ AC_MSG_ERROR([can't find callback library.]))
+
+dnl Header
+
+AC_CHECK_HEADER(callback.h)
+
+dnl Makefile generation
+
+AC_OUTPUT([Makefile tests/Makefile])
diff --git a/tests/Makefile.in b/tests/Makefile.in
index ea6abce..9c3b4ab 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -12,7 +12,7 @@ pcap_open_offline
all: $(TARGETS)
$(TARGETS): $(OBJECTS)
- $(OCAMLC) -g -o $@ $@.cmo -I .. pcap.cma -I @camlidllibdir@ -ccopt -L@libpcapdir@ -cclib -lpcap @ffcallarchive@
+ $(OCAMLC) -g -o $@ $@.cmo -I .. pcap.cma
clean:
rm -f *.cmo *.cmi $(TARGETS)
@@ -20,5 +20,5 @@ clean:
.SUFFIXES: .ml .cmo .cmi
.ml.cmo:
- $(OCAMLC) -pp '$(CAMLP4O) pa_macro.cmo -D@cp4flag@' -I .. -c $<
+ $(OCAMLC) -pp '$(CAMLP4O) pa_macro.cmo @cp4flag@' -I .. -c $<