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