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.1.0)
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 optional ncurses.
148 AC_CHECK_LIB(ncurses,initscr)
150 dnl Check for optional GNOME icons (from gnome-icon-theme package).
152 AC_HELP_STRING([--with-icons=PATH],
153 [Set path to installed icons @<:@default=/usr/share/icons@:>@]),
154 [],[with_icons=/usr/share/icons])
156 if test "x$with_icons" != "xno"; then
157 for size in 16 24 32 48; do
158 for f in devices/computer.png; do
159 fname="${with_icons}/gnome/${size}x${size}/${f}"
160 AC_MSG_CHECKING([checking for icon $fname])
161 if test -f "$fname"; then
163 icons="$size $f $fname $icons"
173 dnl Check for basic OCaml environment & findlib.
174 dnl Note that findlib is not necessary, but things will work better
175 dnl if it is present.
179 if test "x$OCAMLFIND" != "x"; then
180 dnl Use ocamlfind to find the required packages ...
182 dnl Check for required OCaml packages.
183 AC_CHECK_OCAML_PKG(unix)
184 if test "x$pkg_unix" != "xyes"; then
185 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
188 dnl Check for optional OCaml packages.
189 AC_CHECK_OCAML_PKG(extlib)
190 AC_CHECK_OCAML_PKG(lablgtk2)
191 AC_CHECK_OCAML_PKG(curses)
192 AC_CHECK_OCAML_PKG(gettext)
193 AC_CHECK_OCAML_PKG(xml-light)
194 AC_CHECK_OCAML_PKG(csv)
195 AC_CHECK_OCAML_PKG(dbus)
197 dnl Need to check which version of calendar is installed.
198 AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar])
199 if test "x$pkg_calendar2" = "xno"; then
200 AC_CHECK_OCAML_PKG(calendar)
205 AC_SUBST(pkg_lablgtk2)
207 AC_SUBST(pkg_gettext)
208 AC_SUBST(pkg_xml_light)
211 AC_SUBST(pkg_calendar)
212 AC_SUBST(pkg_calendar2)
214 dnl Use a basic module test if there is no findlib ...
216 dnl Check for required OCaml modules.
217 AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.])
218 if test "x$pkg_unix" = "xno"; then
219 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
222 dnl Check for optional OCaml modules.
223 AC_CHECK_OCAML_MODULE(extlib,pkg_extlib,ExtString,[+extlib])
224 AC_CHECK_OCAML_MODULE(lablgtk2,pkg_lablgtk2,GMain,[+lablgtk2])
225 AC_CHECK_OCAML_MODULE(curses,pkg_curses,Curses,[+curses])
226 AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext]) dnl XXX
227 AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light])
228 AC_CHECK_OCAML_MODULE(csv,pkg_csv,Csv,[+csv])
229 AC_CHECK_OCAML_MODULE(dbus,pkg_dbus,DBus,[+dbus])
230 dnl XXX Version check - see above.
231 AC_CHECK_OCAML_MODULE(calendar,pkg_calendar,Calendar,[+calendar])
234 dnl Which subpackages (== subdirs) will we build?
235 subdirs="libvirt examples mlvirsh"
236 if test "x$pkg_lablgtk2" != "xno"; then
237 subdirs="$subdirs virt-ctrl"
239 if test "x$pkg_extlib" != "xno" -a "x$pkg_curses" != "xno"; then
240 subdirs="$subdirs virt-top"
242 if test "x$pkg_extlib" != "xno" -a "x$pkg_xml_light" != "xno"; then
243 subdirs="$subdirs virt-df"
247 dnl Check for optional perldoc (for building manual pages).
248 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
250 dnl Check for optional gdk-pixbuf-mlsource (for icons).
251 AC_CHECK_PROG(HAVE_GDK_PIXBUF_MLSOURCE,gdk-pixbuf-mlsource,gdk-pixbuf-mlsource)
253 dnl Check for optional NSIS (for building a Windows installer).
255 [AS_HELP_STRING([--with-nsis],
256 [use NSIS to build a Windows installer])],
270 eval pushd "\$$1" > /dev/null
276 if test "x$with_nsis" != "xno"; then
277 AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
278 if test "x$MAKENSIS" = "x"; then
279 AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
282 # MAKENSIS is set so we will build a rule for making a Windows
283 # installer. To support this, generate wininstaller.nsis.
288 echo Checking $d for DLLs ... >&5
289 if test -f "$d/libvirt-0.dll"; then
290 LIBVIRT_DLL_PATH="$d"
292 if test -f "$d/libxdr.dll"; then
295 if test -f "$d/libxml2-2.dll"; then
296 LIBXML2_DLL_PATH="$d"
298 if test -f "$d/libgpg-error-0.dll"; then
301 if test -f "$d/libgtk-win32-2.0-0.dll"; then
308 if test "x$LIBVIRT_DLL_PATH" = "x"; then
309 AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
311 if test "x$LIBXDR_DLL_PATH" = "x"; then
312 AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
314 if test "x$LIBXML2_DLL_PATH" = "x"; then
315 AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
317 if test "x$GNUTLS_DLL_PATH" = "x"; then
318 AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
320 if test "x$GTK_DLL_PATH" = "x"; then
321 AC_MSG_WARN([cannot find GTK DLLs in PATH])
324 # Change the paths to Windows paths.
325 msys_to_win_dir LIBVIRT_DLL_PATH
326 msys_to_win_dir LIBXDR_DLL_PATH
327 msys_to_win_dir LIBXML2_DLL_PATH
328 msys_to_win_dir GNUTLS_DLL_PATH
329 if test "x$GTK_DLL_PATH" != "x"; then
330 msys_to_win_dir GTK_DLL_PATH
331 msys_to_win_dir GTK_PATH
335 AC_SUBST(LIBVIRT_DLL_PATH)
336 AC_SUBST(LIBXDR_DLL_PATH)
337 AC_SUBST(LIBXML2_DLL_PATH)
338 AC_SUBST(GNUTLS_DLL_PATH)
339 AC_SUBST(GTK_DLL_PATH)
343 echo "------------------------------------------------------------"
344 echo "Thanks for downloading" $PACKAGE_STRING
345 echo " subpackages to build : $subdirs"
346 echo "------------------------------------------------------------"
348 dnl Produce output files.
349 AC_CONFIG_HEADERS([config.h])
350 AC_CONFIG_FILES([META
351 libvirt/libvirt_version.ml
361 if test "x$MAKENSIS" != "x"; then
362 AC_CONFIG_FILES([wininstaller.nsis])