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