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