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