1AC_INIT([Pan],[0.145],[https://bugzilla.gnome.org/enter_bug.cgi?product=Pan],[pan],[http://pan.rebelbase.com/])
2AC_DEFINE(VERSION_MAJOR,0,[Major part of version number])
3AC_DEFINE(VERSION_MINOR,145,[Minor part of version number])
4AC_DEFINE(VERSION_REVISION,0,[Revision part of version number])
5AC_DEFINE(VERSION_TITLE,["Duplicitous mercenary valetism"],[Release Name])
6AC_PREREQ([2.64])
7
8dnl Get git info for pan-git.version
9GIT_HASH='$Format:%h$'
10if test '0' \< $GIT_HASH ; then
11  GIT_REMOTE=`echo '$Format:%d$' | awk -F , '{print gensub("[[\(\)]]","","g",$NF)}' 2> /dev/null`
12else
13  dnl git-dir is used for building outside the src tree
14  GIT_HASH=`git --git-dir=$srcdir/.git log -1 --pretty=format:%h 2> /dev/null`
15  if test ! -z $GIT_HASH; then
16    GIT_REMOTE=`git config --get remote.origin.url 2> /dev/null`
17  fi
18fi
19dnl Do not include protocol & user name in GIT_REMOTE
20case $GIT_REMOTE in
21  *://* )
22  GIT_REMOTE=`echo $GIT_REMOTE | cut -d '/' -f3- 2> /dev/null`
23  case $GIT_REMOTE in
24    *@* )
25    GIT_REMOTE=`echo $GIT_REMOTE | cut -d '@' -f2- | sed 's/\/git\//\//g' 2> /dev/null` ;;
26  esac
27  ;;
28esac
29if test ! -z $GIT_HASH; then
30  if test -z $GIT_REMOTE; then
31    GIT_REV="$GIT_HASH"
32  else
33    GIT_REV="$GIT_HASH $GIT_REMOTE"
34  fi
35    echo $GIT_REV > pan-git.version
36  elif test -f pan-git.version ; then
37    GIT_REV=`cat pan-git.version`
38  else
39    GIT_REV="Unknown"
40fi
41
42AC_DEFINE_UNQUOTED([GIT_REV],["$GIT_REV"],[Git hash and remote])
43
44AC_CONFIG_HEADERS([config.h])
45AC_CONFIG_SRCDIR(pan/general/quark.cc)
46
47AM_INIT_AUTOMAKE([1.11.1 check-news tar-ustar dist-bzip2 foreign])
48AM_MAINTAINER_MODE([enable])
49
50m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
51
52dnl glib, gmime, and gtk are mandatory prerequisites.
53GLIB_REQUIRED=2.17.6
54GLIB_REQUIRED_FOR_DBUS=2.26.0
55GMIME26_REQUIRED=2.6.20
56GMIME30_REQUIRED=3.0.0
57GTK_REQUIRED=2.16.0
58GTK3_REQUIRED=3.0.0
59GTKSPELL_REQUIRED=2.0.7
60GTKSPELL3_REQUIRED=2.0.16
61ENCHANT_REQUIRED=1.6.0
62GNUTLS_REQUIRED=3.0.0
63LIBNOTIFY_REQUIRED=0.4.1
64LIBGKR_REQUIRED=3.2.0
65LIBSECRET_REQUIRED=0.16
66GCR_REQUIRED=3.20
67WEBKIT_REQUIRED=1.8.1
68AC_SUBST(GLIB_REQUIRED)
69AC_SUBST(GLIB_REQUIRED_FOR_DBUS)
70AC_SUBST(GMIME_REQUIRED)
71AC_SUBST(GTK_REQUIRED)
72AC_SUBST(GTKSPELL_REQUIRED)
73AC_SUBST(GNUTLS_REQUIRED)
74AC_SUBST(LIBNOTIFY_REQUIRED)
75AC_SUBST(LIBGKR_REQUIRED)
76AC_SUBST(LIBSECRET_REQUIRED)
77AC_SUBST(GCR_REQUIRED)
78AC_SUBST(WEBKIT_REQUIRED)
79
80AC_PROG_CXX
81AC_HEADER_STDC
82AC_HEADER_TIME
83AC_CHECK_FUNCS([localtime_r close])
84AC_CXX_HEADER_TR1_UNORDERED_SET
85AC_CXX_HAVE_EXT_HASH_SET
86AC_PROG_AWK
87AC_PROG_INSTALL
88AC_PROG_MAKE_SET
89AC_PROG_RANLIB
90
91dnl for libuu
92AC_CHECK_HEADERS([errno.h fcntl.h])
93
94dnl I18n support
95GETTEXT_PACKAGE=pan
96AC_SUBST(GETTEXT_PACKAGE)
97AM_GNU_GETTEXT_VERSION([0.19.7])
98AM_GNU_GETTEXT([external])
99AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Gettext Package])
100panlocaledir=[${datadir}/locale]
101
102dnl libz for xzver
103PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],AC_DEFINE(HAVE_ZLIB,[1],[Zlib for xzver support]),[])
104AC_SUBST(ZLIB_CFLAGS)
105AC_SUBST(ZLIB_LIBS)
106
107dnl D-Bus support
108AC_ARG_WITH([dbus],
109  AS_HELP_STRING([--with-dbus],[enable D-Bus support (normally: no)]), [want_dbus=$withval], [want_dbus=no])
110if test "x$want_dbus" = "xyes" ; then
111  AM_PATH_GLIB_2_0($GLIB_REQUIRED_FOR_DBUS,AC_DEFINE(HAVE_DBUS,[1],[D-Bus support for multiple Pan instances],exit 1,gobject gmodule gthread))
112else
113  AM_PATH_GLIB_2_0($GLIB_REQUIRED,,exit 1,gobject gmodule gthread)
114fi
115
116dnl Check for GMime
117AC_ARG_WITH([gmime30],
118  AS_HELP_STRING([--with-gmime30],[enable GMime 3.0 support (experimental, normally: no)]), [want_gmime30=$withval], [want_gmime30=no])
119if test "x$want_gmime30" = "xyes" ; then
120  PKG_CHECK_MODULES([GMIME], [gmime-3.0 >= $GMIME30_REQUIRED],
121  [
122  AC_DEFINE(HAVE_GMIME_30,[1],[GMime 3.0 available])
123  ])
124else
125  PKG_CHECK_MODULES([GMIME], [gmime-2.6 >= $GMIME26_REQUIRED])
126fi
127
128dnl Check for GMime cryptography support
129AC_ARG_WITH([gmime-crypto],
130  AS_HELP_STRING([--with-gmime-crypto],[enable GMime cryptography support (normally: yes)]),
131  [want_gmime_crypto=$withval], [want_gmime_crypto=yes])
132
133if test "x$want_gmime_crypto" = "xyes" ; then
134  AC_DEFINE(HAVE_GMIME_CRYPTO,[1],[cryptography (PGP) support with GMime])
135fi
136
137dnl GtkSpell support
138gtkspell_msg=no
139AC_ARG_WITH([gtkspell],
140  AS_HELP_STRING([--with-gtkspell],[enable GtkSpell support (normally: yes)]), [want_gtkspell=$withval], [want_gtkspell=yes])
141
142dnl GTK+ 3, GtkSpell 3, and Enchant support
143gtk_msg=no
144AC_ARG_WITH([gtk3],
145  AS_HELP_STRING([--with-gtk3],[enable GTK+ 3 support (normally: no)]), [want_gtk3=$withval], [want_gtk3=no])
146if test "x$want_gtk3" = "xyes" ; then
147  PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK3_REQUIRED],
148                    [gtk_msg="yes >= $GTK3_REQUIRED"
149                    AC_DEFINE(HAVE_GTK,[1],[GTK+ 3 support])]
150                    )
151  if test "x$want_gtkspell" = "xyes" ; then
152    PKG_CHECK_MODULES([GTKSPELL], [gtkspell3-3.0 >= $GTKSPELL3_REQUIRED enchant >= $ENCHANT_REQUIRED],
153                      [
154                      gtkspell_msg=yes
155                      AC_DEFINE(HAVE_GTKSPELL,[1],[GtkSpell support for spellchecking])
156                      AC_DEFINE(GTKSPELL_VERSION,[3],[GtkSpell API version])
157                      ],
158                      [
159                      gtkspell_msg=no
160                      AC_MSG_RESULT(no)
161                      ])
162  fi
163else
164   if test "x$want_gtkspell" = "xyes" ; then
165   PKG_CHECK_MODULES([GTKSPELL], [gtkspell-2.0 >= $GTKSPELL_REQUIRED enchant >= $ENCHANT_REQUIRED],
166                      [
167                      gtkspell_msg=yes
168                      AC_DEFINE(HAVE_GTKSPELL,[1],[GtkSpell support for spellchecking])
169                      AC_DEFINE(GTKSPELL_VERSION,[2],[GtkSpell API version])
170                      ],
171                      [
172                      gtkspell_msg=no
173                      AC_MSG_RESULT(no)
174                      ])
175   fi
176   AM_PATH_GTK_2_0($GTK_REQUIRED,,exit 1,gthread)
177fi
178
179AC_SUBST(ENCHANT_CFLAGS)
180AC_SUBST(ENCHANT_LIBS)
181
182dnl WebKitGTK+ support
183AC_ARG_WITH([webkit],
184  AS_HELP_STRING([--with-webkit],[enable WebKitGTK+ support (experimental, normally: no)]), [want_webkit=$withval], [want_webkit=no])
185if test "x$want_gtk3" = "xyes" ; then
186  if test "x$want_webkit" = "xyes" ; then
187    PKG_CHECK_MODULES([WEBKITGTK],[webkitgtk-3.0 >= $WEBKIT_REQUIRED],
188    [
189    AC_DEFINE(HAVE_WEBKIT,[1],[WebKit support (3.0) for embedded HTML])
190    ],
191    [
192    AC_MSG_RESULT(no)
193    ])
194  fi
195else
196  if test "x$want_webkit" = "xyes" ; then
197    PKG_CHECK_MODULES([WEBKITGTK], [webkitgtk-1.0 >= $WEBKIT_REQUIRED],
198    [
199    AC_DEFINE(HAVE_WEBKIT,[1],[WebKit support (1.0) for embedded HTML])
200    ],
201    [
202    AC_MSG_RESULT(no)
203    ])
204  fi
205fi
206
207dnl GnuTLS support
208gnutls_msg=no
209AC_ARG_WITH([gnutls],
210  AS_HELP_STRING([--with-gnutls],[enable GnuTLS support (normally: no)]), [want_gnutls=$withval], [want_gnutls=no])
211if test "x$want_gnutls" = "xyes" ; then
212  PKG_CHECK_MODULES([GNUTLS],[gnutls >= $GNUTLS_REQUIRED],
213  [
214  GNUTLS_VER=`pkg-config --modversion gnutls`
215  gnutls_msg="yes ($GNUTLS_VER)"
216  AC_DEFINE(HAVE_GNUTLS,[1],[GnuTLS support])],
217  [gnutls_msg=no
218  AC_MSG_RESULT(no)])
219  AC_SUBST([GNUTLS_CFLAGS])
220  AC_SUBST([GNUTLS_LIBS])
221fi
222
223dnl Check for libnotify if user-enabled for popup notifications
224AC_ARG_ENABLE([libnotify],
225  AS_HELP_STRING([--enable-libnotify],[enable libnotify support (normally: no)]),[enable_libnotify=$enableval],[enable_libnotify=no])
226if test "x$enable_libnotify" = "xyes" ; then
227  PKG_CHECK_MODULES([LIBNOTIFY],[libnotify >= $LIBNOTIFY_REQUIRED],[HAVE_LIBNOTIFY="yes"],[HAVE_LIBNOTIFY="no"])
228  AC_SUBST([LIBNOTIFY_CFLAGS])
229  AC_SUBST([LIBNOTIFY_LIBS])
230  if test "x$HAVE_LIBNOTIFY" = "xyes"; then
231    AC_DEFINE([HAVE_LIBNOTIFY],[1],[libnotify support for popup notifications])
232  fi
233fi
234
235dnl Check for libsecret and gcr (GTK+ 3 only) or GNOME Keyring if user-enabled for password storage
236AC_ARG_ENABLE([gkr],
237  AS_HELP_STRING([--enable-gkr],[enable GNOME Keyring or libsecret support (normally: no)]),[enable_gkr=$enableval],[enable_gkr=no])
238if test "x$enable_gkr" = "xyes" ; then
239  if test "x$want_gtk3" = "xyes" ; then
240    PKG_CHECK_MODULES([LIBGNOME_KEYRING_1],[libsecret-1 >= $LIBSECRET_REQUIRED gcr-3 >= $GCR_REQUIRED],
241    [HAVE_GKR="yes"],[HAVE_GKR="no"])
242  else
243    PKG_CHECK_MODULES([LIBGNOME_KEYRING_1],[gnome-keyring-1 >= $LIBGKR_REQUIRED],[HAVE_GKR="yes"],[HAVE_GKR="no"])
244  fi
245  AC_SUBST([LIBGNOME_KEYRING_1_CFLAGS])
246  AC_SUBST([LIBGNOME_KEYRING_1_LIBS])
247  if test "x$HAVE_GKR" = "xyes"; then
248    AC_DEFINE([HAVE_GKR],[1],[GNOME Keyring or libsecret support for password storage])
249  fi
250fi
251
252dnl User manual infrastructure
253AC_ARG_WITH([yelp-tools],
254  AS_HELP_STRING([--with-yelp-tools],[enable yelp-tools support for documentation (normally: yes)]),
255  [want_yelp_tools=$withval],[want_yelp_tools=yes])
256AC_ARG_ENABLE([manual],
257  AS_HELP_STRING([--enable-manual],[build in user manual (normally: no)]),
258  [enable_manual=$enableval], [enable_manual=no])
259if test "x$want_yelp_tools" = "xyes" ; then
260  YELP_HELP_INIT
261  if test "x$enable_manual" = "xyes" ; then
262    AC_DEFINE(HAVE_MANUAL,[1], [user manual for Pan])
263    AM_CONDITIONAL(ENABLE_MANUAL, true)
264  else
265    AM_CONDITIONAL(ENABLE_MANUAL, false)
266  fi
267else
268  AM_CONDITIONAL(ENABLE_MANUAL, false)
269fi
270
271dnl Check to see if strftime supports the use of %l and %k
272AC_MSG_CHECKING(for %l and %k support in strftime)
273AC_RUN_IFELSE([AC_LANG_SOURCE([[
274#include <string.h>
275#include <stdlib.h>
276#include <time.h>
277int main(int argc, char **argv) {
278  char buf[10];
279  time_t rawtime = time(0);
280  struct tm *timeinfo = localtime (&rawtime);
281  strftime(buf, 10, "%l %k", timeinfo);
282  exit (strstr(buf, "l") || strstr(buf, "k") || !strcmp(buf," ") || !strlen(buf));
283}]])],[
284AC_DEFINE(HAVE_LKSTRFTIME, 1, [strftime supports use of l and k])
285ac_cv_lkstrftime=yes
286],[ac_cv_lkstrftime=no],[ac_cv_lkstrftime=no])
287AC_MSG_RESULT($ac_cv_lkstrftime)
288
289AC_CANONICAL_HOST
290
291AC_DEFINE_UNQUOTED([PLATFORM_INFO],["$host"],[uname cpu-vendor-platformbuild])
292
293dnl Windows-specific stuff
294win32="no"
295case $host_os in
296
297	*darwin*|*rhapsody*)
298	AC_DEFINE(G_OS_DARWIN,[1],[Darwin])
299	;;
300
301	*cygwin|*mingw32*)
302	CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32"
303	CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN"
304	LIBS="$LIBS -lshell32 -lws2_32 -lpthread"
305	panlocaledir="locale"
306
307	if test -z "$host_alias"; then
308		hostaliaswindres=
309	else
310		hostaliaswindres="$host_alias-windres";
311	fi
312	AC_PATH_PROGS([WINDRES], [windres $hostaliaswindres $host_os-windres])
313	if test "x$WINDRES" = "x"; then
314		AC_MSG_ERROR([windres could not be found within your path.])
315	fi
316	AC_SUBST(WINDRES)
317	win32="yes"
318	;;
319esac
320AM_CONDITIONAL([HAVE_WIN32],[test "$win32" = "yes"])
321
322dnl Build the output files
323AC_SUBST(panlocaledir)
324AC_CONFIG_FILES([Makefile
325                 README.windows
326                 uulib/Makefile
327                 pan/Makefile
328                 pan/general/Makefile
329                 pan/usenet-utils/Makefile
330                 pan/data/Makefile
331                 pan/tasks/Makefile
332                 pan/icons/Makefile
333                 pan/data-impl/Makefile
334                 pan/gui/Makefile
335                 po/Makefile.in
336                 help/Makefile])
337
338AC_OUTPUT
339
340echo "
341
342Configuration:
343
344        Prefix:                 ${prefix}
345        Source code location:   ${srcdir}
346        Compiler:               ${CXX}
347        With D-Bus:             ${want_dbus}
348        With GMime 3.0:         ${want_gmime30}
349        With GMime crypto:      ${want_gmime_crypto}
350        With GtkSpell:          ${gtkspell_msg}
351        With GTK+ 3:            ${gtk_msg}
352        With WebKitGTK+:        ${want_webkit}
353        With GnuTLS:            ${gnutls_msg}
354        With libnotify:         ${enable_libnotify}
355        With password storage:  ${enable_gkr}
356        With yelp-tools:        ${want_yelp_tools}
357        With user manual:       ${enable_manual}
358"
359