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.0)
22 dnl Check for basic OCaml environment & findlib.
26 if test "x$OCAMLFIND" = "x"; then
27 AC_MSG_ERROR([OCaml findlib is required])
30 dnl Use ocamlfind to find the required packages ...
32 dnl Check for required OCaml packages.
33 AC_CHECK_OCAML_PKG(unix)
34 if test "x$pkg_unix" != "xyes"; then
35 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
38 AC_CHECK_OCAML_PKG(extlib)
39 if test "x$pkg_extlib" != "xyes"; then
40 AC_MSG_ERROR([Cannot find required OCaml package 'extlib'])
43 AC_CHECK_OCAML_PKG(libvirt)
44 if test "x$pkg_libvirt" != "xyes"; then
45 AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
48 AC_CHECK_OCAML_PKG(curses)
49 if test "x$pkg_curses" != "xyes"; then
50 AC_MSG_ERROR([Cannot find required OCaml package 'curses'])
53 dnl Check for optional OCaml packages.
54 AC_CHECK_OCAML_PKG(gettext)
55 AC_CHECK_OCAML_PKG(xml-light)
56 AC_CHECK_OCAML_PKG(csv)
58 dnl Need to check which version of calendar is installed.
59 AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar])
60 if test "x$pkg_calendar2" = "xno"; then
61 AC_CHECK_OCAML_PKG(calendar)
68 AC_SUBST(pkg_xml_light)
70 AC_SUBST(pkg_calendar)
71 AC_SUBST(pkg_calendar2)
73 dnl Check for optional perldoc (for building manual pages).
74 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
76 dnl Check for recommended ocaml-gettext tool.
77 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
79 dnl Check for optional NSIS (for building a Windows installer).
80 dnl XXX NSIS support is probably broken at the moment XXX
82 [AS_HELP_STRING([--with-nsis],
83 [use NSIS to build a Windows installer])],
97 eval pushd "\$$1" > /dev/null
103 if test "x$with_nsis" != "xno"; then
104 AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
105 if test "x$MAKENSIS" = "x"; then
106 AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
109 # MAKENSIS is set so we will build a rule for making a Windows
110 # installer. To support this, generate wininstaller.nsis.
115 echo Checking $d for DLLs ... >&5
116 if test -f "$d/libvirt-0.dll"; then
117 LIBVIRT_DLL_PATH="$d"
119 if test -f "$d/libxdr.dll"; then
122 if test -f "$d/libxml2-2.dll"; then
123 LIBXML2_DLL_PATH="$d"
125 if test -f "$d/libgpg-error-0.dll"; then
128 if test -f "$d/libgtk-win32-2.0-0.dll"; then
135 if test "x$LIBVIRT_DLL_PATH" = "x"; then
136 AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
138 if test "x$LIBXDR_DLL_PATH" = "x"; then
139 AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
141 if test "x$LIBXML2_DLL_PATH" = "x"; then
142 AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
144 if test "x$GNUTLS_DLL_PATH" = "x"; then
145 AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
147 if test "x$GTK_DLL_PATH" = "x"; then
148 AC_MSG_WARN([cannot find GTK DLLs in PATH])
151 # Change the paths to Windows paths.
152 msys_to_win_dir LIBVIRT_DLL_PATH
153 msys_to_win_dir LIBXDR_DLL_PATH
154 msys_to_win_dir LIBXML2_DLL_PATH
155 msys_to_win_dir GNUTLS_DLL_PATH
156 if test "x$GTK_DLL_PATH" != "x"; then
157 msys_to_win_dir GTK_DLL_PATH
158 msys_to_win_dir GTK_PATH
162 AC_SUBST(LIBVIRT_DLL_PATH)
163 AC_SUBST(LIBXDR_DLL_PATH)
164 AC_SUBST(LIBXML2_DLL_PATH)
165 AC_SUBST(GNUTLS_DLL_PATH)
166 AC_SUBST(GTK_DLL_PATH)
169 dnl Write gettext modules for the programs.
170 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
171 for d in virt-top; do
172 f=`echo $d | tr - _`_gettext.ml
173 AC_MSG_NOTICE([creating $d/$f])
175 echo "(* This file is generated automatically by ./configure. *)" > $d/$f
176 if test "x$pkg_gettext" != "xno"; then
177 # Gettext module is available, so use it.
179 module Gettext = Gettext.Program (
181 let textdomain = "$d"
184 let dependencies = [[]]
186 ) (GettextStub.Native)
189 # No gettext module is available, so fake the translation functions.
191 module Gettext = struct
192 external s_ : string -> string = "%identity"
193 external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
195 let sn_ : string -> string -> int -> string
196 = fun s p n -> if n = 1 then s else p
197 let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
198 -> ('a -> 'b, 'c, 'd) format
199 = fun s p n -> if n = 1 then s else p
206 echo "------------------------------------------------------------"
207 echo "Thanks for downloading" $PACKAGE_STRING
208 echo "------------------------------------------------------------"
210 dnl Produce output files.
211 AC_CONFIG_HEADERS([config.h])
212 AC_CONFIG_FILES([Makefile
217 if test "x$MAKENSIS" != "x"; then
218 AC_CONFIG_FILES([wininstaller.nsis])