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.4)
24 dnl Check for basic OCaml environment & findlib.
28 if test "x$OCAMLFIND" = "x"; then
29 AC_MSG_ERROR([OCaml findlib is required])
32 dnl Use ocamlfind to find the required packages ...
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'])
40 AC_CHECK_OCAML_PKG(extlib)
41 if test "x$pkg_extlib" != "xyes"; then
42 AC_MSG_ERROR([Cannot find required OCaml package 'extlib'])
45 AC_CHECK_OCAML_PKG(libvirt)
46 if test "x$pkg_libvirt" != "xyes"; then
47 AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
50 AC_CHECK_OCAML_PKG(curses)
51 if test "x$pkg_curses" != "xyes"; then
52 AC_MSG_ERROR([Cannot find required OCaml package 'curses'])
55 dnl Check for optional OCaml packages.
56 AC_CHECK_OCAML_PKG(gettext)
57 AC_CHECK_OCAML_PKG(xml-light)
58 AC_CHECK_OCAML_PKG(csv)
60 dnl Need to check which version of calendar is installed.
61 AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar])
62 if test "x$pkg_calendar2" = "xno"; then
63 AC_CHECK_OCAML_PKG(calendar)
70 AC_SUBST(pkg_xml_light)
72 AC_SUBST(pkg_calendar)
73 AC_SUBST(pkg_calendar2)
75 dnl Check for optional perldoc (for building manual pages).
76 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
78 dnl Check for recommended ocaml-gettext tool.
79 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
81 dnl Check for msgfmt tool.
82 AC_CHECK_PROG(MSGFMT,msgfmt,msgfmt)
84 dnl Check for optional NSIS (for building a Windows installer).
85 dnl XXX NSIS support is probably broken at the moment XXX
87 [AS_HELP_STRING([--with-nsis],
88 [use NSIS to build a Windows installer])],
102 eval pushd "\$$1" > /dev/null
108 if test "x$with_nsis" != "xno"; then
109 AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
110 if test "x$MAKENSIS" = "x"; then
111 AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
114 # MAKENSIS is set so we will build a rule for making a Windows
115 # installer. To support this, generate wininstaller.nsis.
120 echo Checking $d for DLLs ... >&5
121 if test -f "$d/libvirt-0.dll"; then
122 LIBVIRT_DLL_PATH="$d"
124 if test -f "$d/libxdr.dll"; then
127 if test -f "$d/libxml2-2.dll"; then
128 LIBXML2_DLL_PATH="$d"
130 if test -f "$d/libgpg-error-0.dll"; then
133 if test -f "$d/libgtk-win32-2.0-0.dll"; then
140 if test "x$LIBVIRT_DLL_PATH" = "x"; then
141 AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
143 if test "x$LIBXDR_DLL_PATH" = "x"; then
144 AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
146 if test "x$LIBXML2_DLL_PATH" = "x"; then
147 AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
149 if test "x$GNUTLS_DLL_PATH" = "x"; then
150 AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
152 if test "x$GTK_DLL_PATH" = "x"; then
153 AC_MSG_WARN([cannot find GTK DLLs in PATH])
156 # Change the paths to Windows paths.
157 msys_to_win_dir LIBVIRT_DLL_PATH
158 msys_to_win_dir LIBXDR_DLL_PATH
159 msys_to_win_dir LIBXML2_DLL_PATH
160 msys_to_win_dir GNUTLS_DLL_PATH
161 if test "x$GTK_DLL_PATH" != "x"; then
162 msys_to_win_dir GTK_DLL_PATH
163 msys_to_win_dir GTK_PATH
167 AC_SUBST(LIBVIRT_DLL_PATH)
168 AC_SUBST(LIBXDR_DLL_PATH)
169 AC_SUBST(LIBXML2_DLL_PATH)
170 AC_SUBST(GNUTLS_DLL_PATH)
171 AC_SUBST(GTK_DLL_PATH)
174 dnl Write gettext modules for the programs.
175 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
176 for d in virt-top; do
177 f=`echo $d | tr - _`_gettext.ml
178 AC_MSG_NOTICE([creating $d/$f])
180 echo "(* This file is generated automatically by ./configure. *)" > $d/$f
181 if test "x$pkg_gettext" != "xno"; then
182 # Gettext module is available, so use it.
184 module Gettext = Gettext.Program (
186 let textdomain = "$d"
189 let dependencies = [[]]
191 ) (GettextStub.Native)
194 # No gettext module is available, so fake the translation functions.
196 module Gettext = struct
197 external s_ : string -> string = "%identity"
198 external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
200 let sn_ : string -> string -> int -> string
201 = fun s p n -> if n = 1 then s else p
202 let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
203 -> ('a -> 'b, 'c, 'd) format
204 = fun s p n -> if n = 1 then s else p
211 echo "------------------------------------------------------------"
212 echo "Thanks for downloading" $PACKAGE_STRING
213 echo "------------------------------------------------------------"
215 dnl Produce output files.
216 AC_CONFIG_HEADERS([config.h])
217 AC_CONFIG_FILES([Makefile
222 if test "x$MAKENSIS" != "x"; then
223 AC_CONFIG_FILES([wininstaller.nsis])