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