2 # Copyright (C) 2007 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.0.2)
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 Check for libvirt >= 0.2.1 (our minimum supported version).
66 dnl See: http://libvirt.org/hvsupport.html
67 AC_CHECK_FUNC(virConnectGetCapabilities,
69 AC_MSG_ERROR([You must have libvirt >= 0.2.1]))
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 \
76 virDomainGetSchedulerParameters \
77 virDomainGetSchedulerType \
78 virDomainInterfaceStats \
80 virDomainSetSchedulerParameters \
81 virNodeGetFreeMemory \
82 virNodeGetCellsFreeMemory \
85 dnl We also use <libvirt/virterror.h>
86 AC_CHECK_HEADER([libvirt/virterror.h],
88 AC_MSG_ERROR([You must install libvirt development package]))
90 dnl Check for optional ncurses.
91 AC_CHECK_LIB(ncurses,initscr)
93 dnl Check for basic OCaml environment & findlib.
94 dnl Note that findlib is not necessary, but things will work better
99 if test "x$OCAMLFIND" != "x"; then
100 dnl Use ocamlfind to find the required packages ...
102 dnl Check for required OCaml packages.
103 AC_CHECK_OCAML_PKG(unix)
104 if test "x$pkg_unix" != "xyes"; then
105 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
108 dnl Check for optional OCaml packages.
109 AC_CHECK_OCAML_PKG(extlib)
110 AC_CHECK_OCAML_PKG(lablgtk2)
111 AC_CHECK_OCAML_PKG(curses)
112 AC_CHECK_OCAML_PKG(gettext)
113 AC_CHECK_OCAML_PKG(xml-light)
114 AC_CHECK_OCAML_PKG(csv)
115 AC_CHECK_OCAML_PKG(calendar)
119 AC_SUBST(pkg_lablgtk2)
121 AC_SUBST(pkg_gettext)
122 AC_SUBST(pkg_xml_light)
124 AC_SUBST(pkg_calendar)
126 dnl Use a basic module test if there is no findlib ...
128 dnl Check for required OCaml modules.
129 AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.])
130 if test "x$pkg_unix" = "xno"; then
131 AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
134 dnl Check for optional OCaml modules.
135 AC_CHECK_OCAML_MODULE(extlib,pkg_extlib,ExtString,[+extlib])
136 AC_CHECK_OCAML_MODULE(lablgtk2,pkg_lablgtk2,GMain,[+lablgtk2])
137 AC_CHECK_OCAML_MODULE(curses,pkg_curses,Curses,[+curses])
138 AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext]) dnl XXX
139 AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light])
140 AC_CHECK_OCAML_MODULE(csv,pkg_csv,Csv,[+csv])
141 AC_CHECK_OCAML_MODULE(calendar,pkg_calendar,Calendar,[+calendar])
144 dnl Which subpackages (== subdirs) will we build?
145 subdirs="libvirt examples mlvirsh"
146 if test "x$pkg_lablgtk2" != "xno"; then
147 subdirs="$subdirs virt-ctrl"
149 if test "x$pkg_extlib" != "xno" -a "x$pkg_curses" != "xno"; then
150 subdirs="$subdirs virt-top"
152 if test "x$pkg_extlib" != "xno" -a "x$pkg_xml_light" != "xno"; then
153 subdirs="$subdirs virt-df"
157 dnl Check for optional perldoc (for building manual pages).
158 AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc)
160 dnl Check for optional NSIS (for building a Windows installer).
162 [AS_HELP_STRING([--with-nsis],
163 [use NSIS to build a Windows installer])],
177 eval pushd "\$$1" > /dev/null
183 if test "x$with_nsis" != "xno"; then
184 AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
185 if test "x$MAKENSIS" = "x"; then
186 AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
189 # MAKENSIS is set so we will build a rule for making a Windows
190 # installer. To support this, generate wininstaller.nsis.
195 echo Checking $d for DLLs ... >&5
196 if test -f "$d/libvirt-0.dll"; then
197 LIBVIRT_DLL_PATH="$d"
199 if test -f "$d/libxdr.dll"; then
202 if test -f "$d/libxml2-2.dll"; then
203 LIBXML2_DLL_PATH="$d"
205 if test -f "$d/libgpg-error-0.dll"; then
208 if test -f "$d/libgtk-win32-2.0-0.dll"; then
215 if test "x$LIBVIRT_DLL_PATH" = "x"; then
216 AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
218 if test "x$LIBXDR_DLL_PATH" = "x"; then
219 AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
221 if test "x$LIBXML2_DLL_PATH" = "x"; then
222 AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
224 if test "x$GNUTLS_DLL_PATH" = "x"; then
225 AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
227 if test "x$GTK_DLL_PATH" = "x"; then
228 AC_MSG_WARN([cannot find GTK DLLs in PATH])
231 # Change the paths to Windows paths.
232 msys_to_win_dir LIBVIRT_DLL_PATH
233 msys_to_win_dir LIBXDR_DLL_PATH
234 msys_to_win_dir LIBXML2_DLL_PATH
235 msys_to_win_dir GNUTLS_DLL_PATH
236 if test "x$GTK_DLL_PATH" != "x"; then
237 msys_to_win_dir GTK_DLL_PATH
238 msys_to_win_dir GTK_PATH
242 AC_SUBST(LIBVIRT_DLL_PATH)
243 AC_SUBST(LIBXDR_DLL_PATH)
244 AC_SUBST(LIBXML2_DLL_PATH)
245 AC_SUBST(GNUTLS_DLL_PATH)
246 AC_SUBST(GTK_DLL_PATH)
250 echo "------------------------------------------------------------"
251 echo "Thanks for downloading" $PACKAGE_STRING
252 echo " subpackages to build : $subdirs"
253 echo "------------------------------------------------------------"
255 dnl Produce output files.
256 AC_CONFIG_HEADERS([config.h])
257 AC_CONFIG_FILES([META
258 libvirt/libvirt_version.ml
268 if test "x$MAKENSIS" != "x"; then
269 AC_CONFIG_FILES([wininstaller.nsis])