2 # Copyright (C) 2007-2021 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.1.0])
21 AM_INIT_AUTOMAKE([foreign])
22 AC_CONFIG_MACRO_DIR([m4])
27 AC_USE_SYSTEM_EXTENSIONS
29 dnl Check for basic C environment.
33 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
36 dnl Check support for 64 bit file offsets.
39 dnl Check for basic OCaml environment & findlib.
41 if test "$OCAMLC" = "no"; then
42 AC_MSG_ERROR([You must install the OCaml compiler])
45 AM_CONDITIONAL([HAVE_OCAMLOPT],[test "$OCAMLBEST" = "opt"])
48 if test "x$OCAMLFIND" = "xno"; then
49 AC_MSG_ERROR([OCaml findlib is required])
52 dnl Use ocamlfind to find the required packages ...
54 dnl Check for required OCaml packages.
55 AC_CHECK_OCAML_PKG(unix)
56 if test "x$OCAML_PKG_unix" = "xno"; then
57 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
60 AC_CHECK_OCAML_PKG(libvirt)
61 if test "x$OCAML_PKG_libvirt" = "xno"; then
62 AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
65 AC_CHECK_OCAML_PKG(curses)
66 if test "x$OCAML_PKG_curses" = "xno"; then
67 AC_MSG_ERROR([Cannot find required OCaml package 'curses'])
70 dnl Check for optional OCaml packages.
71 AC_CHECK_OCAML_PKG(calendar)
72 AC_CHECK_OCAML_PKG(csv)
73 AC_CHECK_OCAML_PKG(gettext)
74 AC_CHECK_OCAML_PKG(xml-light)
76 AM_CONDITIONAL([HAVE_PKG_CALENDAR], [test "x$OCAML_PKG_calendar" != "xno"])
77 AM_CONDITIONAL([HAVE_PKG_CSV], [test "x$OCAML_PKG_csv" != "xno"])
78 AM_CONDITIONAL([HAVE_PKG_GETTEXT], [test "x$OCAML_PKG_gettext" != "xno"])
79 AM_CONDITIONAL([HAVE_PKG_XML_LIGHT],[test "x$OCAML_PKG_xml_light" != "xno"])
81 dnl Check if ocamlc/ocamlopt -runtime-variant _pic works. It was
82 dnl added in OCaml >= 4.03, but in theory might be disabled by
83 dnl downstream distros.
84 OCAML_RUNTIME_VARIANT_PIC_OPTION=""
85 if test "x$OCAMLC" != "xno"; then
86 AC_MSG_CHECKING([if OCaml ‘-runtime-variant _pic’ works])
87 rm -f conftest.ml contest
88 echo 'print_endline "hello world"' > conftest.ml
89 if $OCAMLOPT conftest.ml -runtime-variant _pic -o conftest >&5 2>&5 ; then
91 OCAML_RUNTIME_VARIANT_PIC_OPTION="-runtime-variant _pic"
95 rm -f conftest.ml contest
97 AC_SUBST([OCAML_RUNTIME_VARIANT_PIC_OPTION])
99 dnl Check for optional perldoc (for building manual pages).
100 AC_CHECK_PROG([HAVE_PERLDOC], perldoc, perldoc)
101 AM_CONDITIONAL([HAVE_PERLDOC], [test "x$HAVE_PERLDOC" = "xperldoc"])
103 dnl Check for recommended ocaml-gettext tool.
104 AC_CHECK_PROG([OCAML_GETTEXT], ocaml-gettext, ocaml-gettext)
105 AM_CONDITIONAL([HAVE_OCAML_GETTEXT],[test "x$OCAML_GETTEXT" = "xocaml-gettext"])
107 dnl Check for GNU gettext tools (optional).
108 AC_CHECK_PROG([XGETTEXT],[xgettext],[xgettext],[no])
109 AC_CHECK_PROG([MSGCAT],[msgcat],[msgcat],[no])
110 AC_CHECK_PROG([MSGFMT],[msgfmt],[msgfmt],[no])
111 AC_CHECK_PROG([MSGMERGE],[msgmerge],[msgmerge],[no])
113 dnl Check they are the GNU gettext tools.
114 AC_MSG_CHECKING([msgfmt is GNU tool])
115 if $MSGFMT --version >/dev/null 2>&1 && $MSGFMT --version | grep -q 'GNU gettext
121 AC_MSG_RESULT([$msgfmt_is_gnu])
122 AM_CONDITIONAL([HAVE_GNU_GETTEXT],
123 [test "x$XGETTEXT" != "xno" && test "x$MSGCAT" != "xno" && test "x$MSGFMT" != "xno" && test "x$MSGMERGE" != "xno" && test "x$msgfmt_is_gnu" != "xno"])
125 dnl Check for gettext.
126 AM_GNU_GETTEXT([external])
128 dnl Write gettext modules for the programs.
129 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
130 AC_MSG_NOTICE([creating src/opt_gettext.ml])
131 rm -f src/opt_gettext.ml
132 echo "(* This file is generated automatically by ./configure. *)" > src/opt_gettext.ml
133 if test "x$OCAML_PKG_gettext" != "xno"; then
134 # Gettext module is available, so use it.
135 cat <<EOT >>src/opt_gettext.ml
136 module Gettext = Gettext.Program (
138 let textdomain = "virt-top"
141 let dependencies = [[]]
143 ) (GettextStub.Native)
146 # No gettext module is available, so fake the translation functions.
147 cat <<EOT >>src/opt_gettext.ml
148 module Gettext = struct
149 external s_ : string -> string = "%identity"
150 external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
152 let sn_ : string -> string -> int -> string
153 = fun s p n -> if n = 1 then s else p
154 let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
155 -> ('a -> 'b, 'c, 'd) format
156 = fun s p n -> if n = 1 then s else p
162 echo "------------------------------------------------------------"
163 echo "Thanks for downloading" $PACKAGE_STRING
164 echo "------------------------------------------------------------"
166 dnl Produce output files.
167 AC_CONFIG_HEADERS([config.h])
168 AC_CONFIG_FILES([ocaml-dep.sh], [chmod +x,-w ocaml-dep.sh])
169 AC_CONFIG_FILES([ocaml-link.sh], [chmod +x,-w ocaml-link.sh])
170 AC_CONFIG_FILES([Makefile