Notes.
[virt-top.git] / configure.ac
1 # ocaml-libvirt
2 # Copyright (C) 2007 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.0.2)
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 Check for libvirt >= 0.2.1 (our minimum supported version).
66 dnl See: http://libvirt.org/hvsupport.html
67 AC_CHECK_FUNC(virConnectGetCapabilities,
68         [],
69         AC_MSG_ERROR([You must have libvirt >= 0.2.1]))
70
71 dnl Check for optional libvirt functions added since 0.2.1.
72 dnl See: http://libvirt.org/hvsupport.html
73 AC_CHECK_FUNCS([virConnectGetHostname \
74                 virConnectGetURI \
75                 virDomainBlockStats \
76                 virDomainGetSchedulerParameters \
77                 virDomainGetSchedulerType \
78                 virDomainInterfaceStats \
79                 virDomainMigrate \
80                 virDomainSetSchedulerParameters \
81                 virNodeGetFreeMemory \
82                 virNodeGetCellsFreeMemory \
83                 virJobGetInfo \
84                 virJobGetDomain \
85                 virJobGetNetwork \
86                 virJobCancel \
87                 virJobFree \
88                 virDomainCreateLinuxJob \
89                 virDomainSaveJob \
90                 virDomainRestoreJob \
91                 virDomainCoreDumpJob \
92                 virDomainCreateJob \
93                 virNetworkCreateXMLJob \
94                 virNetworkCreateJob \
95                 virStoragePoolGetConnect \
96                 virConnectNumOfStoragePools \
97                 virConnectListStoragePools \
98                 virConnectNumOfDefinedStoragePools \
99                 virConnectListDefinedStoragePools \
100                 virConnectDiscoverStoragePools \
101                 virStoragePoolLookupByName \
102                 virStoragePoolLookupByUUID \
103                 virStoragePoolLookupByUUIDString \
104                 virStoragePoolLookupByVolume \
105                 virStoragePoolCreateXML \
106                 virStoragePoolDefineXML \
107                 virStoragePoolUndefine \
108                 virStoragePoolCreate \
109                 virStoragePoolDestroy \
110                 virStoragePoolShutdown \
111                 virStoragePoolFree \
112                 virStoragePoolRefresh \
113                 virStoragePoolGetName \
114                 virStoragePoolGetUUID \
115                 virStoragePoolGetUUIDString \
116                 virStoragePoolGetInfo \
117                 virStoragePoolGetXMLDesc \
118                 virStoragePoolGetAutostart \
119                 virStoragePoolSetAutostart \
120                 virStoragePoolNumOfVolumes \
121                 virStoragePoolListVolumes \
122                 virStorageVolLookupByName \
123                 virStorageVolLookupByKey \
124                 virStorageVolLookupByPath \
125                 virStorageVolGetName \
126                 virStorageVolGetKey \
127                 virStorageVolCreateXML \
128                 virStorageVolDestroy \
129                 virStorageVolFree \
130                 virStorageVolGetInfo \
131                 virStorageVolGetXMLDesc \
132                 virStorageVolGetPath \
133 ])
134
135 dnl Check for optional types added since 0.2.1.
136 AC_CHECK_TYPES([virJobPtr, virStoragePoolPtr, virStorageVolPtr])
137
138 dnl We also use <libvirt/virterror.h>
139 AC_CHECK_HEADER([libvirt/virterror.h],
140         [],
141         AC_MSG_ERROR([You must install libvirt development package]))
142
143 dnl Check for optional ncurses.
144 AC_CHECK_LIB(ncurses,initscr)
145
146 dnl Check for basic OCaml environment & findlib.
147 dnl Note that findlib is not necessary, but things will work better
148 dnl if it is present.
149 AC_PROG_OCAML
150 AC_PROG_FINDLIB
151
152 if test "x$OCAMLFIND" != "x"; then
153     dnl Use ocamlfind to find the required packages ...
154
155     dnl Check for required OCaml packages.
156     AC_CHECK_OCAML_PKG(unix)
157     if test "x$pkg_unix" != "xyes"; then
158         AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
159     fi
160
161     dnl Check for optional OCaml packages.
162     AC_CHECK_OCAML_PKG(extlib)
163     AC_CHECK_OCAML_PKG(lablgtk2)
164     AC_CHECK_OCAML_PKG(curses)
165     AC_CHECK_OCAML_PKG(gettext)
166     AC_CHECK_OCAML_PKG(xml-light)
167     AC_CHECK_OCAML_PKG(csv)
168     AC_CHECK_OCAML_PKG(calendar)
169
170     AC_SUBST(pkg_unix)
171     AC_SUBST(pkg_extlib)
172     AC_SUBST(pkg_lablgtk2)
173     AC_SUBST(pkg_curses)
174     AC_SUBST(pkg_gettext)
175     AC_SUBST(pkg_xml_light)
176     AC_SUBST(pkg_csv)
177     AC_SUBST(pkg_calendar)
178 else
179     dnl Use a basic module test if there is no findlib ...
180
181     dnl Check for required OCaml modules.
182     AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.])
183     if test "x$pkg_unix" = "xno"; then
184         AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
185     fi
186
187     dnl Check for optional OCaml modules.
188     AC_CHECK_OCAML_MODULE(extlib,pkg_extlib,ExtString,[+extlib])
189     AC_CHECK_OCAML_MODULE(lablgtk2,pkg_lablgtk2,GMain,[+lablgtk2])
190     AC_CHECK_OCAML_MODULE(curses,pkg_curses,Curses,[+curses])
191     AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext]) dnl XXX
192     AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light])
193     AC_CHECK_OCAML_MODULE(csv,pkg_csv,Csv,[+csv])
194     AC_CHECK_OCAML_MODULE(calendar,pkg_calendar,Calendar,[+calendar])
195 fi
196
197 dnl Which subpackages (== subdirs) will we build?
198 subdirs="libvirt examples mlvirsh"
199 if test "x$pkg_lablgtk2" != "xno"; then
200     subdirs="$subdirs virt-ctrl"
201 fi
202 if test "x$pkg_extlib" != "xno" -a "x$pkg_curses" != "xno"; then
203     subdirs="$subdirs virt-top"
204 fi
205 if test "x$pkg_extlib" != "xno" -a "x$pkg_xml_light" != "xno"; then
206     subdirs="$subdirs virt-df"
207 fi
208 AC_SUBST(subdirs)
209
210 dnl Check for optional perldoc (for building manual pages).
211 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
212
213 dnl Check for optional NSIS (for building a Windows installer).
214 AC_ARG_WITH([nsis],
215         [AS_HELP_STRING([--with-nsis],
216             [use NSIS to build a Windows installer])],
217         [],
218         [with_nsis=no])
219
220 MAKENSIS=
221 LIBVIRT_DLL_PATH=
222 LIBXDR_DLL_PATH=
223 LIBXML2_DLL_PATH=
224 GNUTLS_DLL_PATH=
225 GTK_PATH=
226 GTK_DLL_PATH=
227
228 [
229 msys_to_win_dir () {
230     eval pushd "\$$1" > /dev/null
231     eval $1=`pwd -W`
232     popd > /dev/null
233 }
234 ]
235
236 if test "x$with_nsis" != "xno"; then
237     AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
238     if test "x$MAKENSIS" = "x"; then
239         AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
240     fi
241
242     # MAKENSIS is set so we will build a rule for making a Windows
243     # installer.  To support this, generate wininstaller.nsis.
244     saved_IFS=$IFS
245     IFS=$PATH_SEPARATOR
246     for d in $PATH; do
247         IFS=$saved_IFS
248         echo Checking $d for DLLs ... >&5
249         if test -f "$d/libvirt-0.dll"; then
250             LIBVIRT_DLL_PATH="$d"
251         fi
252         if test -f "$d/libxdr.dll"; then
253             LIBXDR_DLL_PATH="$d"
254         fi
255         if test -f "$d/libxml2-2.dll"; then
256             LIBXML2_DLL_PATH="$d"
257         fi
258         if test -f "$d/libgpg-error-0.dll"; then
259             GNUTLS_DLL_PATH="$d"
260         fi
261         if test -f "$d/libgtk-win32-2.0-0.dll"; then
262             GTK_DLL_PATH="$d"
263             GTK_PATH="$d/.."
264         fi
265     done
266     IFS=$saved_IFS
267
268     if test "x$LIBVIRT_DLL_PATH" = "x"; then
269         AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
270     fi
271     if test "x$LIBXDR_DLL_PATH" = "x"; then
272         AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
273     fi
274     if test "x$LIBXML2_DLL_PATH" = "x"; then
275         AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
276     fi
277     if test "x$GNUTLS_DLL_PATH" = "x"; then
278         AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
279     fi
280     if test "x$GTK_DLL_PATH" = "x"; then
281         AC_MSG_WARN([cannot find GTK DLLs in PATH])
282     fi
283
284     # Change the paths to Windows paths.
285     msys_to_win_dir LIBVIRT_DLL_PATH
286     msys_to_win_dir LIBXDR_DLL_PATH
287     msys_to_win_dir LIBXML2_DLL_PATH
288     msys_to_win_dir GNUTLS_DLL_PATH
289     if test "x$GTK_DLL_PATH" != "x"; then
290         msys_to_win_dir GTK_DLL_PATH
291         msys_to_win_dir GTK_PATH
292     fi
293 fi
294 AC_SUBST(MAKENSIS)
295 AC_SUBST(LIBVIRT_DLL_PATH)
296 AC_SUBST(LIBXDR_DLL_PATH)
297 AC_SUBST(LIBXML2_DLL_PATH)
298 AC_SUBST(GNUTLS_DLL_PATH)
299 AC_SUBST(GTK_DLL_PATH)
300 AC_SUBST(GTK_PATH)
301
302 dnl Summary.
303 echo "------------------------------------------------------------"
304 echo "Thanks for downloading" $PACKAGE_STRING
305 echo " subpackages to build : $subdirs"
306 echo "------------------------------------------------------------"
307
308 dnl Produce output files.
309 AC_CONFIG_HEADERS([config.h])
310 AC_CONFIG_FILES([META
311         libvirt/libvirt_version.ml
312         Makefile
313         Make.rules
314         libvirt/Makefile
315         examples/Makefile
316         mlvirsh/Makefile
317         virt-ctrl/Makefile
318         virt-top/Makefile
319         virt-df/Makefile
320         ])
321 if test "x$MAKENSIS" != "x"; then
322         AC_CONFIG_FILES([wininstaller.nsis])
323 fi
324 AC_OUTPUT