Brazilian Portuguese translation by Herli Joaquim de Menezes and revised by Igor...
[virt-ctrl.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(virt-ctrl,1.0.0)
21
22 AC_PROG_INSTALL
23
24 dnl Check for optional GNOME icons (from gnome-icon-theme package).
25 AC_ARG_WITH(icons,
26         AC_HELP_STRING([--with-icons=PATH],
27                 [Set path to installed icons @<:@default=/usr/share/icons@:>@]),
28         [],[with_icons=/usr/share/icons])
29 icons=""
30 if test "x$with_icons" != "xno"; then
31     for size in 16 24 32 48; do
32         for f in devices/computer.png; do
33             fname="${with_icons}/gnome/${size}x${size}/${f}"
34             AC_MSG_CHECKING([checking for icon $fname])
35             if test -f "$fname"; then
36                 AC_MSG_RESULT([yes])
37                 icons="$size $f $fname $icons"
38             else
39                 AC_MSG_RESULT([no])
40             fi
41         done
42     done
43 fi
44 AC_SUBST(with_icons)
45 AC_SUBST(icons)
46
47 dnl Check for basic OCaml environment & findlib.
48 AC_PROG_OCAML
49 AC_PROG_FINDLIB
50
51 if test "x$OCAMLFIND" = "x"; then
52     AC_MSG_ERROR([OCaml findlib is required])
53 fi
54
55 dnl Use ocamlfind to find the required packages ...
56
57 dnl Check for required OCaml packages.
58 AC_CHECK_OCAML_PKG(unix)
59 if test "x$pkg_unix" != "xyes"; then
60     AC_MSG_ERROR([Cannot find required OCaml package 'unix'])
61 fi
62
63 AC_CHECK_OCAML_PKG(libvirt)
64 if test "x$pkg_libvirt" != "xyes"; then
65     AC_MSG_ERROR([Cannot find required OCaml package 'libvirt'])
66 fi
67
68 AC_CHECK_OCAML_PKG(lablgtk2)
69 if test "x$pkg_lablgtk2" != "xyes"; then
70     AC_MSG_ERROR([Cannot find required OCaml package 'lablgtk2'])
71 fi
72
73 AC_CHECK_OCAML_PKG(xml-light)
74 if test "x$pkg_xml_light" != "xyes"; then
75     AC_MSG_ERROR([Cannot find required OCaml package 'xml-light'])
76 fi
77
78 AC_CHECK_OCAML_PKG(extlib)
79 if test "x$pkg_extlib" != "xyes"; then
80     AC_MSG_ERROR([Cannot find required OCaml package 'extlib'])
81 fi
82
83 dnl Check for optional OCaml packages.
84 AC_CHECK_OCAML_PKG(gettext)
85 AC_CHECK_OCAML_PKG(dbus)
86
87 AC_SUBST(pkg_unix)
88 AC_SUBST(pkg_lablgtk2)
89 AC_SUBST(pkg_gettext)
90 AC_SUBST(pkg_dbus)
91
92 dnl Check for optional gdk-pixbuf-mlsource (for icons).
93 AC_CHECK_PROG(HAVE_GDK_PIXBUF_MLSOURCE,gdk-pixbuf-mlsource,gdk-pixbuf-mlsource)
94
95 dnl Check for recommended ocaml-gettext tool.
96 AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
97
98 dnl Check for optional NSIS (for building a Windows installer).
99 dnl XXX This probably needs some attention XXX
100 AC_ARG_WITH([nsis],
101         [AS_HELP_STRING([--with-nsis],
102             [use NSIS to build a Windows installer])],
103         [],
104         [with_nsis=no])
105
106 MAKENSIS=
107 LIBVIRT_DLL_PATH=
108 LIBXDR_DLL_PATH=
109 LIBXML2_DLL_PATH=
110 GNUTLS_DLL_PATH=
111 GTK_PATH=
112 GTK_DLL_PATH=
113
114 [
115 msys_to_win_dir () {
116     eval pushd "\$$1" > /dev/null
117     eval $1=`pwd -W`
118     popd > /dev/null
119 }
120 ]
121
122 if test "x$with_nsis" != "xno"; then
123     AC_PATH_PROG(MAKENSIS,makensis,[],[$with_nsis:$PATH])
124     if test "x$MAKENSIS" = "x"; then
125         AC_MSG_FAILURE([--with-nsis was given, but could not find MAKENSIS.EXE])
126     fi
127
128     # MAKENSIS is set so we will build a rule for making a Windows
129     # installer.  To support this, generate wininstaller.nsis.
130     saved_IFS=$IFS
131     IFS=$PATH_SEPARATOR
132     for d in $PATH; do
133         IFS=$saved_IFS
134         echo Checking $d for DLLs ... >&5
135         if test -f "$d/libvirt-0.dll"; then
136             LIBVIRT_DLL_PATH="$d"
137         fi
138         if test -f "$d/libxdr.dll"; then
139             LIBXDR_DLL_PATH="$d"
140         fi
141         if test -f "$d/libxml2-2.dll"; then
142             LIBXML2_DLL_PATH="$d"
143         fi
144         if test -f "$d/libgpg-error-0.dll"; then
145             GNUTLS_DLL_PATH="$d"
146         fi
147         if test -f "$d/libgtk-win32-2.0-0.dll"; then
148             GTK_DLL_PATH="$d"
149             GTK_PATH="$d/.."
150         fi
151     done
152     IFS=$saved_IFS
153
154     if test "x$LIBVIRT_DLL_PATH" = "x"; then
155         AC_MSG_FAILURE([cannot find libvirt-0.dll in PATH])
156     fi
157     if test "x$LIBXDR_DLL_PATH" = "x"; then
158         AC_MSG_FAILURE([cannot find libxdr.dll in PATH])
159     fi
160     if test "x$LIBXML2_DLL_PATH" = "x"; then
161         AC_MSG_FAILURE([cannot find libxml2-2.dll in PATH])
162     fi
163     if test "x$GNUTLS_DLL_PATH" = "x"; then
164         AC_MSG_FAILURE([cannot find GnuTLS DLLs in PATH])
165     fi
166     if test "x$GTK_DLL_PATH" = "x"; then
167         AC_MSG_WARN([cannot find GTK DLLs in PATH])
168     fi
169
170     # Change the paths to Windows paths.
171     msys_to_win_dir LIBVIRT_DLL_PATH
172     msys_to_win_dir LIBXDR_DLL_PATH
173     msys_to_win_dir LIBXML2_DLL_PATH
174     msys_to_win_dir GNUTLS_DLL_PATH
175     if test "x$GTK_DLL_PATH" != "x"; then
176         msys_to_win_dir GTK_DLL_PATH
177         msys_to_win_dir GTK_PATH
178     fi
179 fi
180 AC_SUBST(MAKENSIS)
181 AC_SUBST(LIBVIRT_DLL_PATH)
182 AC_SUBST(LIBXDR_DLL_PATH)
183 AC_SUBST(LIBXML2_DLL_PATH)
184 AC_SUBST(GNUTLS_DLL_PATH)
185 AC_SUBST(GTK_DLL_PATH)
186 AC_SUBST(GTK_PATH)
187
188 dnl Write gettext modules for the programs.
189 dnl http://www.le-gall.net/sylvain+violaine/documentation/ocaml-gettext/html/reference-manual/ch03s04.html
190 for d in virt-ctrl; do
191     f=`echo $d | tr - _`_gettext.ml
192     AC_MSG_NOTICE([creating $d/$f])
193     rm -f $d/$f
194     echo "(* This file is generated automatically by ./configure. *)" > $d/$f
195     if test "x$pkg_gettext" != "xno"; then
196         # Gettext module is available, so use it.
197         cat <<EOT >>$d/$f
198 module Gettext = Gettext.Program (
199   struct
200     let textdomain = "$d"
201     let codeset = None
202     let dir = None
203     let dependencies = [[]]
204   end
205 ) (GettextStub.Native)
206 EOT
207     else
208         # No gettext module is available, so fake the translation functions.
209         cat <<EOT >>$d/$f
210 module Gettext = struct
211   external s_ : string -> string = "%identity"
212   external f_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format
213     = "%identity"
214   let sn_ : string -> string -> int -> string
215     = fun s p n -> if n = 1 then s else p
216   let fn_ : ('a -> 'b, 'c, 'd) format -> ('a -> 'b, 'c, 'd) format -> int
217       -> ('a -> 'b, 'c, 'd) format
218     = fun s p n -> if n = 1 then s else p
219 end
220 EOT
221     fi
222 done
223
224 dnl Summary.
225 echo "------------------------------------------------------------"
226 echo "Thanks for downloading" $PACKAGE_STRING
227 echo "------------------------------------------------------------"
228
229 dnl Produce output files.
230 AC_CONFIG_HEADERS([config.h])
231 AC_CONFIG_FILES([Makefile
232         Make.rules
233         po/Makefile
234         virt-ctrl/Makefile
235         ])
236 if test "x$MAKENSIS" != "x"; then
237         AC_CONFIG_FILES([wininstaller.nsis])
238 fi
239 AC_OUTPUT