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