Rewrite critical search inner loop in C for speed.
[virt-mem.git] / configure.ac
1 # virt-mem
2 # Copyright (C) 2007-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(virt-mem,0.2.4)
21
22 AC_PROG_INSTALL
23 AC_PROG_MKDIR_P
24
25 dnl Check for an ANSI C compiler.
26 AC_GNU_SOURCE
27 AC_PROG_CC
28 AC_C_PROTOTYPES
29 test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
30 AC_PROG_CC_C_O
31
32 AC_CHECK_FUNCS([memmem])
33
34 dnl Check for basic OCaml environment & findlib.
35 AC_PROG_OCAML
36 AC_PROG_FINDLIB
37
38 if test "x$OCAMLFIND" = "x"; then
39     AC_MSG_ERROR([OCaml findlib is required])
40 fi
41
42 dnl Use ocamlfind to find the required packages ...
43
44 dnl Check for required OCaml packages.
45 AC_CHECK_OCAML_PKG(unix)
46 if test "x$pkg_unix" != "xyes"; then
47     AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
48 fi
49
50 AC_CHECK_OCAML_PKG(extlib)
51 if test "x$pkg_extlib" != "xyes"; then
52     AC_MSG_ERROR([Cannot find required OCaml package 'extlib'])
53 fi
54
55 AC_CHECK_OCAML_PKG(libvirt)
56 if test "x$pkg_libvirt" != "xyes"; then
57     AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
58 fi
59
60 AC_CHECK_OCAML_PKG(xml-light)
61 if test "x$pkg_xml_light" != "xyes"; then
62     AC_MSG_ERROR([Cannot find required OCaml package 'xml-light'])
63 fi
64
65 AC_CHECK_OCAML_PKG(bitmatch)
66 if test "x$pkg_bitmatch" != "xyes"; then
67     AC_MSG_ERROR([Cannot find required OCaml package 'bitmatch'])
68 fi
69
70 dnl Check for optional OCaml packages.
71 AC_CHECK_OCAML_PKG(gettext)
72 AC_CHECK_OCAML_PKG(csv)
73
74 AC_SUBST(pkg_unix)
75 AC_SUBST(pkg_extlib)
76 AC_SUBST(pkg_libvirt)
77 AC_SUBST(pkg_xml_light)
78 AC_SUBST(pkg_bitmatch)
79 AC_SUBST(pkg_gettext)
80 AC_SUBST(pkg_csv)
81
82 dnl Check for optional perldoc (for building manual pages).
83 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
84
85 dnl Check for recommended ocaml-gettext tool.
86 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
87
88 dnl Write gettext modules for the programs.
89 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
90 for d in virt-mem; do
91     f=`echo $d | tr - _`_gettext.ml
92     AC_MSG_NOTICE([creating lib/$f])
93     rm -f lib/$f
94     echo "(* This file is generated automatically by ./configure. *)" > lib/$f
95     if test "x$pkg_gettext" != "xno"; then
96         # Gettext module is available, so use it.
97         cat <<EOT >>lib/$f
98 module Gettext = Gettext.Program (
99   struct
100     let textdomain = "$d"
101     let codeset = None
102     let dir = None
103     let dependencies = [[]]
104   end
105 ) (GettextStub.Native)
106 EOT
107     else
108         # No gettext module is available, so fake the translation functions.
109         cat <<EOT >>lib/$f
110 module Gettext = struct
111   external s_ : string -> string = "%identity"
112   external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
113     = "%identity"
114   let sn_ : string -> string -> int -> string
115     = fun s p n -> if n = 1 then s else p
116   let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
117       -> ('a -> 'b, 'c, 'd) format
118     = fun s p n -> if n = 1 then s else p
119 end
120 EOT
121     fi
122 done
123
124 dnl Enable type annotation files (always, there's no penalty for doing
125 dnl this).  Use C-c C-t in emacs to print the type of an expression.
126 OCAMLCFLAGS="-dtypes -g"
127 OCAMLOPTFLAGS=""
128
129 dnl Enable profiling support for native code.
130 AC_ARG_ENABLE([profiling],
131         [AS_HELP_STRING([--enable-profiling],
132           [enable profiling for native code])],
133         [OCAMLOPTFLAGS="$OCAMLOPTFLAGS -p"])
134
135 AC_SUBST(OCAMLCFLAGS)
136 AC_SUBST(OCAMLOPTFLAGS)
137
138 dnl Summary.
139 echo "------------------------------------------------------------"
140 echo "Thanks for downloading" $PACKAGE_STRING
141 echo "------------------------------------------------------------"
142
143 dnl Produce output files.
144 AC_CONFIG_HEADERS([config.h])
145 AC_CONFIG_FILES([Makefile
146         Make.rules
147         lib/Makefile
148         lib/virt_mem_version.ml
149         uname/Makefile
150         dmesg/Makefile
151         ps/Makefile
152         po/Makefile
153         ])
154 AC_OUTPUT