Fix typo in ocaml_libvirt_storage_vol_get_info
[ocaml-libvirt.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.6.1.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 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                 virDomainBlockPeek \
127                 virDomainMemoryPeek \
128                 virDomainGetCPUStats \
129 ])
130
131 dnl Check for optional types added since 0.2.1.
132 AC_CHECK_TYPES([virStoragePoolPtr, virStorageVolPtr],,,
133                [#include <libvirt/libvirt.h>])
134
135 dnl Check for basic OCaml environment & findlib.
136 AC_PROG_OCAML
137 AC_PROG_FINDLIB
138
139 if test "x$OCAMLFIND" = "x"; then
140     AC_MSG_ERROR([OCaml findlib is required])
141 fi
142
143 dnl Use ocamlfind to find the required packages ...
144
145 dnl Check for required OCaml packages.
146 AC_CHECK_OCAML_PKG(unix)
147 if test "x$pkg_unix" != "xyes"; then
148     AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
149 fi
150
151 dnl Check for optional NSIS (for building a Windows installer).
152 dnl XXX This probably doesn't work at the moment XXX
153 AC_ARG_WITH([nsis],
154         [AS_HELP_STRING([--with-nsis],
155             [use NSIS to build a Windows installer])],
156         [],
157         [with_nsis=no])
158
159 MAKENSIS=
160 LIBVIRT_DLL_PATH=
161 LIBXDR_DLL_PATH=
162 LIBXML2_DLL_PATH=
163 GNUTLS_DLL_PATH=
164 GTK_PATH=
165 GTK_DLL_PATH=
166
167 [
168 msys_to_win_dir () {
169     eval pushd "\$$1" > /dev/null
170     eval $1=`pwd -W`
171     popd > /dev/null
172 }
173 ]
174
175 if test "x$with_nsis" != "xno"; then
176     AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
177     if test "x$MAKENSIS" = "x"; then
178         AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
179     fi
180
181     # MAKENSIS is set so we will build a rule for making a Windows
182     # installer.  To support this, generate wininstaller.nsis.
183     saved_IFS=$IFS
184     IFS=$PATH_SEPARATOR
185     for d in $PATH; do
186         IFS=$saved_IFS
187         echo Checking $d for DLLs ... >&5
188         if test -f "$d/libvirt-0.dll"; then
189             LIBVIRT_DLL_PATH="$d"
190         fi
191         if test -f "$d/libxdr.dll"; then
192             LIBXDR_DLL_PATH="$d"
193         fi
194         if test -f "$d/libxml2-2.dll"; then
195             LIBXML2_DLL_PATH="$d"
196         fi
197         if test -f "$d/libgpg-error-0.dll"; then
198             GNUTLS_DLL_PATH="$d"
199         fi
200         if test -f "$d/libgtk-win32-2.0-0.dll"; then
201             GTK_DLL_PATH="$d"
202             GTK_PATH="$d/.."
203         fi
204     done
205     IFS=$saved_IFS
206
207     if test "x$LIBVIRT_DLL_PATH" = "x"; then
208         AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
209     fi
210     if test "x$LIBXDR_DLL_PATH" = "x"; then
211         AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
212     fi
213     if test "x$LIBXML2_DLL_PATH" = "x"; then
214         AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
215     fi
216     if test "x$GNUTLS_DLL_PATH" = "x"; then
217         AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
218     fi
219     if test "x$GTK_DLL_PATH" = "x"; then
220         AC_MSG_WARN([cannot find GTK DLLs in PATH])
221     fi
222
223     # Change the paths to Windows paths.
224     msys_to_win_dir LIBVIRT_DLL_PATH
225     msys_to_win_dir LIBXDR_DLL_PATH
226     msys_to_win_dir LIBXML2_DLL_PATH
227     msys_to_win_dir GNUTLS_DLL_PATH
228     if test "x$GTK_DLL_PATH" != "x"; then
229         msys_to_win_dir GTK_DLL_PATH
230         msys_to_win_dir GTK_PATH
231     fi
232 fi
233 AC_SUBST(MAKENSIS)
234 AC_SUBST(LIBVIRT_DLL_PATH)
235 AC_SUBST(LIBXDR_DLL_PATH)
236 AC_SUBST(LIBXML2_DLL_PATH)
237 AC_SUBST(GNUTLS_DLL_PATH)
238 AC_SUBST(GTK_DLL_PATH)
239 AC_SUBST(GTK_PATH)
240
241 dnl Summary.
242 echo "------------------------------------------------------------"
243 echo "Thanks for downloading" $PACKAGE_STRING
244 echo "------------------------------------------------------------"
245
246 dnl Produce output files.
247 AC_CONFIG_HEADERS([config.h])
248 AC_CONFIG_FILES([META
249         libvirt/libvirt_version.ml
250         Makefile
251         Make.rules
252         libvirt/Makefile
253         examples/Makefile
254         ])
255 if test "x$MAKENSIS" != "x"; then
256         AC_CONFIG_FILES([wininstaller.nsis])
257 fi
258 AC_OUTPUT