1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.59)
5AC_INIT([mcabber],[1.1.2],[mcabber@lilotux.net])
6XC_AUTOMAKE
7AC_CONFIG_SRCDIR([mcabber])
8AC_CONFIG_HEADERS([mcabber/config.h])
9AC_CONFIG_HEADERS([include/config.h])
10
11AC_PROG_LIBTOOL
12AC_PROG_RANLIB
13
14# Checks for programs.
15AC_PROG_CC
16AC_PROG_INSTALL
17
18if test "x$GCC" = "xyes"; then
19    dnl Get gcc version
20    AC_MSG_CHECKING([gcc version])
21        gccver=$($CC -dumpversion)
22        gccvermajor=$(echo $gccver | cut -d . -f1)
23        gccverminor=$(echo $gccver | cut -d . -f2)
24        gccvernum=$(expr $gccvermajor "*" 100 + $gccverminor)
25    AC_MSG_RESULT($gccver)
26
27    CFLAGS="$CFLAGS -Wall"
28    if test x"$gccvermajor" = x"4" -a x"$gccverminor" = x"2"; then
29        DBGCFLAGS="-fgnu89-inline"
30    fi
31fi
32
33AC_SYS_LARGEFILE
34
35PKG_PROG_PKG_CONFIG
36
37# Checks for header files.
38AC_HEADER_STDC
39AC_CHECK_HEADERS([arpa/inet.h fcntl.h locale.h netdb.h netinet/in.h stddef.h \
40                  stdlib.h string.h strings.h sys/socket.h sys/time.h \
41                  syslog.h termios.h wchar.h wctype.h localcharset.h])
42AC_CHECK_HEADERS([unistd.h], , AC_MSG_ERROR([Missing header file]))
43AC_VAR_TIMEZONE_EXTERNALS
44
45# Checks for typedefs, structures, and compiler characteristics.
46AC_HEADER_STDBOOL
47AC_C_CONST
48AC_C_INLINE
49AC_TYPE_SIZE_T
50AC_HEADER_TIME
51AC_STRUCT_TM
52
53# Checks for library functions.
54AC_FUNC_ERROR_AT_LINE
55AC_FUNC_MALLOC
56AC_FUNC_MEMCMP
57AC_FUNC_REALLOC
58AC_FUNC_SELECT_ARGTYPES
59AC_TYPE_SIGNAL
60AC_FUNC_STRFTIME
61AC_FUNC_VPRINTF
62AC_CHECK_FUNCS([alarm arc4random bzero gethostbyname gethostname inet_ntoa \
63                isascii memmove memset modf select setlocale socket strcasecmp \
64                strchr strdup strncasecmp strrchr strstr strcasestr vsnprintf \
65                iswblank])
66
67
68AC_CHECK_DECLS([strptime],,,
69[#define _GNU_SOURCE
70#include <time.h>])
71
72# Check for tm_gmtoff
73MC_TM_GMTOFF
74
75# Check if we must provide a SIGWINCH handler
76AC_MSG_CHECKING([if we use our own SIGWINCH handler])
77AC_ARG_ENABLE(sigwinch,
78        AC_HELP_STRING([--enable-sigwinch], [compile with SIGWINCH handler]),
79        [with_sigwinch=$enableval],
80        [with_sigwinch=$with_ext_funcs])
81if test "$with_sigwinch" = yes; then
82    AC_MSG_RESULT($with_sigwinch)
83    AC_DEFINE([USE_SIGWINCH], [], [Provide own SIGWINCH handler])
84else
85    AC_MSG_RESULT(no)
86fi
87
88# Checks for libraries.
89
90AC_CHECK_LIB(charset, locale_charset)
91
92AC_CHECK_FUNC(initscr,,
93[
94    cf_ncurses="ncurses"
95    for lib in ncursesw ncurses
96    do
97        AC_CHECK_LIB($lib, waddnwstr,
98            [cf_ncurses="$lib"; cf_ncurses_unicode="yes"; break])
99    done
100    AC_CHECK_LIB($cf_ncurses, initscr,
101        [LIBS="$LIBS -l$cf_ncurses"
102
103         if test "$cf_ncurses" = ncursesw; then
104             AC_CHECK_LIB(tinfow, tgetent, [LIBS="$LIBS -ltinfow"])
105             AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/panel.h],,
106                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
107                                   AC_MSG_ERROR([Missing header file]))])
108         else
109             AC_CHECK_LIB(tinfo, tgetent, [LIBS="$LIBS -ltinfo"])
110             AC_CHECK_HEADERS([ncurses/ncurses.h ncurses/panel.h],,
111                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
112                                   AC_MSG_ERROR([Missing header file]))])
113         fi
114        ],
115        [CF_CURSES_LIBS])
116])
117
118AC_CHECK_LIB([panelw], [new_panel],,
119             AC_CHECK_LIB([panel], [new_panel])
120            )
121
122if test x"$cf_ncurses_unicode" = x"yes"; then
123    AC_DEFINE([HAVE_UNICODE], [], [Define if ncurses have unicode support])
124else
125    AC_MSG_WARN([Your ncurses installation does not support unicode])
126fi
127
128AC_CACHE_CHECK([for ESCDELAY variable],
129               [mc_cv_ncurses_escdelay],
130               [AC_TRY_LINK([], [
131                            extern int ESCDELAY;
132                            ESCDELAY = 0;
133                            ],
134                            [mc_cv_ncurses_escdelay=yes],
135                            [mc_cv_ncurses_escdelay=no])
136               ])
137if test "$mc_cv_ncurses_escdelay" = yes; then
138    AC_DEFINE([HAVE_ESCDELAY], 1,
139              [Define if ncurses has ESCDELAY variable])
140fi
141
142AC_ARG_ENABLE(modules, AC_HELP_STRING([--disable-modules],
143                                      [disable dynamic modules loading]),
144              enable_modules=$enableval)
145if test "x$enable_modules" != "xno"; then
146  AC_DEFINE(MODULES_ENABLE, 1, [Define if you want dynamic modules loading])
147  gmodule_module=gmodule
148else
149  gmodule_module=''
150fi
151
152# Check for glib
153AM_PATH_GLIB_2_0(2.14.0,
154                 [AC_DEFINE([HAVE_GLIB_REGEX], 1,
155                            [Define if GLib has regex support])],
156                 [AM_PATH_GLIB_2_0(2.0.0, , AC_MSG_ERROR([glib is required]),
157                                  [g_list_append], ["$gmodule_module"])],
158                 [g_regex_new "$gmodule_module"])
159
160# Check for loudmouth
161PKG_CHECK_MODULES(LOUDMOUTH, loudmouth-1.0 >= 1.4.2)
162PKG_CHECK_MODULES(LOUDMOUTH_SHA256, [loudmouth-1.0 >= 1.5.3],
163                  AC_DEFINE([LOUDMOUTH_USES_SHA256], 1,
164                           [loudmouth is now using a new digest]
165                           ),
166                  []
167                 )
168
169# Check for lm_ssl_set_cipher_list in loudmouth
170AC_CHECK_LIB(loudmouth-1, lm_ssl_set_cipher_list,
171              AC_DEFINE([HAVE_LM_SSL_CIPHER_LIST], 1,
172                        [Define that loudmouth has lm_ssl_cipher_list]
173                        )
174            )
175# Check for lm_ssl_set_cipher_list in loudmouth
176AC_CHECK_LIB(loudmouth-1, lm_ssl_set_ca,
177              AC_DEFINE([HAVE_LM_SSL_CA], 1,
178                        [Define that loudmouth has lm_ssl_ca]
179                        )
180            )
181
182
183# Check for libidn
184AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]],
185                                   [Support IDN (needs GNU Libidn)]),
186            libidn=$withval, libidn=yes)
187if test "$libidn" != "no" ; then
188  PKG_CHECK_MODULES(LIBIDN, libidn >= 0.0.0, [libidn=yes], [libidn=no])
189  if test "$libidn" != "yes" ; then
190    libidn=no
191    AC_MSG_WARN([Libidn not found])
192  else
193    libidn=yes
194    AC_DEFINE(HAVE_LIBIDN, 1, [Define to 1 if you want Libidn.])
195  fi
196fi
197
198# Check for gpgme
199AC_ARG_ENABLE(gpgme,
200    AC_HELP_STRING([--disable-gpgme], [disable GPGME support]),
201    [ if test x"$enableval" = x"no"; then
202        enable_gpgme=no
203      fi
204    ])
205
206if test x"${enable_gpgme}" != x"no"; then
207    AM_PATH_GPGME(1.0.0, AC_DEFINE([HAVE_GPGME], 1,
208        [Define if you use GPGME to support OpenPGP]))
209fi
210
211# Check for otr
212AC_ARG_ENABLE(otr,
213    AC_HELP_STRING([--enable-otr],
214                   [enable OTR (Off-the-Record) messaging support]),
215    enable_otr=$enableval,
216    otr="")
217if test "x$enable_otr" = "xyes"; then
218    # Look for libotr
219    AM_PATH_LIBOTR(4.0.0, [
220        AC_DEFINE([HAVE_LIBOTR], 1, [Define if you use libotr])
221    ], [
222        AC_MSG_ERROR(libotr 4.0.0 or newer is required.)
223    ])
224fi
225
226# Check for Enchant stuff
227AC_ARG_ENABLE(enchant,
228              AC_HELP_STRING([--enable-enchant], [enable enchant support]),
229              enable_enchant=$enableval, enchant="")
230# Check for Aspell stuff
231AC_ARG_ENABLE(aspell,
232              AC_HELP_STRING([--enable-aspell], [enable aspell support]),
233              enable_aspell=$enableval, aspell="")
234
235if test "x$enable_enchant" = "xyes"; then
236 PKG_CHECK_MODULES(ENCHANT, [enchant],
237   AC_DEFINE(WITH_ENCHANT, 1, [Define if you want enchant support])
238 )
239else
240 if test "x$enable_aspell" = "xyes"; then
241    AC_CHECK_HEADERS(aspell.h, [ have_aspell_includes=yes ])
242    if test "x$have_aspell_includes" = "xyes"; then
243        AC_CHECK_LIB(aspell, new_aspell_config, [ have_aspell_libs=yes ])
244        if test "x$have_aspell_libs" = "xyes"; then
245            AC_DEFINE([WITH_ASPELL], 1, [Define if you want aspell support])
246            LIBS="$LIBS -laspell"
247        else
248            enable_aspell=no
249        fi
250    else
251        enable_aspell=no
252    fi
253 fi
254fi
255
256# Export $datadir to the source tree.
257if test x"${datadir}" != x""; then
258    AC_DEFINE_DIR(DATA_DIR, datadir, [Data files directory])
259fi
260
261# Export $libexecdir to the source tree
262pkglibdir=${libdir}/${PACKAGE}
263AC_DEFINE_DIR(PKGLIB_DIR, pkglibdir, [Modules directory])
264
265AC_ARG_ENABLE(debug,
266    AC_HELP_STRING([--enable-debug], [add development compilation options]),
267    debug=$enableval, debug="")
268if test x"${debug}" = x"yes"; then
269    AC_DEFINE_UNQUOTED([ENABLE_DEBUG],[1],[Devel compilation options])
270    if test "x$GCC" = "xyes"; then
271        if test "$gccvernum" -ge "400"; then
272            CFLAGS="$CFLAGS -Wextra"
273        else
274            CFLAGS="$CFLAGS -W"
275        fi
276        CFLAGS="$CFLAGS -Wno-unused-parameter -pedantic -std=gnu99 $DBGCFLAGS -O0"
277    fi # gcc
278    CFLAGS="$CFLAGS -g"
279else
280    CFLAGS="-O2 $CFLAGS"
281fi
282
283AC_ARG_ENABLE(hgcset,
284    AC_HELP_STRING([--disable-hgcset], [do not use Mercurial changeset value]),
285    hgcset=$enableval, hgcset="yes")
286AM_CONDITIONAL(HGCSET, [test x$hgcset = xyes])
287if test "${hgcset}" = "yes"; then
288    AC_DEFINE([ENABLE_HGCSET], 1, [Use Mercurial changeset])
289fi
290
291AM_CONDITIONAL([OTR], [test x$libotr_found = xyes])
292AM_CONDITIONAL([INSTALL_HEADERS], [test x$enable_modules != xno])
293
294# Prepare some config.h variables
295AC_DEFINE([MCABBER_BRANCH], "1.1.2", [Mcabber branch])
296AC_DEFINE([MCABBER_VERSION], "AC_PACKAGE_VERSION", [Mcabber version string])
297
298# We need _GNU_SOURCE for strptime() and strcasestr()
299CFLAGS="$CFLAGS -D_GNU_SOURCE"
300
301AC_CONFIG_FILES([mcabber/Makefile
302                 modules/Makefile
303                 modules/beep/Makefile
304                 modules/xttitle/Makefile
305                 modules/fifo/Makefile
306                 modules/urlregex/Makefile
307                 doc/Makefile
308                 doc/guide/Makefile
309                 doc/help/Makefile
310                 mcabber.pc
311                 Makefile])
312AC_OUTPUT
313dnl vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2:  For Vim users...
314