Support Log4Vala 0.2
[moonshot-ui.git] / configure.ac
1 AC_PREREQ([2.63])
2 AC_INIT([Moonshot-ui],
3         [1.0.3],
4         [moonshot-community@jiscmail.ac.uk],
5         [moonshot-ui],
6         [http://www.project-moonshot.org/])
7
8 # Remove this when we can depend on autoconf >= 2.64
9 AC_SUBST(PACKAGE_URL, [http://www.project-moonshot.org/])
10 AC_DEFINE(PACKAGE_URL,["http://www.project-moonshot.org"],[package URL])
11 AC_CONFIG_HEADERS([config.h])
12 AC_CONFIG_SRCDIR([configure.ac])
13 AC_CONFIG_MACRO_DIR([m4])
14 AC_CONFIG_AUX_DIR([build-aux])
15
16 AM_INIT_AUTOMAKE([1.11 -Wall foreign subdir-objects tar-pax no-dist-gzip dist-xz])
17 AM_SILENT_RULES([yes])
18 AM_MAINTAINER_MODE([enable])
19
20 LT_PREREQ([2.2])
21 LT_INIT([win32-dll])
22 AC_CHECK_FUNCS_ONCE(geteuid getpwuid)
23
24 # Checks for programs.
25 PKG_PROG_PKG_CONFIG([0.23])
26 AC_PROG_CC
27 AM_PROG_CC_C_O
28 AM_PROG_VALAC([0.9])
29
30 # Platform checks
31 AC_CANONICAL_HOST
32
33 case "$host" in
34   *-*-mingw*)
35     win32=yes
36     macos=no
37     linux=no
38     SERVER_IPC_MODULE="msrpc-glib2-1.0"
39     CLIENT_IPC_MODULE="msrpc-mingw-1.0"
40     ;;
41     
42   *darwin*) 
43     win32=no
44     macos=yes
45     linux=no
46
47     # We require dbus-glib for the client library even if we are using GDBus
48     # in the server. The reason we can't always use dbus-glib in the server is
49     # because Vala drops support for it, but as it ships with DBus there is very
50     # little danger of it being dropped by distros any time soon.
51     CLIENT_IPC_MODULE="dbus-glib-1"
52         SERVER_IPC_MODULE="dbus-glib-1"   
53         
54         PKG_CHECK_MODULES([MAC], 
55                         [gtk-mac-integration >= 1.0.1]
56         )
57
58     ;;
59   *)
60     macos=no
61     win32=no
62     linux=yes
63
64     # We require dbus-glib for the client library even if we are using GDBus
65     # in the server. The reason we can't always use dbus-glib in the server is
66     # because Vala drops support for it, but as it ships with DBus there is very
67     # little danger of it being dropped by distros any time soon.
68     CLIENT_IPC_MODULE="dbus-glib-1"
69     PKG_CHECK_MODULES([GDBUS],
70             [gio-2.0 >= 2.26],
71             [SERVER_IPC_MODULE="gio-2.0"],
72             [SERVER_IPC_MODULE="dbus-glib-1"]
73     )
74
75     ;;
76 esac
77
78
79 # For all platforms: Use Gtk+3.0 if available; else revert to Gtk+2.0
80 PKG_CHECK_MODULES([GTK],
81         [gtk+-3.0 >= 3.1],
82         [GTK_VERSION="gtk+-3.0"],
83             [PKG_CHECK_MODULES([GTK],
84                         [gtk+-2.0 >= 2.18],
85                         [GTK_VERSION="gtk+-2.0"]
86             )]                            
87 )
88 AC_SUBST(GTK_VERSION)
89
90
91 # For all platforms: Use Log4Vala 0.2 if available; else revert to 0.1
92 PKG_CHECK_MODULES([LOG4VALA],
93         [log4vala-0.2],
94         [LOG4VALA_VERSION="log4vala-0.2"],
95             [PKG_CHECK_MODULES([LOG4VALA],
96                         [log4vala-0.1],
97                         [LOG4VALA_VERSION="log4vala-0.1"]
98             )]                            
99 )
100 AC_SUBST(LOG4VALA_VERSION)
101
102
103
104 # For all platforms: Use gee-0.8 if available; else revert to gee-1.0
105 # (yes, gee-0.8 is an upgrade from gee-1.0!)
106 PKG_CHECK_MODULES([LIB_GEE],
107         [gee-0.8 >= 0.10.5],
108         [GEE_VERSION="gee-0.8"],
109             [PKG_CHECK_MODULES([LIB_GEE],
110                         [gee-1.0 >= 0.5],
111                         [GEE_VERSION="gee-1.0"]
112             )]                            
113 )
114 AC_SUBST(GEE_VERSION)
115
116 #enable the optional use of Log4Vala (Must have the package installed!)
117 AC_ARG_ENABLE([log4vala],
118 [  --enable-log4vala    Enable use of log4vala for logging],
119 [case "${enableval}" in
120   yes) log4vala=true ;;
121   no)  log4vala=false ;;
122   *) AC_MSG_ERROR([bad value ${enableval} for --enable-log4vala]) ;;
123 esac],[log4vala=false])
124 AM_CONDITIONAL([LOG4VALA], [test x$log4vala = xtrue])
125
126
127 AM_CONDITIONAL([OS_LINUX], [test "$linux" = "yes"])
128 AM_CONDITIONAL([OS_WIN32], [test "$win32" = "yes"])
129 AM_CONDITIONAL([OS_MACOS], [test "$macos" = "yes"])
130
131 AM_CONDITIONAL([IPC_MSRPC], [test "$SERVER_IPC_MODULE" = "msrpc-glib2-1.0"])
132 AM_CONDITIONAL([IPC_DBUS], [test "$SERVER_IPC_MODULE" != "msrpc-glib2-1.0"])
133 AM_CONDITIONAL([IPC_DBUS_GLIB], [test "$SERVER_IPC_MODULE" = "dbus-glib-1"])
134 AM_CONDITIONAL([IPC_GDBUS], [test "$SERVER_IPC_MODULE" = "gio-2.0"])
135
136 vala_version=`$VALAC --version | sed 's/Vala  *//'`
137 AS_VERSION_COMPARE(["$vala_version"], [0.11.1],
138   [gio_vapi_uses_arrays="no"],
139   [gio_vapi_uses_arrays="yes"],
140   [gio_vapi_uses_arrays="yes"])
141 AM_CONDITIONAL([GIO_VAPI_USES_ARRAYS], [test "$gio_vapi_uses_arrays" = "yes"])
142 if test "$SERVER_IPC_MODULE" = "dbus-glib-1"; then
143   AC_MSG_CHECKING([$VALAC is no greater than 0.12.1])
144   AS_VERSION_COMPARE([0.12.2], ["$vala_version"],
145     [vala_supports_dbus_glib="no"],
146     [vala_supports_dbus_glib="no"],
147     [vala_supports_dbus_glib="yes"])
148
149   AC_MSG_RESULT([$vala_supports_dbus_glib])
150   if test "$vala_supports_dbus_glib" = "no"; then
151     AC_MSG_ERROR([
152 *** Vala 0.12.1 or earlier is required for dbus-glib support. Newer versions
153 *** require that you have GLib 2.26 or newer (for GDBus support).])
154   fi
155 fi
156
157 if test "$SERVER_IPC_MODULE" = "msrpc-glib2-1.0"; then
158   # MS RPC utilities
159   AC_PATH_MSRPC_MINGW([0.1.0], :,
160     AC_MSG_ERROR([
161 *** msrpc-mingw 0.1.0 or better is required.]))
162
163   AC_PATH_PROG([MIDL], [midl], no,
164                [/c/Program\ Files/Microsoft\ SDKs/Windows/v7.0/Bin$PATH_SEPARATOR$PATH])
165   if test "$MIDL" = "no"; then
166      AC_MSG_ERROR([
167 *** Could not find the Microsoft interface compiler MIDL.EXE.
168 *** This program is available as part of the MS Windows SDK, in
169 *** the Win32 Development Tools package. If it is not in the PATH
170 *** or its default location you may set the 'MIDL' environment
171 *** variable to point to its location and rerun configure.])
172   fi
173 fi
174
175 if test "$win32" = "yes"; then
176   # Other Windows-specific tools
177
178   # LIB.EXE from MSVC to build an MSVC-compatible import library.
179   AC_PATH_PROG([MSVC_LIB], [lib], no,
180                [/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/VC/bin$PATH_SEPARATOR/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 9.0/VC/bin$PATH_SEPARATOR$PATH])
181
182   if test "$MSVC_LIB" = "no"; then
183      AC_MSG_WARN([
184 *** Could not find the Microsoft 'LIB.EXE' program. This is required
185 *** to build the Visual C import library for libmoonshot. Use the
186 *** MSVC_LIB environment variable to pass its location if this is
187 *** outside the PATH.])
188   fi
189
190
191   # ImageMagick for the 'make icons' target. Note that
192   # c:/windows/system32/convert.exe is nothing to do with ImageMagick.
193   AC_PATH_PROG([IMAGEMAGICK_CONVERT], [convert], no,
194                [/c/Program\ Files/ImageMagick$PATH_SEPARATOR/c/Program\ Files\ \(x86\)/ImageMagick$PATH_SEPARATOR$PATH])
195
196   if test "$IMAGEMAGICK_CONVERT" = "no" || test "$IMAGEMAGICK_CONVERT" = "/c/windows/system32/convert"; then
197      AC_MSG_WARN([
198 *** Could not find ImageMagick convert.exe. This is required for the
199 *** 'make icons' target. Use the IMAGEMAGICK_CONVERT environment
200 *** variable to pass its location if this is outside the PATH.])
201   fi
202
203
204   # Windows Installer XML tools
205   AC_PATH_PROG([WIX_CANDLE], [candle], no,
206                [/c/Program\ Files/Windows\ Installer\ XML\ v3.5/bin$PATH_SEPARATOR/c/Program\ Files\ \(x86\)/Windows\ Installer\ XML\ v3.5/bin$PATH_SEPARATOR$PATH])
207   AC_PATH_PROG([WIX_LIGHT], [light], no,
208                [/c/Program\ Files/Windows\ Installer\ XML\ v3.5/bin$PATH_SEPARATOR/c/Program\ Files\ \(x86\)/Windows\ Installer\ XML\ v3.5/bin$PATH_SEPARATOR$PATH])
209
210   if test "$WIX_CANDLE" = "no" || test "$WIX_LIGHT" = "no"; then
211      AC_MSG_WARN([
212 *** Could not find the Windows Installer XML tools. These are required
213 *** for the 'make installer' target. Use the WIX_CANDLE and WIX_LIGHT
214 *** environment variables to pass their locations if they are outside
215 *** the PATH.])
216   fi
217 fi
218
219 if test "$linux" = "yes"; then
220   AC_PATH_PROG([UPDATE_MIME_DATABASE], [update-mime-database], [no])
221   if test "$UPDATE_MIME_DATABASE" = "no"; then
222     AC_MSG_ERROR([
223 *** Could not find the Freedesktop.org  mime database update tool.
224 *** Web provisioning files could not be automatically installed.])
225   fi
226   AC_PATH_PROG([UPDATE_DESKTOP_DATABASE], [update-desktop-database], [no])
227   if test "$UPDATE_DESKTOP_DATABASE" = "no"; then
228     AC_MSG_ERROR([
229 *** Could not find the Freedesktop.org desktop entry database update
230 *** tool. Web provisioning files could not be automatically installed.])
231   fi
232 fi
233
234 MOONSHOT_APP="$bindir/moonshot"
235 MOONSHOT_WEBP="$bindir/moonshot-webp"
236
237 AC_SUBST(MIDL)
238 AC_SUBST(MSVC_LIB)
239 AC_SUBST(IMAGEMAGICK_CONVERT)
240 AC_SUBST(WIX_CANDLE)
241 AC_SUBST(WIX_LIGHT)
242 AC_SUBST(UPDATE_MIME_DATABASE)
243 AC_SUBST(UPDATE_DESKTOP_DATABASE)
244 AC_SUBST(MOONSHOT_APP)
245 AC_SUBST(MOONSHOT_WEBP)
246
247 # Dependencies
248 PKG_CHECK_MODULES(moonshot,[
249         atk >= 1.20
250         glib-2.0 >= 2.22
251         gobject-2.0 >= 2.22
252         libssl
253         $GTK_VERSION
254         $GEE_VERSION
255         $SERVER_IPC_MODULE
256                 $MAC
257 ])
258
259 PKG_CHECK_MODULES(libmoonshot,[
260         $CLIENT_IPC_MODULE
261 ])
262
263 # i18n stuff
264 AM_GNU_GETTEXT([external])
265 AM_GNU_GETTEXT_VERSION([0.17])
266
267 AC_SUBST([GETTEXT_PACKAGE],[PACKAGE_TARNAME])
268 AC_DEFINE([GETTEXT_PACKAGE],[PACKAGE_TARNAME],[Define to the gettext package name.])
269
270 AC_CONFIG_FILES([
271         Makefile
272         po/Makefile.in
273         moonshot.desktop
274         moonshot-webp.desktop
275         moonshot-ui.spec
276 ])
277
278 AC_OUTPUT