2b2fdcabccbd63a9c4d286f41bb5db1dd0c9e85b
[libgcrypt.git] / configure.in
1 dnl
2 dnl Configure template for GNUPG
3 dnl
4 dnl (Process this file with autoconf to produce a configure script.)
5 AC_REVISION($Revision$)dnl
6
7 dnl Must reset CDPATH so that bash's cd does not print to stdout
8 CDPATH=
9
10 AC_INIT(g10/g10.c)
11 AC_CONFIG_AUX_DIR(scripts)
12 AM_CONFIG_HEADER(config.h)
13
14
15 VERSION=`cat $srcdir/VERSION`
16 PACKAGE=gnupg
17 ALL_LINGUAS="en de it fr ru es_ES"
18 AC_SUBST(VERSION)
19 AC_SUBST(PACKAGE)
20 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
21 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
22
23 AC_ARG_ENABLE(dev-random,
24 [  --disable-dev-random    disable the use of dev random],
25     try_dev_random=$enableval, try_dev_random=yes)
26
27 AC_ARG_ENABLE(dynload,
28 [  --disable-dynload       disable dynamic loading],
29     try_dynload=$enableval, try_dynload=yes)
30
31 AC_MSG_CHECKING([whether memory debugging is requested])
32 AC_ARG_ENABLE(m-debug,
33 [  --enable-m-debug        enable debugging of memory allocation],
34 use_m_debug=$enableval, use_m_debug=no)
35 AC_MSG_RESULT($use_m_debug)
36 if test "$use_m_debug" = yes; then
37     AC_DEFINE(M_DEBUG)
38     use_m_guard=yes
39 else
40     AC_MSG_CHECKING([whether memory guard is requested])
41     AC_ARG_ENABLE(m-guard,
42     [  --disable-m-guard       disable memory guard facility],
43     use_m_guard=$enableval, use_m_guard=yes)
44     AC_MSG_RESULT($use_m_guard)
45 fi
46 if test "$use_m_guard" = yes ; then
47     AC_DEFINE(M_GUARD)
48     CFLAGS="$CFLAGS -g -Wall"
49 else
50     CFLAGS="$CFLAGS -O2 -Wall"
51 fi
52
53
54 AC_MSG_CHECKING([whether included zlib is requested])
55 AC_ARG_WITH(included-zlib,
56     [  --with-included-zlib    use the zlib code included here],
57 [g10_force_zlib=yes], [g10_force_zlib=no] )
58 AC_MSG_RESULT($g10_force_zlib)
59
60 dnl Checks for programs.
61
62 AC_CANONICAL_SYSTEM
63 AC_ARG_PROGRAM
64 AC_PROG_MAKE_SET
65 AM_SANITY_CHECK
66 missing_dir=`cd $ac_aux_dir && pwd`
67 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
68 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
69 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
70 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
71 dnl AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
72 AC_PROG_CC
73 AC_PROG_CPP
74 AC_ISC_POSIX
75 AC_PROG_RANLIB
76 AC_PROG_INSTALL
77 AM_CYGWIN32
78
79
80
81 case "${target}" in
82     i386--mingw32)
83         # special stuff for Windoze NT
84         cross_compiling=yes
85         CC="i386--mingw32-gcc"
86         CPP="i386--mingw32-gcc -E"
87         RANLIB="i386--mingw32-ranlib"
88         ac_cv_have_dev_random=no
89         AC_DEFINE(USE_RAND_W32)
90         ;;
91     *-*-hpux*)
92         if test -z "$GCC" ; then
93             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
94         fi
95         AC_DEFINE(USE_RAND_UNIX)
96         ;;
97     *)
98         AC_DEFINE(USE_RAND_UNIX)
99        ;;
100 esac
101
102 case "${target}" in
103     i386--mingw32)
104         PRINTABLE_OS_NAME="MingW32"
105         ;;
106     *-linux*)
107         PRINTABLE_OS_NAME="GNU/Linux"
108         ;;
109     *)
110         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
111         ;;
112 esac
113 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME")
114
115 dnl  Fixme: Are these the best flags for OpenBSD????
116 case "${target}" in
117     *-openbsd*)
118         NAME_OF_DEV_RANDOM="/dev/srandom"
119         NAME_OF_DEV_URANDOM="/dev/urandom"
120         DYNLINK_MOD_CFLAGS="-shared -rdynamic -fpic -Wl,-Bshareable -Wl,-x"
121         ;;
122     *)
123         NAME_OF_DEV_RANDOM="/dev/random"
124         NAME_OF_DEV_URANDOM="/dev/urandom"
125         DYNLINK_MOD_CFLAGS="-shared  -fPIC -lc"
126         ;;
127 esac
128 AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM")
129 AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM")
130
131
132 dnl Checks for libraries.
133
134 AM_GNU_GETTEXT
135
136 AC_CHECK_LIB(gdbm,gdbm_firstkey)
137
138 if test "$try_dynload" = yes ; then
139 AC_CHECK_LIB(dl,dlopen)
140 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
141   AC_DEFINE(USE_DYNAMIC_LINKING)
142   AC_DEFINE(HAVE_DL_DLOPEN)
143   DYNLINK_LDFLAGS=-rdynamic
144   use_gnupg_extensions=yes
145 else
146 AC_CHECK_LIB(dld,dld_link)
147 if test "$ac_cv_lib_dld_dld_link" = "yes"; then
148   AC_DEFINE(USE_DYNAMIC_LINKING)
149   AC_DEFINE(HAVE_DLD_DLD_LINK)
150   DYNLINK_LDFLAGS=-rdynamic
151   use_gnupg_extensions=yes
152 fi
153 fi
154 else
155   AC_MSG_CHECKING(for dynamic loading)
156   DYNLINK_LDFLAGS=
157   DYNLINK_MOD_CFLAGS=
158   use_gnupg_extensions=no
159   AC_MSG_RESULT(has been disabled)
160 fi
161
162 AM_CONDITIONAL(ENABLE_GNUPG_EXTENSIONS, test "$use_gnupg_extensions" = yes )
163 AC_SUBST(DYNLINK_LDFLAGS)
164 AC_SUBST(DYNLINK_MOD_CFLAGS)
165
166
167 dnl Checks for header files.
168 AC_HEADER_STDC
169 AC_CHECK_HEADERS(unistd.h)
170
171
172 dnl Checks for typedefs, structures, and compiler characteristics.
173 AC_C_CONST
174 AC_C_INLINE
175 AC_TYPE_SIZE_T
176 AC_TYPE_SIGNAL
177 AC_DECL_SYS_SIGLIST
178
179 WK_CHECK_ENDIAN
180
181
182 WK_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
183 WK_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
184 WK_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
185 WK_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
186 WK_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
187
188 AC_CHECK_SIZEOF(unsigned short, 2)
189 AC_CHECK_SIZEOF(unsigned int, 4)
190 AC_CHECK_SIZEOF(unsigned long, 4)
191
192 if test "$ac_cv_sizeof_unsigned_short" = "0" \
193    || test "$ac_cv_sizeof_unsigned_int" = "0" \
194    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
195     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
196 fi
197
198
199
200 dnl Checks for library functions.
201 AC_FUNC_VPRINTF
202 AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr rand strtoul mmap)
203 AC_CHECK_FUNCS(memmove gettimeofday getrusage gethrtime setrlimit)
204 AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime)
205
206 WK_CHECK_MLOCK
207
208 WK_CHECK_IPC
209 if test "$ac_cv_header_sys_shm_h" = "yes"; then
210   AC_DEFINE(USE_SHM_COPROCESSING)
211 fi
212
213 dnl check whether we have a random device
214 if test "$try_dev_random" = yes ; then
215 AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
216 [if test -c "$NAME_OF_DEV_RANDOM" && test -c "$NAME_OF_DEV_URANDOM" ; then
217   ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
218 if test "$ac_cv_have_dev_random" = yes; then
219     AC_DEFINE(HAVE_DEV_RANDOM)
220 fi
221 else
222     AC_MSG_CHECKING(for random device)
223     ac_cv_have_dev_random=no
224     AC_MSG_RESULT(has been disabled)
225 fi
226
227
228 dnl setup assembler stuff
229 AC_MSG_CHECKING(for mpi assembler functions)
230 if test -f $srcdir/mpi/config.links ; then
231     . $srcdir/mpi/config.links
232     WK_LINK_FILES($mpi_ln_src, $mpi_ln_dst)
233     ac_cv_mpi_extra_asm_modules="$mpi_extra_modules"
234     ac_cv_mpi_sflags="$mpi_sflags"
235     ac_cv_mpi_config_done="yes"
236     AC_MSG_RESULT(done)
237 else
238     AC_MSG_RESULT(failed)
239     AC_MSG_ERROR([mpi/config.links missing!])
240 fi
241 MPI_EXTRA_ASM_OBJS=""
242 if test "$ac_cv_mpi_extra_asm_modules" != ""; then
243 WK_MSG_PRINT([mpi extra asm functions:])
244 for i in $ac_cv_mpi_extra_asm_modules; do
245     WK_MSG_PRINT([$i])
246     MPI_EXTRA_ASM_OBJS="$MPI_EXTRA_ASM_OBJS $i.o"
247 done
248 AC_MSG_RESULT()
249 fi
250 AC_SUBST(MPI_EXTRA_ASM_OBJS)
251 MPI_SFLAGS="$ac_cv_mpi_sflags"
252 AC_SUBST(MPI_SFLAGS)
253
254 dnl Do we have zlib? Must do it here because Solaris failed
255 dnl when compiling a conftest (due to the "-lz" from LIBS).
256 if test "$g10_force_zlib" = "yes"; then
257     ZLIBS="../zlib/libzlib.a"
258     AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, true)
259     WK_LINK_FILES(zlib/zlib.h, zlib.h )
260     WK_LINK_FILES(zlib/zconf.h, zconf.h )
261 else
262 AC_CHECK_HEADERS(zlib.h)
263 if test "$ac_cv_header_zlib_h" = yes ; then
264     LIBS="$LIBS -lz"
265     ZLIBS=
266     AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, false)
267 else
268     ZLIBS="../zlib/libzlib.a"
269     AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, true)
270     WK_LINK_FILES(zlib/zlib.h, zlib.h )
271     WK_LINK_FILES(zlib/zconf.h, zconf.h )
272 fi
273 fi
274 AC_SUBST(ZLIBS)
275
276 WK_DO_LINK_FILES
277
278
279 AC_OUTPUT([
280 Makefile
281 intl/Makefile
282 po/Makefile.in
283 util/Makefile
284 mpi/Makefile
285 cipher/Makefile
286 g10/Makefile
287 doc/Makefile
288 tools/Makefile
289 zlib/Makefile
290 checks/Makefile
291 ])
292