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