Merge
[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.3.1)
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 Do we have pahole (from acme's "dwarves" library)?
35 AC_PATH_PROG(PAHOLE,pahole)
36
37 dnl Check for basic OCaml environment & findlib.
38 AC_PROG_OCAML
39 AC_PROG_FINDLIB
40
41 if test "x$OCAMLFIND" = "x"; then
42     AC_MSG_ERROR([OCaml findlib is required])
43 fi
44
45 dnl Use ocamlfind to find the required packages ...
46
47 dnl Check for required OCaml packages.
48 AC_CHECK_OCAML_PKG(unix)
49 if test "x$pkg_unix" != "xyes"; then
50     AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
51 fi
52
53 AC_CHECK_OCAML_PKG(extlib)
54 if test "x$pkg_extlib" != "xyes"; then
55     AC_MSG_ERROR([Cannot find required OCaml package 'extlib'])
56 fi
57
58 AC_CHECK_OCAML_PKG(libvirt)
59 if test "x$pkg_libvirt" != "xyes"; then
60     AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
61 fi
62
63 AC_CHECK_OCAML_PKG(xml-light)
64 if test "x$pkg_xml_light" != "xyes"; then
65     AC_MSG_ERROR([Cannot find required OCaml package 'xml-light'])
66 fi
67
68 AC_CHECK_OCAML_PKG(bitstring)
69 if test "x$pkg_bitstring" != "xyes"; then
70     AC_MSG_ERROR([Cannot find required OCaml package 'bitstring'])
71 fi
72
73 dnl Check for optional OCaml packages.
74 AC_CHECK_OCAML_PKG(gettext)
75 AC_CHECK_OCAML_PKG(csv)
76 AC_CHECK_OCAML_PKG(xmlrpc-light)
77
78 AC_SUBST(pkg_unix)
79 AC_SUBST(pkg_extlib)
80 AC_SUBST(pkg_libvirt)
81 AC_SUBST(pkg_xml_light)
82 AC_SUBST(pkg_bitstring)
83 AC_SUBST(pkg_gettext)
84 AC_SUBST(pkg_csv)
85 AC_SUBST(pkg_xmlrpc_light)
86
87 dnl Check that libvirt / ocaml-libvirt support virDomainMemoryPeek,
88 dnl because without that call nothing is going to work.
89 old_libs="$LIBS"
90 AC_SEARCH_LIBS([virDomainMemoryPeek],[virt],[],
91     [AC_MSG_ERROR(virDomainMemoryPeek call not found in libvirt.  You probably need to install a newer version of libvirt - try a version >= 0.4.4)])
92 LIBS="$old_libs"
93
94 AC_MSG_CHECKING([for Libvirt.Domain.memory_peek in ocaml-libvirt])
95 echo "Libvirt.Domain.memory_peek" > conftest.ml
96 cmd="$OCAMLFIND ocamlc -package libvirt -c conftest.ml"
97 echo $cmd >&5
98 $cmd >&5 2>&5
99 r=$?
100 rm conftest.*
101 if test "$r" -eq 0 ; then
102     AC_MSG_RESULT([ok])
103 else
104     AC_MSG_RESULT([not found])
105     AC_MSG_FAILURE([Libvirt.Domain.memory_peek call not found in ocaml-libvirt.  You probably need to install a newer version of ocaml-libvirt and libvirt - try versions >= 0.4.4])
106 fi
107
108 dnl Check for optional perldoc (for building manual pages).
109 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
110
111 dnl Check for recommended ocaml-gettext tool.
112 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
113
114 dnl Write gettext modules for the programs.
115 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
116 for d in virt-mem; do
117     f=`echo $d | tr - _`_gettext.ml
118     AC_MSG_NOTICE([creating lib/$f])
119     rm -f lib/$f
120     echo "(* This file is generated automatically by ./configure. *)" > lib/$f
121     if test "x$pkg_gettext" != "xno"; then
122         # Gettext module is available, so use it.
123         cat <<EOT >>lib/$f
124 module Gettext = Gettext.Program (
125   struct
126     let textdomain = "$d"
127     let codeset = None
128     let dir = None
129     let dependencies = [[]]
130   end
131 ) (GettextStub.Native)
132 EOT
133     else
134         # No gettext module is available, so fake the translation functions.
135         cat <<EOT >>lib/$f
136 module Gettext = struct
137   external s_ : string -> string = "%identity"
138   external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
139     = "%identity"
140   let sn_ : string -> string -> int -> string
141     = fun s p n -> if n = 1 then s else p
142   let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
143       -> ('a -> 'b, 'c, 'd) format
144     = fun s p n -> if n = 1 then s else p
145 end
146 EOT
147     fi
148 done
149
150 dnl Enable type annotation files (always, there's no penalty for doing
151 dnl this).  Use C-c C-t in emacs to print the type of an expression.
152 OCAMLCFLAGS="-dtypes -g"
153 OCAMLOPTFLAGS=""
154
155 dnl Enable profiling support for native code.
156 AC_ARG_ENABLE([profiling],
157         [AS_HELP_STRING([--enable-profiling],
158           [enable profiling for native code])],
159         [OCAMLOPTFLAGS="$OCAMLOPTFLAGS -p"])
160
161 AC_SUBST(OCAMLCFLAGS)
162 AC_SUBST(OCAMLOPTFLAGS)
163
164 dnl Summary.
165 echo "------------------------------------------------------------"
166 echo "Thanks for downloading" $PACKAGE_STRING
167 echo "------------------------------------------------------------"
168
169 dnl Produce output files.
170 AC_CONFIG_HEADERS([config.h])
171 AC_CONFIG_FILES([Makefile
172         Make.rules
173         lib/Makefile
174         lib/virt_mem_version.ml
175         uname/Makefile
176         dmesg/Makefile
177         ifconfig/Makefile
178         ps/Makefile
179         mem/Makefile
180         po/Makefile
181         extract/fedora-koji/Makefile
182         extract/codegen/Makefile
183         ])
184 AC_OUTPUT