Fix handling of OCAML_PKG_* macros for new OCaml autoconf.
[ocaml-bitstring.git] / configure.ac
1 # Bitstring syntax extension.
2 # Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
18 dnl Process this file with autoconf to produce a configure script.
19
20 AC_INIT(ocaml-bitstring,2.0.1)
21
22 dnl Check for basic C environment.
23 AC_PROG_CC
24 AC_PROG_INSTALL
25 AC_PROG_CPP
26
27 AC_C_PROTOTYPES
28 test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
29
30 AC_PROG_CC_C_O
31
32 dnl Check for native endianness.
33 AC_C_BIGENDIAN(,,
34   [AC_MSG_ERROR([Machine endianness could not be determined])]
35 )
36 if test "x$WORDS_BIGENDIAN" = "x"; then
37   NATIVEENDIAN=LittleEndian
38 else
39   NATIVEENDIAN=BigEndian
40 fi
41 AC_SUBST(NATIVEENDIAN)
42
43 dnl Create byteswap.h if the system doesn't have this file.
44 dnl Written by Oskar Liljeblad.
45 dnl From gnulib, license is LGPLv2+.
46 AC_CHECK_HEADERS([byteswap.h], [
47   BYTESWAP_H=''
48 ], [
49   BYTESWAP_H='byteswap.h'
50 ])
51 AC_SUBST(BYTESWAP_H)
52
53 dnl Check for basic OCaml environment & findlib.
54 AC_PROG_OCAML
55 AC_PROG_FINDLIB
56
57 if test "x$OCAMLFIND" = "x"; then
58     AC_MSG_ERROR([You must have ocaml and findlib installed])
59 fi
60
61 dnl Check for camlp4
62 AC_CHECK_PROG(CAMLP4OF,camlp4of.opt,camlp4of.opt,no)
63 if test "x$CAMLP4OF" = "xno"; then
64     AC_MSG_ERROR([You must have camlp4 installed])
65 fi
66
67 dnl Check for Extlib (optional)
68 AC_CHECK_OCAML_PKG(extlib)
69
70 dnl Check for CIL (optional)
71 AC_CHECK_OCAML_PKG(cil)
72
73 dnl Check for /usr/bin/time and get full path.
74 AC_PATH_PROG(TIME,time,no)
75 if test "x$TIME" = "xno"; then
76     AC_MSG_ERROR(['time' command not found])
77 fi
78
79 dnl Check for diff and get full path.
80 AC_PATH_PROG(DIFF,diff,no)
81 if test "x$DIFF" = "xno"; then
82     AC_MSG_ERROR(['diff' command not found])
83 fi
84 AC_SUBST(DIFF)
85
86 dnl Check for gprof (optional).
87 AC_CHECK_PROG(GPROF,gprof,gprof,no)
88
89 dnl Check for ocaml-bisect (optional) and --enable-coverage.
90 AC_CHECK_PROG(BISECT_REPORT,bisect-report,bisect-report,no)
91 AC_ARG_ENABLE([coverage],
92     [AS_HELP_STRING([--enable-coverage],
93         [add code coverage information (slow) @<:@default=no@:>@])],
94     [],
95     [enable_coverage=no])
96
97 if test "x$enable_coverage" != "xno" -a "x$BISECT_REPORT" = "xno"; then
98     AC_MSG_ERROR([You must install ocaml-bisect package to get code coverage])
99 fi
100 AC_SUBST(enable_coverage)
101
102 dnl Produce output files.
103 AC_CONFIG_HEADERS([config.h])
104 AC_CONFIG_FILES([Makefile META bitstring_config.ml cil-tools/Makefile])
105 AC_OUTPUT