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