8d8e27490e9436858f5015e8086fc09399ee6fda
[citadel] / libcitadel / configure.in
1 dnl   configuration script for libcitadel
2 dnl   Process this file with autoconf to produce a configure script.
3 dnl
4
5 dnl Ensure that libcitadel is configured with autoconf 2.52 or newer
6 AC_PREREQ(2.52)
7
8 AC_INIT(libcitadel, 7.38, https://uncensored.citadel.org)
9
10 AC_CONFIG_SRCDIR(Makefile.in)
11 AC_CONFIG_AUX_DIR(conftools)
12
13
14 dnl
15 dnl Increment LIBREVISION if source code has changed at all
16 dnl
17 dnl If the API has changed, increment LIBCURRENT and set LIBREVISION to 0
18 dnl
19 dnl If the API changes compatibly (i.e. simply adding a new function
20 dnl without changing or removing earlier interfaces), then increment LIBAGE.
21 dnl 
22 dnl If the API changes incompatibly set LIBAGE back to 0
23 dnl
24
25 LIBCURRENT=1
26 LIBREVISION=0
27 LIBAGE=0
28
29 sinclude(conftools/libtool.m4)
30 sinclude(conftools/ac_c_bigendian_cross.m4)
31
32 AC_PROG_LIBTOOL
33
34 AC_SUBST(LIBCURRENT)
35 AC_SUBST(LIBREVISION)
36 AC_SUBST(LIBAGE)
37
38 dnl Checks for programs.
39 AC_PROG_CC
40 AC_PROG_INSTALL
41
42 if test "$GCC" = yes ; then
43     dnl
44     dnl Be careful about adding the -fexceptions option; some versions of
45     dnl GCC don't support it and it causes extra warnings that are only
46     dnl distracting; avoid.
47     dnl
48     OLDCFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes"
49     CFLAGS="$OLDCFLAGS -fexceptions"
50     AC_MSG_CHECKING(whether $CC accepts -fexceptions)
51     AC_TRY_LINK( , ,
52                    AC_MSG_RESULT(yes),
53                    AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
54     CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
55 fi
56
57 dnl Checks for header files.
58 AC_HEADER_STDC
59
60 AC_CHECK_HEADER(sys/mman.h, [CFLAGS="$CFLAGS -D HAVE_MMAP"])
61 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
62 dnl Checks for the zlib compression library.
63 if test "x$with_zlib" != xno ; then
64         AC_CHECK_HEADERS(zlib.h,
65                 [AC_CHECK_LIB(z, zlibVersion,
66                         [ok_zlib=yes],,
67         )])
68 fi
69
70 if test "x$ok_zlib" = xyes ; then
71         LIBS="-lz $LIBS"
72         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
73 fi
74
75 AC_CHECK_HEADERS(iconv.h)
76
77
78 dnl Here is the check for a libc integrated iconv
79 AC_ARG_ENABLE(iconv,
80         [  --disable-iconv         do not use iconv charset conversion],
81         ok_iconv=no, ok_iconv=yes)
82
83 AC_MSG_CHECKING(Checking to see if your system supports iconv)
84 AC_TRY_RUN([
85         #include <iconv.h>
86         main() {
87                 iconv_t ic = (iconv_t)(-1) ;
88                 ic = iconv_open("UTF-8", "us-ascii");
89                 iconv_close(ic);
90                 exit(0);
91         }
92  ],
93                 [
94                   ok_iconv=yes
95                   AC_MSG_RESULT([yes])
96                 ],
97                 [ 
98                   ok_iconv=no
99                   AC_MSG_RESULT([no])
100                 ]
101 )
102
103 dnl Check for iconv in external libiconv
104 if test "$ok_iconv" = no; then
105         AC_MSG_CHECKING(Checking for an external libiconv)
106         OLD_LDFLAGS="$LDFLAGS"
107         LDFLAGS="$LDFLAGS -liconv"
108         AC_TRY_RUN([
109                         #include <iconv.h>
110                         main() {
111                                 iconv_t ic = (iconv_t)(-1) ;
112                                 ic = iconv_open("UTF-8", "us-ascii");
113                                 iconv_close(ic);
114                         }
115                 ],
116                         [
117                           ok_iconv=yes
118                           AC_MSG_RESULT([yes])
119                         ],
120                         [ 
121                           ok_iconv=no
122                           LDFLAGS="$OLD_LDFLAGS"
123                           AC_MSG_RESULT([no])
124                         ]
125                 )
126 fi      
127 if test "$ok_iconv" != "no"; then
128         AC_MSG_RESULT(libcitadel will be built with character set conversion.)
129         AC_DEFINE(HAVE_ICONV,[],[whether we have iconv for charset conversion])
130 else
131         AC_MSG_RESULT(libcitadel will be built without character set conversion.)
132 fi
133
134
135 AC_ARG_WITH(with_zlib,    [  --with-zlib             use zlib compression if present])
136 dnl Checks for the zlib compression library.
137 if test "x$with_zlib" != xno ; then
138         AC_CHECK_HEADERS(zlib.h,
139                 [AC_CHECK_LIB(z, zlibVersion,
140                         [ok_zlib=yes],,
141         )])
142 fi
143
144 if test "x$ok_zlib" = xyes ; then
145         LIBS="-lz $LIBS"
146         AC_DEFINE(HAVE_ZLIB,[],[whether we have zlib])
147 fi
148
149
150 dnl Checks for typedefs, structures, and compiler characteristics.
151
152 AC_SUBST(LIBS)
153 AC_C_CONST
154 AC_TYPE_SIZE_T
155 AC_CHECK_FUNCS(memmove bcopy)
156
157 AC_CONFIG_FILES(Makefile libcitadel.pc)
158 AC_CONFIG_HEADER(sysdep.h)
159 AC_OUTPUT
160
161 abs_srcdir="`cd $srcdir && pwd`"
162 abs_builddir="`pwd`"
163 if test "$abs_srcdir" != "$abs_builddir"; then
164   make mkdir-init
165 fi
166 echo 'zlib compression:                ' $ok_zlib
167 echo 'Character set conversion support:' $ok_iconv