* major code cleanup (part 1)
[claws.git] / configure.in
1
2 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(src/main.c)
4 PACKAGE=sylpheed
5
6 dnl version number
7 MAJOR_VERSION=0
8 MINOR_VERSION=7
9 MICRO_VERSION=8
10 INTERFACE_AGE=0
11 BINARY_AGE=0
12 EXTRA_VERSION=claws42
13 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
14
15 dnl set $target
16 AC_CANONICAL_SYSTEM
17
18 dnl
19 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
20 dnl AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
21 dnl AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
22 AC_SUBST(PACKAGE)
23 AC_SUBST(VERSION)
24
25 dnl GNOME installed?
26 AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
27 if test "$GNOME_CONFIG" != no; then
28         gnomedir="`gnome-config --prefix`"
29         AC_SUBST(gnomedir)
30 fi
31 AM_CONDITIONAL(SYLPHEED_GNOME, test -d "$gnomedir")
32
33 dnl Claws version
34 AC_DEFINE(CLAWS, 1)
35
36 dnl libtool versioning
37 LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
38 LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
39 LT_REVISION=$INTERFACE_AGE
40 LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
41 AC_SUBST(LT_RELEASE)
42 AC_SUBST(LT_CURRENT)
43 AC_SUBST(LT_REVISION)
44 AC_SUBST(LT_AGE)
45
46 dnl Specify a header configuration file
47 AM_CONFIG_HEADER(config.h)
48
49 AM_MAINTAINER_MODE
50
51 dnl Checks for programs.
52 AC_ARG_PROGRAM
53 AC_PROG_CC
54 AC_ISC_POSIX
55 AM_PROG_CC_STDC
56 AC_PROG_INSTALL
57 AC_PROG_LN_S
58 AC_PROG_MAKE_SET
59 AC_PROG_CPP
60 dnl AC_PROG_RANLIB
61 AM_PROG_LEX
62 AC_PROG_YACC
63 AM_PROG_LIBTOOL
64
65 SYLPHEED_ACLOCAL_INCLUDE(ac)
66
67 case "$target" in
68 *-darwin*)
69         CFLAGS="$CFLAGS -traditional-cpp -fno-common"
70         ;;
71 esac
72
73 dnl add additional parameters
74 AC_ARG_WITH(compiler-flags,
75     [  --with-compiler-flags=FLAGS  add parameters to the compiler command],
76     CFLAGS="$CFLAGS $withval")
77
78 dnl for gettext
79 ALL_LINGUAS="cs de el en_GB es fr hr it ja ko nl pl pt_BR ru sv"
80 AM_GNU_GETTEXT
81 dnl AC_CHECK_FUNC(gettext, AC_CHECK_LIB(intl, gettext))
82 localedir='${prefix}/${DATADIRNAME}/locale'
83 AC_SUBST(localedir)
84
85 manualdir='${prefix}/${DATADIRNAME}/${PACKAGE}/manual'
86 AC_SUBST(manualdir)
87 faqdir='${prefix}/${DATADIRNAME}/${PACKAGE}/faq'
88 AC_SUBST(faqdir)
89 mandir='${prefix}/man/man1'
90 AC_SUBST(mandir)
91
92 dnl Set PACKAGE_DATA_DIR in config.h.
93 if test "x${datadir}" = 'x${prefix}/share'; then
94   if test "x${prefix}" = "xNONE"; then
95     AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}")
96   else
97     AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}")
98   fi
99 else
100   AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}")
101 fi
102
103 dnl Checks for libraries.
104 AM_PATH_GLIB(1.2.6,,
105         AC_MSG_ERROR(Test for GLIB failed. See the file 'INSTALL' for help.),
106         gthread)
107 AM_PATH_GTK(1.2.6,,
108         AC_MSG_ERROR(Test for GTK failed. See the file 'INSTALL' for help.))
109
110 dnl Check for built-in image view support
111 AC_ARG_ENABLE(gdk-pixbuf,
112         [  --disable-gdk-pixbuf    Do not use gdk-pixbuf],
113         [ac_cv_enable_gdk_pixbuf=$enableval], [ac_cv_enable_gdk_pixbuf=yes])
114 AC_ARG_ENABLE(imlib,
115         [  --disable-imlib         Do not use imlib],
116         [ac_cv_enable_imlib=$enableval], [ac_cv_enable_imlib=yes])
117
118 if test "$ac_cv_enable_gdk_pixbuf" = yes; then
119         AM_PATH_GDK_PIXBUF(0.8.0,
120                 [AC_DEFINE(HAVE_GDK_PIXBUF)
121                  ac_cv_enable_imlib=no], [ac_cv_enable_gdk_pixbuf=no])
122 fi
123 if test "$ac_cv_enable_imlib" = yes; then
124         AM_PATH_GDK_IMLIB(1.9,
125                 AC_DEFINE(HAVE_GDK_IMLIB), [ac_cv_enable_imlib=no])
126 fi
127 if test "$ac_cv_enable_gdk_pixbuf" = no -a "$ac_cv_enable_imlib" = no; then
128         AC_MSG_WARN(*** Built-in image view will not be supported ***)
129 fi
130
131 dnl GPGME is used to support OpenPGP 
132 AC_ARG_ENABLE(gpgme,
133         [  --enable-gpgme          Enable GnuPG support using GPGME [default=no]],
134         [ac_cv_enable_gpgme=$enableval], [ac_cv_enable_gpgme=no])
135 AC_MSG_CHECKING([whether to use GPGME])
136 if test $ac_cv_enable_gpgme = yes; then
137         AC_MSG_RESULT(yes)
138         AM_PATH_GPGME(0.2.3, AC_DEFINE(USE_GPGME), [use_gpgme=no
139                                                     ac_cv_enable_gpgme=no])
140 else
141         AC_MSG_RESULT(no)
142 fi
143
144 dnl for JPilot support in addressbook
145 dnl no check for libraries; these are dynamically loaded
146 AC_ARG_ENABLE(jpilot,
147         [  --enable-jpilot         Enable JPilot support [default=no]],
148         [ac_cv_enable_jpilot=$enableval], [ac_cv_enable_jpilot=no])
149 AC_MSG_CHECKING([whether to use JPilot])
150 if test "$ac_cv_enable_jpilot" = yes; then
151         AC_MSG_RESULT(yes)
152         AC_CHECK_HEADERS(pi-args.h pi-appinfo.h pi-address.h,
153                          [ AC_DEFINE(USE_JPILOT) ],
154                          [ ac_cv_enable_jpilot=no ])
155         if test "$ac_cv_enable_jpilot" = no; then
156                 AC_CHECK_HEADERS(libpisock/pi-args.h libpisock/pi-appinfo.h libpisock/pi-address.h,
157                                  [ ac_cv_enable_jpilot=yes
158                                    AC_DEFINE(USE_JPILOT) ])
159         fi
160         AC_MSG_CHECKING([whether jpilot is available])
161         AC_MSG_RESULT($ac_cv_enable_jpilot)
162
163         if test "$ac_cv_enable_jpilot" = yes; then
164                 LIBS="$LIBS -lpisock"
165         fi
166 else
167         AC_MSG_RESULT(no)
168 fi
169
170 dnl for LDAP support in addressbook
171 AC_ARG_ENABLE(ldap,
172         [  --enable-ldap           Enable LDAP support [default=no]],
173         [ac_cv_enable_ldap=$enableval], [ac_cv_enable_ldap=no])
174 AC_MSG_CHECKING([whether to use LDAP])
175 if test "$ac_cv_enable_ldap" = yes; then
176         AC_MSG_RESULT(yes)
177
178         dnl check for available libraries, and pull them in
179         AC_CHECK_LIB(resolv, res_query, LDAP_LIBS="$LDAP_LIBS -lresolv")
180         AC_CHECK_LIB(socket, bind, LDAP_LIBS="$LDAP_LIBS -lsocket")
181         AC_CHECK_LIB(nsl, gethostbyaddr, LDAP_LIBS="$LDAP_LIBS -lnsl")
182         AC_CHECK_LIB(lber, ber_get_tag, LDAP_LIBS="$LDAP_LIBS -llber")
183
184         dnl we need libpthread for sylpheed ldap,  until we find
185         dnl a better way to handle ldap requests asynchronously...
186         AC_CHECK_LIB(pthread, pthread_create, LDAP_LIBS="$LDAP_LIBS -lpthread")
187
188         dnl the check for the headers 
189         AC_CHECK_HEADERS(ldap.h lber.h pthread.h,
190                          [ ac_cv_enable_ldap=yes ],
191                          [ ac_cv_enable_ldap=no ])
192         AC_MSG_CHECKING([whether ldap headers were detected])
193         AC_MSG_RESULT($ac_cv_enable_ldap)
194
195         if test "$ac_cv_enable_ldap" = yes; then
196                 AC_CHECK_LIB(ldap, ldap_open, [ 
197                                 ac_cv_enable_ldap=yes
198                                 CFLAGS="$CFLAGS `$GLIB_CONFIG --cflags gthread`"
199                                 LDAP_LIBS="$LDAP_LIBS -lldap `$GLIB_CONFIG --libs gthread`"
200                                 AC_DEFINE(USE_LDAP)
201                                 AC_SUBST(LDAP_LIBS)
202                                 ], 
203                                 [ ac_cv_enable_ldap=no ], $LDAP_LIBS )
204                 AC_MSG_CHECKING([whether ldap libs were detected])
205                 AC_MSG_RESULT($ac_cv_enable_ldap)
206         fi
207 else
208         AC_MSG_RESULT(no)
209 fi
210
211 dnl Check for OpenSSL
212 AC_ARG_ENABLE(ssl,
213         [  --enable-ssl            Enable SSL support using OpenSSL [default=no]],
214         [ac_cv_enable_ssl=$enableval], [ac_cv_enable_ssl=no])
215 AC_MSG_CHECKING([whether to use OpenSSL])
216 if test $ac_cv_enable_ssl = yes; then
217         AC_MSG_RESULT(yes)
218         AC_MSG_CHECKING([if openssl is available])
219         LIBS="$LIBS -lssl -lcrypto"
220         AC_TRY_LINK([
221 #include <openssl/opensslv.h>
222 ],      [ return OPENSSL_VERSION_NUMBER; ],
223         [ AC_MSG_RESULT(yes)
224           AC_DEFINE(USE_SSL) ],
225         [ AC_MSG_RESULT(no)
226           LIBS="$ac_save_LIBS"
227           ac_cv_enable_ssl=no ])
228 else
229         AC_MSG_RESULT(no)
230 fi
231
232 dnl Check for X-Face support
233 AC_ARG_ENABLE(compface,
234         [  --disable-compface      Do not use compface (X-Face)],
235         [ac_cv_enable_compface=$enableval], [ac_cv_enable_compface=yes])
236 if test "$ac_cv_enable_compface" = yes; then
237         AC_CHECK_LIB(compface, uncompface,,[ac_cv_enable_compface=no])
238 fi
239
240 dnl Check for libjconv
241 AC_ARG_ENABLE(jconv,
242         [  --disable-jconv         Do not use libjconv],
243         [ac_cv_enable_jconv=$enableval], [ac_cv_enable_jconv=yes])
244 if test "$ac_cv_enable_jconv" = yes; then
245         AC_CHECK_LIB(jconv, jconv_alloc_conv,,[ac_cv_enable_jconv=no])
246 fi
247
248 AC_CHECK_LIB(xpg4, setlocale)
249 dnl AC_CHECK_LIB(kcc, KCC_filter)
250
251 dnl for GThread support (currently disabled)
252 dnl AC_ARG_ENABLE(threads,
253 dnl     [  --enable-threads        Enable multithread support [default=no]],
254 dnl     [use_threads=$enableval], [use_threads=no])
255
256 AC_MSG_CHECKING([whether to use threads])
257 if test x"$use_threads" = xyes ; then
258         AC_MSG_RESULT(yes)
259         if test ! -z `$GLIB_CONFIG --help 2>&1 |grep 'gthread'` ; then
260                 CFLAGS="$CFLAGS `$GLIB_CONFIG --cflags gthread`"
261                 LIBS="$LIBS `$GLIB_CONFIG --libs gthread`"
262                 AC_DEFINE(USE_THREADS)
263         else
264                 AC_MSG_ERROR([Sylpheed requires GThread from GLib to use threading.])
265         fi
266 else
267         AC_MSG_RESULT(no)
268 fi
269
270 dnl check for IPv6 option
271 AC_ARG_ENABLE(ipv6,
272         [  --enable-ipv6           Enable IPv6 support [default=no]],
273         [ac_cv_enable_ipv6=$enableval], [ac_cv_enable_ipv6=no])
274
275 dnl automated checks for IPv6 support.
276 AC_MSG_CHECKING([whether to use IPv6])
277 if test x"$ac_cv_enable_ipv6" = xyes; then
278         AC_MSG_RESULT(yes)
279         AC_MSG_CHECKING([for IPv6 support])
280         AC_CACHE_VAL(ac_cv_ipv6,[
281                 AC_TRY_COMPILE([#define INET6
282                                 #include <sys/types.h>
283                                 #include <netinet/in.h>],
284                         [int x = IPPROTO_IPV6; struct in6_addr a;],
285                         ac_cv_ipv6=yes, ac_cv_ipv6=no)
286         ])
287         AC_MSG_RESULT($ac_cv_ipv6)
288         if test $ac_cv_ipv6 = yes; then
289                 AC_DEFINE(INET6)
290         else
291                 AC_MSG_WARN(*** IPv6 will not be supported ***)
292                 ac_cv_enable_ipv6=no
293         fi
294 else
295         AC_MSG_RESULT(no)
296 fi
297
298 dnl PSPELL is user for spell checking
299 AC_ARG_ENABLE(pspell,
300         [  --enable-pspell           Enable pspell support [default=no]],
301         [ac_cv_enable_pspell=$enableval], [ac_cv_enable_pspell=no])
302 AC_MSG_CHECKING([whether to use pspell])
303 if test $ac_cv_enable_pspell = yes; then
304         AC_MSG_RESULT(yes)
305         AM_PATH_PSPELL(.12.2, AC_DEFINE(USE_PSPELL), [use_pspell=no
306                                                     ac_cv_enable_pspell=no])
307         pspell_path="`pspell-config --pkgdatadir`"
308         AC_DEFINE_UNQUOTED(PSPELL_PATH, "${pspell_path}/")
309 else
310         AC_MSG_RESULT(no)
311 fi
312
313 dnl check if gdk / gtk was compiled with USE_XIM
314 AC_MSG_CHECKING([whether GTK was compiled with XIM support])
315 CFLAGS_SAVE="$CFLAGS"
316 LDFLAGS_SAVE="$LDFLAGS"
317 CFLAGS="$CFLAGS `$GLIB_CONFIG --cflags` `gtk-config --cflags`"
318 LDFLAGS="$LIBS `$GLIB_CONFIG --libs` `gtk-config --libs`"
319 AC_CACHE_VAL(ac_cv_use_gtkgdk_xim, [
320         AC_TRY_COMPILE([#include <gtk/gtk.h>
321                         #include <gdk/gdk.h>],
322                         [extern gint gdk_im_open(void); gdk_im_open();],
323                          ac_cv_use_gtkgdk_xim=yes, ac_cv_use_gtkgdk_xim=no)
324         ])
325 AC_MSG_RESULT($ac_cv_use_gtkgdk_xim)
326 if test $ac_cv_use_gtkgdk_xim = yes; then
327         AC_DEFINE(USE_GTKGDK_XIM)
328 fi
329 CFLAGS="$CFLAGS_SAVE"
330 LDFLAGS="$LDFLAGS_SAVE"
331
332
333 dnl Checks for header files.
334 AC_HEADER_DIRENT
335 AC_HEADER_STDC
336 AC_HEADER_SYS_WAIT
337 AC_CHECK_HEADERS(fcntl.h sys/file.h unistd.h paths.h \
338                  sys/param.h sys/utsname.h \
339                  wchar.h wctype.h)
340
341 dnl Checks for typedefs, structures, and compiler characteristics.
342 AC_C_CONST
343 AC_TYPE_OFF_T
344 AC_TYPE_PID_T
345 AC_TYPE_SIZE_T
346 AC_STRUCT_TM
347
348 dnl AC_CHECK_TYPE(wint_t, unsigned int) does not work because wint_t
349 dnl may be defined only in wchar.h (this happens with gcc-2.96).
350 dnl So we need to use this extended macro.
351 SYLPHEED_CHECK_TYPE(wint_t, unsigned int,
352 [
353 #if HAVE_WCHAR_H
354 #include <wchar.h>
355 #endif
356 ])
357
358 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
359 AC_CHECK_SIZEOF(unsigned short, 2)
360 AC_CHECK_SIZEOF(unsigned int, 4)
361 AC_CHECK_SIZEOF(unsigned long, 4)
362
363 dnl Checks for library functions.
364 AC_FUNC_ALLOCA
365 AC_CHECK_FUNCS(gethostname mkdir mktime socket strstr \
366                wcsstr wcswcs iswalnum iswspace towlower \
367                wcslen wcscpy wcsncpy \
368                uname flock lockf inet_aton inet_addr \
369                fchmod mkstemp)
370
371 AC_OUTPUT([
372 Makefile
373 sylpheed.spec
374 intl/Makefile
375 ac/Makefile
376 po/Makefile.in
377 libkcc/Makefile
378 src/version.h
379 src/Makefile
380 faq/Makefile
381 faq/de/Makefile
382 faq/en/Makefile
383 faq/es/Makefile
384 faq/fr/Makefile
385 faq/it/Makefile
386 man/Makefile
387 manual/Makefile
388 manual/de/Makefile
389 manual/en/Makefile
390 manual/es/Makefile
391 manual/fr/Makefile
392 manual/ja/Makefile
393 tools/Makefile
394 ])
395
396 dnl Output the configuration summary
397 echo ""
398 echo "$PACKAGE $VERSION"
399 echo ""
400 if test "$ac_cv_enable_gdk_pixbuf" = yes; then
401         echo "image support : yes (gdk-pixbuf)"
402 elif test "$ac_cv_enable_imlib" = yes; then
403         echo "image support : yes (gdk_imlib)"
404 else
405         echo "image support : no"
406 fi
407 echo "GPGME         : $ac_cv_enable_gpgme"
408 echo "JPilot        : $ac_cv_enable_jpilot"
409 echo "LDAP          : $ac_cv_enable_ldap"
410 echo "OpenSSL       : $ac_cv_enable_ssl"
411 echo "compface      : $ac_cv_enable_compface"
412 echo "libjconv      : $ac_cv_enable_jconv"
413 echo "IPv6          : $ac_cv_enable_ipv6"
414 echo "Pspell        : $ac_cv_enable_pspell"
415 echo ""
416 echo "The binary will be installed in $prefix/bin"
417 echo ""
418 echo "Configure finished, type 'make' to build."