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