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(ocaml-libvirt,0.4.2.1)
22 dnl Check for basic C environment.
28 test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
32 dnl Select some C flags based on the host type.
36 WARNINGS="-Wall -Werror"
41 WARNINGS="$WARNINGS -Wno-unused"
50 dnl Check for libvirt development environment.
52 AC_HELP_STRING([--with-libvirt=PATH],[Set path to installed libvirt]),
53 [if test "x$withval" != "x"; then
54 CFLAGS="$CFLAGS -I$withval/include"
55 LDFLAGS="$LDFLAGS -L$withval/lib"
58 AC_CHECK_LIB(virt,virConnectOpen,
60 AC_MSG_ERROR([You must install libvirt library]))
61 AC_CHECK_HEADER([libvirt/libvirt.h],
63 AC_MSG_ERROR([You must install libvirt development package]))
65 dnl We also use <libvirt/virterror.h>
66 AC_CHECK_HEADER([libvirt/virterror.h],
68 AC_MSG_ERROR([You must install libvirt development package]))
70 dnl Check for libvirt >= 0.2.1 (our minimum supported version).
71 dnl See: http://libvirt.org/hvsupport.html
72 AC_CHECK_FUNC(virConnectGetCapabilities,
74 AC_MSG_ERROR([You must have libvirt >= 0.2.1]))
76 dnl Check for optional libvirt functions added since 0.2.1.
77 dnl See: http://libvirt.org/hvsupport.html
78 AC_CHECK_FUNCS([virConnectGetHostname \
81 virDomainGetSchedulerParameters \
82 virDomainGetSchedulerType \
83 virDomainInterfaceStats \
85 virDomainSetSchedulerParameters \
86 virNodeGetFreeMemory \
87 virNodeGetCellsFreeMemory \
88 virStoragePoolGetConnect \
89 virConnectNumOfStoragePools \
90 virConnectListStoragePools \
91 virConnectNumOfDefinedStoragePools \
92 virConnectListDefinedStoragePools \
93 virStoragePoolLookupByName \
94 virStoragePoolLookupByUUID \
95 virStoragePoolLookupByUUIDString \
96 virStoragePoolLookupByVolume \
97 virStoragePoolCreateXML \
98 virStoragePoolDefineXML \
100 virStoragePoolUndefine \
101 virStoragePoolCreate \
102 virStoragePoolDestroy \
103 virStoragePoolDelete \
105 virStoragePoolRefresh \
106 virStoragePoolGetName \
107 virStoragePoolGetUUID \
108 virStoragePoolGetUUIDString \
109 virStoragePoolGetInfo \
110 virStoragePoolGetXMLDesc \
111 virStoragePoolGetAutostart \
112 virStoragePoolSetAutostart \
113 virStoragePoolNumOfVolumes \
114 virStoragePoolListVolumes \
115 virStorageVolLookupByName \
116 virStorageVolLookupByKey \
117 virStorageVolLookupByPath \
118 virStorageVolGetName \
119 virStorageVolGetKey \
120 virStorageVolCreateXML \
121 virStorageVolDelete \
123 virStorageVolGetInfo \
124 virStorageVolGetXMLDesc \
125 virStorageVolGetPath \
128 # This jobs API was never published and is due to get overhauled
129 # in the near future:
135 # virDomainCreateLinuxJob
137 # virDomainRestoreJob
138 # virDomainCoreDumpJob
140 # virNetworkCreateXMLJob
141 # virNetworkCreateJob
143 dnl Check for optional types added since 0.2.1.
144 AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr],,,
145 [#include <libvirt/libvirt.h>])
147 dnl Check for basic OCaml environment & findlib.
151 if test "x$OCAMLFIND" = "x"; then
152 AC_MSG_ERROR([OCaml findlib is required])
155 dnl Use ocamlfind to find the required packages ...
157 dnl Check for required OCaml packages.
158 AC_CHECK_OCAML_PKG(unix)
159 if test "x$pkg_unix" != "xyes"; then
160 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
163 dnl Check for optional OCaml packages.
164 AC_CHECK_OCAML_PKG(gettext)
166 AC_SUBST(pkg_gettext)
168 dnl Check for recommended ocaml-gettext tool.
169 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
171 dnl Check for optional NSIS (for building a Windows installer).
172 dnl XXX This probably doesn't work at the moment XXX
174 [AS_HELP_STRING([--with-nsis],
175 [use NSIS to build a Windows installer])],
189 eval pushd "\$$1" > /dev/null
195 if test "x$with_nsis" != "xno"; then
196 AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
197 if test "x$MAKENSIS" = "x"; then
198 AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
201 # MAKENSIS is set so we will build a rule for making a Windows
202 # installer. To support this, generate wininstaller.nsis.
207 echo Checking $d for DLLs ... >&5
208 if test -f "$d/libvirt-0.dll"; then
209 LIBVIRT_DLL_PATH="$d"
211 if test -f "$d/libxdr.dll"; then
214 if test -f "$d/libxml2-2.dll"; then
215 LIBXML2_DLL_PATH="$d"
217 if test -f "$d/libgpg-error-0.dll"; then
220 if test -f "$d/libgtk-win32-2.0-0.dll"; then
227 if test "x$LIBVIRT_DLL_PATH" = "x"; then
228 AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
230 if test "x$LIBXDR_DLL_PATH" = "x"; then
231 AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
233 if test "x$LIBXML2_DLL_PATH" = "x"; then
234 AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
236 if test "x$GNUTLS_DLL_PATH" = "x"; then
237 AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
239 if test "x$GTK_DLL_PATH" = "x"; then
240 AC_MSG_WARN([cannot find GTK DLLs in PATH])
243 # Change the paths to Windows paths.
244 msys_to_win_dir LIBVIRT_DLL_PATH
245 msys_to_win_dir LIBXDR_DLL_PATH
246 msys_to_win_dir LIBXML2_DLL_PATH
247 msys_to_win_dir GNUTLS_DLL_PATH
248 if test "x$GTK_DLL_PATH" != "x"; then
249 msys_to_win_dir GTK_DLL_PATH
250 msys_to_win_dir GTK_PATH
254 AC_SUBST(LIBVIRT_DLL_PATH)
255 AC_SUBST(LIBXDR_DLL_PATH)
256 AC_SUBST(LIBXML2_DLL_PATH)
257 AC_SUBST(GNUTLS_DLL_PATH)
258 AC_SUBST(GTK_DLL_PATH)
261 dnl Write gettext modules for the programs.
262 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
264 f=`echo $d | tr - _`_gettext.ml
265 AC_MSG_NOTICE([creating $d/$f])
267 echo "(* This file is generated automatically by ./configure. *)" > $d/$f
268 if test "x$pkg_gettext" != "xno"; then
269 # Gettext module is available, so use it.
271 module Gettext = Gettext.Program (
273 let textdomain = "$d"
276 let dependencies = [[]]
278 ) (GettextStub.Native)
281 # No gettext module is available, so fake the translation functions.
283 module Gettext = struct
284 external s_ : string -> string = "%identity"
285 external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
287 let sn_ : string -> string -> int -> string
288 = fun s p n -> if n = 1 then s else p
289 let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
290 -> ('a -> 'b, 'c, 'd) format
291 = fun s p n -> if n = 1 then s else p
298 echo "------------------------------------------------------------"
299 echo "Thanks for downloading" $PACKAGE_STRING
300 echo "------------------------------------------------------------"
302 dnl Produce output files.
303 AC_CONFIG_HEADERS([config.h])
304 AC_CONFIG_FILES([META
305 libvirt/libvirt_version.ml
313 if test "x$MAKENSIS" != "x"; then
314 AC_CONFIG_FILES([wininstaller.nsis])