2 # Copyright (C) 2007-2008 Red Hat Inc., Richard W.M. Jones
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.
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.
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
18 dnl Process this file with autoconf to produce a configure script.
20 AC_INIT([virt-top],[1.0.9])
21 AC_CONFIG_MACRO_DIR([m4])
25 dnl Check for basic OCaml environment & findlib.
29 if test "x$OCAMLFIND" = "xno"; then
30 AC_MSG_ERROR([OCaml findlib is required])
33 dnl Use ocamlfind to find the required packages ...
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'])
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'])
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'])
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'])
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 AC_CHECK_OCAML_PKG(calendar)
62 AC_SUBST(OCAML_PKG_unix)
63 AC_SUBST(OCAML_PKG_extlib)
64 AC_SUBST(OCAML_PKG_curses)
65 AC_SUBST(OCAML_PKG_gettext)
66 AC_SUBST(OCAML_PKG_xml_light)
67 AC_SUBST(OCAML_PKG_csv)
68 AC_SUBST(OCAML_PKG_calendar)
70 dnl Check for optional perldoc (for building manual pages).
71 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
73 dnl Check for recommended ocaml-gettext tool.
74 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
76 dnl Check for msgfmt tool.
77 AC_CHECK_PROG(MSGFMT,msgfmt,msgfmt)
79 dnl Substitute CFLAGS and LDFLAGS if set.
83 dnl Write gettext modules for the programs.
84 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
85 AC_MSG_NOTICE([creating src/opt_gettext.ml])
86 rm -f src/opt_gettext.ml
87 echo "(* This file is generated automatically by ./configure. *)" > src/opt_gettext.ml
88 if test "x$OCAML_PKG_gettext" != "xno"; then
89 # Gettext module is available, so use it.
90 cat <<EOT >>src/opt_gettext.ml
91 module Gettext = Gettext.Program (
93 let textdomain = "virt-top"
96 let dependencies = [[]]
98 ) (GettextStub.Native)
101 # No gettext module is available, so fake the translation functions.
102 cat <<EOT >>src/opt_gettext.ml
103 module Gettext = struct
104 external s_ : string -> string = "%identity"
105 external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
107 let sn_ : string -> string -> int -> string
108 = fun s p n -> if n = 1 then s else p
109 let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
110 -> ('a -> 'b, 'c, 'd) format
111 = fun s p n -> if n = 1 then s else p
117 echo "------------------------------------------------------------"
118 echo "Thanks for downloading" $PACKAGE_STRING
119 echo "------------------------------------------------------------"
121 dnl Produce output files.
122 AC_CONFIG_HEADERS([config.h])
123 AC_CONFIG_FILES([Makefile