Add missing AUTHORS and ChangeLog.
[gnt.git] / configure.ac
blob43746b835a9b76942f80ed09a567d861f0770e90
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.50])
4 # UPDATING VERSION NUMBERS FOR RELEASES
6 # gnt_micro_version += 1
8 # If any functions have been added to libgnt:
9 #   gnt_micro_version = 0
10 #   gnt_minor_version += 1
11 #   gnt_lt_current += 1
13 # If backwards compatibility has been broken in libgnt:
14 #   gnt_micro_version = 0
15 #   gnt_minor_version = 0
16 #   gnt_major_version += 1;
17 #   gnt_lt_current += 1
19 # gnt_version_suffix should be similar to one of the following:
20 #   For beta releases:          [beta2]
21 #   For code under development: [devel]
22 #   For production releases:    []
24 # Make sure to update ../../configure.ac with libgnt version changes.
27 m4_define([gnt_lt_current], [2])
28 m4_define([gnt_major_version], [2])
29 m4_define([gnt_minor_version], [2])
30 m4_define([gnt_micro_version], [0])
31 m4_define([gnt_version_suffix], [devel])
32 m4_define([gnt_version],
33           [gnt_major_version.gnt_minor_version.gnt_micro_version])
34 m4_define([gnt_display_version], gnt_version[]m4_ifdef([gnt_version_suffix],[gnt_version_suffix]))
36 AC_INIT([libgnt], [gnt_display_version], [devel@pidgin.im])
37 AC_CANONICAL_SYSTEM
38 AM_CONFIG_HEADER(config.h)
39 AC_CONFIG_AUX_DIR([.])
40 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
42 GNT_MAJOR_VERSION=gnt_major_version
43 GNT_MINOR_VERSION=gnt_minor_version
44 GNT_MICRO_VERSION=gnt_micro_version
45 GNT_VERSION=[gnt_display_version]
46 AC_SUBST(GNT_MAJOR_VERSION)
47 AC_SUBST(GNT_MINOR_VERSION)
48 AC_SUBST(GNT_MICRO_VERSION)
49 AC_SUBST(GNT_VERSION)
51 GNT_LT_VERSION_INFO="gnt_lt_current:gnt_micro_version:gnt_minor_version"
52 AC_SUBST(GNT_LT_VERSION_INFO)
54 AC_PATH_PROG(sedpath, sed)
56 dnl Storing configure arguments
57 AC_DEFINE_UNQUOTED(CONFIG_ARGS, "$ac_configure_args", [configure arguments])
59 dnl Checks for programs.
60 AC_PROG_CC
61 AC_DISABLE_STATIC
62 AM_PROG_LIBTOOL
63 LIBTOOL="$LIBTOOL --silent"
64 AC_PROG_INSTALL
66 dnl we don't use autobreak on cygwin!!
67 dnl AC_CYGWIN
69 dnl Checks for header files.
70 AC_HEADER_STDC
71 AC_HEADER_SYS_WAIT
72 AC_CHECK_HEADERS(arpa/nameser_compat.h fcntl.h sys/time.h unistd.h locale.h signal.h stdint.h regex.h)
74 dnl Checks for typedefs, structures, and compiler characteristics.
75 AC_C_CONST
76 AC_STRUCT_TM
78 AC_C_BIGENDIAN
80 dnl Checks for library functions.
81 AC_TYPE_SIGNAL
82 AC_FUNC_STRFTIME
83 AC_CHECK_FUNCS(strdup strstr atexit setlocale)
85 dnl to prevent the g_stat()/g_unlink() crash,
86 dnl (09:50:07) Robot101: LSchiere2: it's easy. +LC_SYS_LARGEFILE somewhere in configure.ac
87 AC_SYS_LARGEFILE
89 dnl FreeBSD doesn't have libdl, dlopen is provided by libc
90 AC_CHECK_FUNC(dlopen, LIBDL="", [AC_CHECK_LIB(dl, dlopen, LIBDL="-ldl")])
92 AC_MSG_CHECKING(for the %z format string in strftime())
93 AC_TRY_RUN([
94 #ifdef HAVE_SYS_TIME_H
95 #include <sys/time.h>
96 #endif
97 #include <time.h>
98 #include <stdio.h>
100 int main()
102         char buf[6];
103         time_t t = time(NULL);
105         if (strftime(buf, sizeof(buf), "%z", localtime(&t)) != 5)
106                 return 1;
108         fprintf(stderr, "strftime(\"%%z\") yields: \"%s\"\n", buf);
110         return !((buf[0] == '-' || buf[0] == '+') &&
111                  (buf[1] >= '0' && buf[1] <= '9') &&
112                  (buf[2] >= '0' && buf[2] <= '9') &&
113                  (buf[3] >= '0' && buf[3] <= '9') &&
114                  (buf[4] >= '0' && buf[4] <= '9')
115                 );
119         AC_MSG_RESULT(yes)
120         AC_DEFINE([HAVE_STRFTIME_Z_FORMAT], [1],
121                                       [Define to 1 if you have a strftime() that supports the %z format string.])
124         AC_MSG_RESULT(no)
127         # Fallback for Cross Compiling...
128         # This will enable the compatibility code.
129         AC_MSG_RESULT(no)
134 AC_CHECK_HEADER(sys/utsname.h)
135 AC_CHECK_FUNC(uname)
137 if test "x$enable_debug" = "xyes" ; then
138         AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.])
139         enable_fatal_asserts="yes"
142 if test "x$enable_fatal_asserts" = "xyes" ; then
143         AC_DEFINE(GAIM_FATAL_ASSERTS, 1, [Define to make assertions fatal (useful for debugging).])
146 if test "x$enable_deprecated" = "xno"; then
147         DEBUG_CFLAGS="$DEBUG_CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
150 if test "x$GCC" = "xyes"; then
151         dnl We enable -Wall later.
152         dnl If it's set after the warning CFLAGS in the compiler invocation, it counteracts the -Wno... flags.
153         dnl This leads to warnings we don't want.
154         CFLAGS=`echo $CFLAGS |$sedpath 's/-Wall//'`
156         dnl ENABLE WARNINGS SUPPORTED BY THE VERSION OF GCC IN USE
157         dnl
158         dnl Future Possibilities
159         dnl
160         dnl Consider adding -Wbad-function-cast.
161         dnl     This leads to spurious warnings using GPOINTER_TO_INT(), et al. directly on a function call.
162         dnl             We'd need an intermediate variable.
163         dnl
164         dnl Consider adding -Wfloat-equal.
165         dnl     This leads to warnings with Perl.
166         dnl             Perhaps we could write ugly configure magic and pass -Wno-float-equal down to that subdirectory.
167         dnl             On the other hand, it's probably actually broken, so maybe the Perl folks should fix that?
168         dnl
169         dnl Consider removing -Wno-sign-compare (from the -Wextra set) and fixing all those cases.
170         dnl     This is likely non-trivial.
171         dnl
172         for newflag in \
173                         "-Waggregate-return" \
174                         "-Wcast-align" \
175                         "-Wdeclaration-after-statement" \
176                         "-Werror-implicit-function-declaration" \
177                         "-Wextra -Wno-sign-compare -Wno-unused-parameter" \
178                         "-Winit-self" \
179                         "-Wmissing-declarations" \
180                         "-Wmissing-prototypes" \
181                         "-Wnested-externs" \
182                         "-Wpointer-arith" \
183                         "-Wundef" \
184         ; do
185                 orig_CFLAGS="$CFLAGS"
186                 CFLAGS="$CFLAGS $newflag"
187                 AC_MSG_CHECKING(for $newflag option to gcc)
188                 AC_TRY_COMPILE([], [
189                         int main() {return 0;}
190                 ], [
191                         AC_MSG_RESULT(yes)
192                         CFLAGS="$orig_CFLAGS"
193                         DEBUG_CFLAGS="$DEBUG_CFLAGS $newflag"
194                 ], [
195                         AC_MSG_RESULT(no)
196                         CFLAGS="$orig_CFLAGS"
197                 ])
198         done
200         if test "x$enable_fortify" = "xyes"; then
201                 AC_MSG_CHECKING(for FORTIFY_SOURCE support)
202                 AC_TRY_COMPILE([#include <features.h>], [
203                         int main() {
204                         #if !(__GNUC_PREREQ (4, 1) \
205                                 || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \
206                                 || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (3, 4) \
207                                         && __GNUC_MINOR__ == 4 \
208                                         && (__GNUC_PATCHLEVEL__ > 2 \
209                                                 || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ >= 8))))
210                         #error No FORTIFY_SOURCE support
211                         #endif
212                                 return 0;
213                         }
214                 ], [
215                         AC_MSG_RESULT(yes)
216                         DEBUG_CFLAGS="$DEBUG_CFLAGS -D_FORTIFY_SOURCE=2"
217                 ], [
218                         AC_MSG_RESULT(no)
219                 ])
220         fi
222         DEBUG_CFLAGS="-Wall $DEBUG_CFLAGS"
223         CFLAGS="-g $CFLAGS"
225 AC_SUBST(CFLAGS)
227 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.0 gobject-2.0 gmodule-2.0],,
228         [
229                 AC_MSG_ERROR([
230 *** GLib 2.0 is required to build LibGNT; please make sure you have the GLib
231 *** development headers installed. The latest version of GLib is
232 *** always available at http://www.gtk.org/.])
233         ])
234 AC_SUBST(GLIB_CFLAGS)
235 AC_SUBST(GLIB_LIBS)
238 AC_MSG_CHECKING(for me pot o' gold)
239 AC_MSG_RESULT(no)
240 AC_CHECK_FUNCS(gethostid lrand48)
241 AC_CHECK_FUNCS(memcpy memmove random strchr strerror vprintf)
242 AC_CHECK_HEADERS(malloc.h paths.h sgtty.h stdarg.h sys/cdefs.h)
243 AC_CHECK_HEADERS(sys/file.h sys/filio.h sys/ioctl.h sys/msgbuf.h)
244 AC_CHECK_HEADERS(sys/select.h sys/uio.h sys/utsname.h sys/wait.h)
245 AC_CHECK_HEADERS(termios.h)
246 #AC_CHECK_FUNC(wcwidth, [AC_DEFINE([HAVE_WCWIDTH], [1], [Define to 1 if you have wcwidth function.])])
247 #AC_VAR_TIMEZONE_EXTERNALS
249 GNT_CFLAGS=
250 GNT_LIBS=
251 AC_ARG_WITH(ncurses-headers, [AC_HELP_STRING([--with-ncurses-headers=DIR],
252                 [compile finch against the ncurses includes in DIR])],
253                 [ac_ncurses_includes="$withval"], [ac_ncurses_includes=""])
254 AC_CHECK_LIB(ncursesw, initscr, [GNT_LIBS="-lncursesw"], [enable_gnt=no])
255 AC_CHECK_LIB(panelw, update_panels, [GNT_LIBS="$GNT_LIBS -lpanelw"], [enable_gnt=no])
257 # If ncursesw is not found, look for plain old ncurses
258 if test "x$enable_gnt" = "xno"; then
259         AC_CHECK_LIB(ncurses, initscr, [[GNT_LIBS="-lncurses"] [enable_gnt=yes]], [enable_gnt=no])
260         AC_CHECK_LIB(panel, update_panels, [[GNT_LIBS="$GNT_LIBS -lpanel"] [enable_gnt=yes]], [enable_gnt=no])
261         AC_DEFINE(NO_WIDECHAR, [1], [Define to 1 if you do not have ncursesw.])
262 else
263         dnl # Some distros put the headers in ncursesw/, some don't
264         found_ncurses_h=no
265         for location in $ac_ncurses_includes /usr/include/ncursesw /usr/include
266         do
267                 f="$location/ncurses.h"
268                 AC_CHECK_HEADER($f,[
269                         AC_MSG_CHECKING([if $f supports wide characters])
270                         AC_TRY_COMPILE([
271                                 #define _XOPEN_SOURCE_EXTENDED
272                                 #include <$f>
273                         ], [
274                                 #ifndef get_wch
275                                 # error get_wch not found!
276                                 #endif
277                         ], [
278                                 dir=$location
279                                 if test x"$dir" != x"." ; then
280                                         GNT_CFLAGS="-I$dir/"
281                                 else
282                                         GNT_CFLAGS=""
283                                 fi
285                                 found_ncurses_h=yes
286                                 AC_MSG_RESULT([yes])
287                                 break
288                         ], [
289                                 AC_MSG_RESULT([no])
290                         ])
291                 ])
292         done
293         if test x"$found_ncurses_h" != "xyes"; then
294                 enable_gnt="no"
295         fi
297 AC_SUBST(GNT_CFLAGS)
298 AC_SUBST(GNT_LIBS)
300 if test "x$enable_gnt" = "xno"; then
301         AC_MSG_ERROR([
302 *** You need ncursesw or ncurses and its header files.])
305 dnl Check for libxml
306 have_libxml=yes
307 PKG_CHECK_MODULES(LIBXML, [libxml-2.0], , [
308                 AC_MSG_RESULT(no)
309                 have_libxml=no
310         ])
311 AC_SUBST(LIBXML_CFLAGS)
312 AC_SUBST(LIBXML_LIBS)
314 if test "x$have_libxml" = "xno"; then
315         AC_DEFINE(NO_LIBXML, 1, [Do not have libxml2.])
318 AM_CONDITIONAL(PURPLE_AVAILABLE, false)
320 AC_OUTPUT([Makefile
321            gnt.pc
322            wms/Makefile
323                   ])