Added a documentation note about RAID devices.
[virt-top.git] / configure.ac
1 # ocaml-libvirt
2 # Copyright (C) 2007-2008 Red Hat Inc., Richard W.M. Jones
3 #
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.
8 #
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.
13 #
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
17
18 dnl Process this file with autoconf to produce a configure script.
19
20 AC_INIT(ocaml-libvirt,0.4.1.1)
21
22 dnl Check for basic C environment.
23 AC_PROG_CC
24 AC_PROG_INSTALL
25 AC_PROG_CPP
26
27 AC_C_PROTOTYPES
28 test "x$U" != "x" && AC_MSG_ERROR(Compiler not ANSI compliant)
29
30 AC_PROG_CC_C_O
31
32 dnl Select some C flags based on the host type.
33 AC_CANONICAL_HOST
34
35 DEBUG="-g"
36 WARNINGS="-Wall -Werror"
37 CFLAGS_FPIC="-fPIC"
38 WIN32=no
39 case "$host" in
40   *-*-mingw*)
41     WARNINGS="$WARNINGS -Wno-unused"
42     CFLAGS_FPIC=""
43     WIN32=yes
44 esac
45 AC_SUBST(DEBUG)
46 AC_SUBST(WARNINGS)
47 AC_SUBST(CFLAGS_FPIC)
48 AC_SUBST(WIN32)
49
50 dnl Check for libvirt development environment.
51 AC_ARG_WITH(libvirt,
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"
56          fi
57         ])
58 AC_CHECK_LIB(virt,virConnectOpen,
59         [],
60         AC_MSG_ERROR([You must install libvirt library]))
61 AC_CHECK_HEADER([libvirt/libvirt.h],
62         [],
63         AC_MSG_ERROR([You must install libvirt development package]))
64
65 dnl We also use <libvirt/virterror.h>
66 AC_CHECK_HEADER([libvirt/virterror.h],
67         [],
68         AC_MSG_ERROR([You must install libvirt development package]))
69
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,
73         [],
74         AC_MSG_ERROR([You must have libvirt >= 0.2.1]))
75
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 \
79                 virConnectGetURI \
80                 virDomainBlockStats \
81                 virDomainGetSchedulerParameters \
82                 virDomainGetSchedulerType \
83                 virDomainInterfaceStats \
84                 virDomainMigrate \
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 \
99                 virStoragePoolBuild \
100                 virStoragePoolUndefine \
101                 virStoragePoolCreate \
102                 virStoragePoolDestroy \
103                 virStoragePoolDelete \
104                 virStoragePoolFree \
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 \
122                 virStorageVolFree \
123                 virStorageVolGetInfo \
124                 virStorageVolGetXMLDesc \
125                 virStorageVolGetPath \
126 ])
127
128 # This jobs API was never published and is due to get overhauled
129 # in the near future:
130 #               virJobGetInfo
131 #               virJobGetDomain
132 #               virJobGetNetwork
133 #               virJobCancel
134 #               virJobFree
135 #               virDomainCreateLinuxJob
136 #               virDomainSaveJob
137 #               virDomainRestoreJob
138 #               virDomainCoreDumpJob
139 #               virDomainCreateJob
140 #               virNetworkCreateXMLJob
141 #               virNetworkCreateJob
142
143 dnl Check for optional types added since 0.2.1.
144 AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr],,,
145                [#include <libvirt/libvirt.h>])
146
147 dnl Check for optional ncurses.
148 AC_CHECK_LIB(ncurses,initscr)
149
150 dnl Check for optional GNOME icons (from gnome-icon-theme package).
151 AC_ARG_WITH(icons,
152         AC_HELP_STRING([--with-icons=PATH],
153                 [Set path to installed icons @<:@default=/usr/share/icons@:>@]),
154         [],[with_icons=/usr/share/icons])
155 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
162                 AC_MSG_RESULT([yes])
163                 icons="$size $f $fname $icons"
164             else
165                 AC_MSG_RESULT([no])
166             fi
167         done
168     done
169 fi
170 AC_SUBST(with_icons)
171 AC_SUBST(icons)
172
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.
176 AC_PROG_OCAML
177 AC_PROG_FINDLIB
178
179 if test "x$OCAMLFIND" != "x"; then
180     dnl Use ocamlfind to find the required packages ...
181
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'])
186     fi
187
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)
196     AC_CHECK_OCAML_PKG(gettext)
197     AC_CHECK_OCAML_PKG(bitmatch)
198
199     dnl Need to check which version of calendar is installed.
200     AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar])
201     if test "x$pkg_calendar2" = "xno"; then
202         AC_CHECK_OCAML_PKG(calendar)
203     fi
204
205     AC_SUBST(pkg_unix)
206     AC_SUBST(pkg_extlib)
207     AC_SUBST(pkg_lablgtk2)
208     AC_SUBST(pkg_curses)
209     AC_SUBST(pkg_gettext)
210     AC_SUBST(pkg_xml_light)
211     AC_SUBST(pkg_csv)
212     AC_SUBST(pkg_dbus)
213     AC_SUBST(pkg_gettext)
214     AC_SUBST(pkg_calendar)
215     AC_SUBST(pkg_calendar2)
216 else
217     dnl Use a basic module test if there is no findlib ...
218
219     dnl Check for required OCaml modules.
220     AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.])
221     if test "x$pkg_unix" = "xno"; then
222         AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
223     fi
224
225     dnl Check for optional OCaml modules.
226     AC_CHECK_OCAML_MODULE(extlib,pkg_extlib,ExtString,[+extlib])
227     AC_CHECK_OCAML_MODULE(lablgtk2,pkg_lablgtk2,GMain,[+lablgtk2])
228     AC_CHECK_OCAML_MODULE(curses,pkg_curses,Curses,[+curses])
229     AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext]) dnl XXX
230     AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light])
231     AC_CHECK_OCAML_MODULE(csv,pkg_csv,Csv,[+csv])
232     AC_CHECK_OCAML_MODULE(dbus,pkg_dbus,DBus,[+dbus])
233     AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext])
234     AC_CHECK_OCAML_MODULE(bitmatch,pkg_bitmatch,Bitmatch,[+bitmatch])
235     dnl XXX Version check - see above.
236     AC_CHECK_OCAML_MODULE(calendar,pkg_calendar,Calendar,[+calendar])
237 fi
238
239 dnl Which subpackages (== subdirs) will we build?
240 subdirs="libvirt examples mlvirsh"
241 if test "x$pkg_lablgtk2" != "xno"; then
242     subdirs="$subdirs virt-ctrl"
243 fi
244 if test "x$pkg_extlib" != "xno" -a "x$pkg_curses" != "xno"; then
245     subdirs="$subdirs virt-top"
246 fi
247 if test "x$pkg_extlib" != "xno" \
248    -a "x$pkg_xml_light" != "xno" \
249    -a "x$pkg_bitmatch" != "xno"; then
250     subdirs="$subdirs virt-df"
251 fi
252 AC_SUBST(subdirs)
253
254 dnl Check for optional perldoc (for building manual pages).
255 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
256
257 dnl Check for optional gdk-pixbuf-mlsource (for icons).
258 AC_CHECK_PROG(HAVE_GDK_PIXBUF_MLSOURCE,gdk-pixbuf-mlsource,gdk-pixbuf-mlsource)
259
260 dnl Check for recommended ocaml-gettext tool.
261 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
262
263 dnl Check for optional NSIS (for building a Windows installer).
264 AC_ARG_WITH([nsis],
265         [AS_HELP_STRING([--with-nsis],
266             [use NSIS to build a Windows installer])],
267         [],
268         [with_nsis=no])
269
270 MAKENSIS=
271 LIBVIRT_DLL_PATH=
272 LIBXDR_DLL_PATH=
273 LIBXML2_DLL_PATH=
274 GNUTLS_DLL_PATH=
275 GTK_PATH=
276 GTK_DLL_PATH=
277
278 [
279 msys_to_win_dir () {
280     eval pushd "\$$1" > /dev/null
281     eval $1=`pwd -W`
282     popd > /dev/null
283 }
284 ]
285
286 if test "x$with_nsis" != "xno"; then
287     AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
288     if test "x$MAKENSIS" = "x"; then
289         AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
290     fi
291
292     # MAKENSIS is set so we will build a rule for making a Windows
293     # installer.  To support this, generate wininstaller.nsis.
294     saved_IFS=$IFS
295     IFS=$PATH_SEPARATOR
296     for d in $PATH; do
297         IFS=$saved_IFS
298         echo Checking $d for DLLs ... >&5
299         if test -f "$d/libvirt-0.dll"; then
300             LIBVIRT_DLL_PATH="$d"
301         fi
302         if test -f "$d/libxdr.dll"; then
303             LIBXDR_DLL_PATH="$d"
304         fi
305         if test -f "$d/libxml2-2.dll"; then
306             LIBXML2_DLL_PATH="$d"
307         fi
308         if test -f "$d/libgpg-error-0.dll"; then
309             GNUTLS_DLL_PATH="$d"
310         fi
311         if test -f "$d/libgtk-win32-2.0-0.dll"; then
312             GTK_DLL_PATH="$d"
313             GTK_PATH="$d/.."
314         fi
315     done
316     IFS=$saved_IFS
317
318     if test "x$LIBVIRT_DLL_PATH" = "x"; then
319         AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
320     fi
321     if test "x$LIBXDR_DLL_PATH" = "x"; then
322         AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
323     fi
324     if test "x$LIBXML2_DLL_PATH" = "x"; then
325         AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
326     fi
327     if test "x$GNUTLS_DLL_PATH" = "x"; then
328         AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
329     fi
330     if test "x$GTK_DLL_PATH" = "x"; then
331         AC_MSG_WARN([cannot find GTK DLLs in PATH])
332     fi
333
334     # Change the paths to Windows paths.
335     msys_to_win_dir LIBVIRT_DLL_PATH
336     msys_to_win_dir LIBXDR_DLL_PATH
337     msys_to_win_dir LIBXML2_DLL_PATH
338     msys_to_win_dir GNUTLS_DLL_PATH
339     if test "x$GTK_DLL_PATH" != "x"; then
340         msys_to_win_dir GTK_DLL_PATH
341         msys_to_win_dir GTK_PATH
342     fi
343 fi
344 AC_SUBST(MAKENSIS)
345 AC_SUBST(LIBVIRT_DLL_PATH)
346 AC_SUBST(LIBXDR_DLL_PATH)
347 AC_SUBST(LIBXML2_DLL_PATH)
348 AC_SUBST(GNUTLS_DLL_PATH)
349 AC_SUBST(GTK_DLL_PATH)
350 AC_SUBST(GTK_PATH)
351
352 dnl Write gettext modules for the programs.
353 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
354 for d in mlvirsh virt-ctrl virt-df virt-top; do
355     f=`echo $d | tr - _`_gettext.ml
356     AC_MSG_NOTICE([creating $d/$f])
357     rm -f $d/$f
358     echo "(* This file is generated automatically by ./configure. *)" > $d/$f
359     if test "x$pkg_gettext" != "xno"; then
360         # Gettext module is available, so use it.
361         cat <<EOT >>$d/$f
362 module Gettext = Gettext.Program (
363   struct
364     let textdomain = "$d"
365     let codeset = None
366     let dir = None
367     let dependencies = [[]]
368   end
369 ) (GettextStub.Native)
370 EOT
371     else
372         # No gettext module is available, so fake the translation functions.
373         cat <<EOT >>$d/$f
374 module Gettext = struct
375   external s_ : string -> string = "%identity"
376   external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
377     = "%identity"
378   let sn_ : string -> string -> int -> string
379     = fun s p n -> if n = 1 then s else p
380   let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
381       -> ('a -> 'b, 'c, 'd) format
382     = fun s p n -> if n = 1 then s else p
383 end
384 EOT
385     fi
386 done
387
388 dnl Summary.
389 echo "------------------------------------------------------------"
390 echo "Thanks for downloading" $PACKAGE_STRING
391 echo " subpackages to build : $subdirs"
392 echo "------------------------------------------------------------"
393
394 dnl Produce output files.
395 AC_CONFIG_HEADERS([config.h])
396 AC_CONFIG_FILES([META
397         libvirt/libvirt_version.ml
398         Makefile
399         Make.rules
400         po/Makefile
401         libvirt/Makefile
402         examples/Makefile
403         mlvirsh/Makefile
404         virt-ctrl/Makefile
405         virt-top/Makefile
406         virt-df/Makefile
407         ])
408 if test "x$MAKENSIS" != "x"; then
409         AC_CONFIG_FILES([wininstaller.nsis])
410 fi
411 AC_OUTPUT