]> git.ipfire.org Git - thirdparty/nettle.git/blame - aclocal.m4
Add ChangeLog entry for nettle-3.10 release.
[thirdparty/nettle.git] / aclocal.m4
CommitLineData
41660564 1dnl Choose cc flags for compiling position independent code
41660564
NM
2AC_DEFUN([LSH_CCPIC],
3[AC_REQUIRE([AC_CANONICAL_HOST])dnl
4AC_MSG_CHECKING(CCPIC)
5AC_CACHE_VAL(lsh_cv_sys_ccpic,[
6 if test -z "$CCPIC" ; then
7 if test "$GCC" = yes ; then
8 case "$host_os" in
9 bsdi4.*) CCPIC="-fPIC" ;;
10 bsdi*) CCPIC="" ;;
11 darwin*) CCPIC="-fPIC" ;;
a2b05950 12 freebsd*|netbsd*|openbsd*) CCPIC="-fPIC" ;;
41660564
NM
13 # Could also use -fpic, depending on the number of symbol references
14 solaris*) CCPIC="-fPIC" ;;
15 cygwin*) CCPIC="" ;;
16 mingw32*) CCPIC="" ;;
17 *) CCPIC="-fpic" ;;
18 esac
19 else
20 case "$host_os" in
21 darwin*) CCPIC="-fPIC" ;;
22 irix*) CCPIC="-share" ;;
23 hpux*) CCPIC="+z"; ;;
a2b05950 24 freebsd*|netbsd*|openbsd*) CCPIC="-fPIC" ;;
41660564
NM
25 sco*|sysv4.*) CCPIC="-KPIC -dy -Bdynamic" ;;
26 solaris*) CCPIC="-KPIC -Bdynamic" ;;
27 winnt*) CCPIC="-shared" ;;
28 *) CCPIC="" ;;
29 esac
30 fi
31 fi
32 OLD_CFLAGS="$CFLAGS"
33 CFLAGS="$CFLAGS $CCPIC"
95fa09b7
NM
34 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],
35 [lsh_cv_sys_ccpic="$CCPIC"], [lsh_cv_sys_ccpic=''])
41660564
NM
36 CFLAGS="$OLD_CFLAGS"
37])
38CCPIC="$lsh_cv_sys_ccpic"
2f8497aa 39AC_MSG_RESULT($CCPIC)])
41660564
NM
40
41dnl LSH_PATH_ADD(path-id, directory)
42AC_DEFUN([LSH_PATH_ADD],
43[AC_MSG_CHECKING($2)
44ac_exists=no
45if test -d "$2/." ; then
46 ac_real_dir=`cd $2 && pwd`
47 if test -n "$ac_real_dir" ; then
48 ac_exists=yes
49 for old in $1_REAL_DIRS ; do
50 ac_found=no
51 if test x$ac_real_dir = x$old ; then
52 ac_found=yes;
53 break;
54 fi
55 done
56 if test $ac_found = yes ; then
57 AC_MSG_RESULT(already added)
58 else
59 AC_MSG_RESULT(added)
60 # LDFLAGS="$LDFLAGS -L $2"
61 $1_REAL_DIRS="$ac_real_dir [$]$1_REAL_DIRS"
62 $1_DIRS="$2 [$]$1_DIRS"
63 fi
64 fi
65fi
66if test $ac_exists = no ; then
67 AC_MSG_RESULT(not found)
68fi
69])
70
71dnl LSH_RPATH_ADD(dir)
72AC_DEFUN([LSH_RPATH_ADD], [LSH_PATH_ADD(RPATH_CANDIDATE, $1)])
73
74dnl LSH_RPATH_INIT(candidates)
75AC_DEFUN([LSH_RPATH_INIT],
76[AC_REQUIRE([AC_CANONICAL_HOST])dnl
77AC_MSG_CHECKING([for -R flag])
78RPATHFLAG=''
79case "$host_os" in
80 osf1*) RPATHFLAG="-rpath " ;;
81 irix6.*|irix5.*) RPATHFLAG="-rpath " ;;
82 solaris*)
83 if test "$TCC" = "yes"; then
84 # tcc doesn't know about -R
85 RPATHFLAG="-Wl,-R,"
86 else
87 RPATHFLAG=-R
88 fi
89 ;;
86dcf2f3 90 linux*|freebsd*) RPATHFLAG="-Wl,-rpath," ;;
41660564
NM
91 *) RPATHFLAG="" ;;
92esac
93
94if test x$RPATHFLAG = x ; then
95 AC_MSG_RESULT(none)
96else
97 AC_MSG_RESULT([using $RPATHFLAG])
98fi
99
100RPATH_CANDIDATE_REAL_DIRS=''
101RPATH_CANDIDATE_DIRS=''
102
103AC_MSG_RESULT([Searching for libraries])
104
105for d in $1 ; do
106 LSH_RPATH_ADD($d)
107done
108])
109
110dnl Try to execute a main program, and if it fails, try adding some
111dnl -R flag.
112dnl LSH_RPATH_FIX
113AC_DEFUN([LSH_RPATH_FIX],
114[if test $cross_compiling = no -a "x$RPATHFLAG" != x ; then
115 ac_success=no
95fa09b7
NM
116 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) { return 0; }]])],
117 [ac_success=yes], [ac_success=no], [:])
41660564
NM
118
119 if test $ac_success = no ; then
120 AC_MSG_CHECKING([Running simple test program failed. Trying -R flags])
121dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS
122 ac_remaining_dirs=''
123 ac_rpath_save_LDFLAGS="$LDFLAGS"
124 for d in $RPATH_CANDIDATE_DIRS ; do
125 if test $ac_success = yes ; then
126 ac_remaining_dirs="$ac_remaining_dirs $d"
127 else
128 LDFLAGS="$RPATHFLAG$d $LDFLAGS"
129dnl echo LDFLAGS = $LDFLAGS
95fa09b7
NM
130 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) { return 0; }]])],
131 [ac_success=yes
41660564 132 ac_rpath_save_LDFLAGS="$LDFLAGS"
95fa09b7
NM
133 AC_MSG_RESULT([adding $RPATHFLAG$d])
134 ],
135 [ac_remaining_dirs="$ac_remaining_dirs $d"], [:])
41660564
NM
136 LDFLAGS="$ac_rpath_save_LDFLAGS"
137 fi
138 done
139 RPATH_CANDIDATE_DIRS=$ac_remaining_dirs
140 fi
141 if test $ac_success = no ; then
142 AC_MSG_RESULT(failed)
143 fi
144fi
145])
146
41660564
NM
147dnl LSH_GCC_ATTRIBUTES
148dnl Check for gcc's __attribute__ construction
149
150AC_DEFUN([LSH_GCC_ATTRIBUTES],
151[AC_CACHE_CHECK(for __attribute__,
152 lsh_cv_c_attribute,
95fa09b7 153[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
41660564
NM
154#include <stdlib.h>
155
156static void foo(void) __attribute__ ((noreturn));
157
158static void __attribute__ ((noreturn))
159foo(void)
160{
161 exit(1);
162}
95fa09b7
NM
163]], [[]])],
164 [lsh_cv_c_attribute=yes],
165 [lsh_cv_c_attribute=no])])
41660564
NM
166
167AH_TEMPLATE([HAVE_GCC_ATTRIBUTE], [Define if the compiler understands __attribute__])
168if test "x$lsh_cv_c_attribute" = "xyes"; then
169 AC_DEFINE(HAVE_GCC_ATTRIBUTE)
170fi
171
172AH_BOTTOM(
173[#if __GNUC__ && HAVE_GCC_ATTRIBUTE
174# define NORETURN __attribute__ ((__noreturn__))
175# define PRINTF_STYLE(f, a) __attribute__ ((__format__ (__printf__, f, a)))
176# define UNUSED __attribute__ ((__unused__))
177#else
178# define NORETURN
179# define PRINTF_STYLE(f, a)
180# define UNUSED
181#endif
182])])
183
184# Check for alloca, and include the standard blurb in config.h
185AC_DEFUN([LSH_FUNC_ALLOCA],
186[AC_FUNC_ALLOCA
187AC_CHECK_HEADERS([malloc.h])
188AH_BOTTOM(
189[/* AIX requires this to be the first thing in the file. */
190#ifndef __GNUC__
191# if HAVE_ALLOCA_H
192# include <alloca.h>
193# else
194# ifdef _AIX
195 #pragma alloca
196# else
197# ifndef alloca /* predefined by HP cc +Olibcalls */
198char *alloca ();
199# endif
200# endif
201/* Needed for alloca on windows */
202# if HAVE_MALLOC_H
203# include <malloc.h>
204# endif
205# endif
206#else /* defined __GNUC__ */
207# if HAVE_ALLOCA_H
208# include <alloca.h>
7400439c
NM
209# else
210/* Needed for alloca on windows, also with gcc */
211# if HAVE_MALLOC_H
212# include <malloc.h>
213# endif
41660564
NM
214# endif
215#endif
216])])
217
41660564
NM
218dnl LSH_DEPENDENCY_TRACKING
219
220dnl Defines compiler flags DEP_FLAGS to generate dependency
221dnl information, and DEP_PROCESS that is any shell commands needed for
222dnl massaging the dependency information further. Dependencies are
223dnl generated as a side effect of compilation. Dependency files
224dnl themselves are not treated as targets.
225
226AC_DEFUN([LSH_DEPENDENCY_TRACKING],
227[AC_ARG_ENABLE(dependency_tracking,
95fa09b7 228 AS_HELP_STRING([--disable-dependency-tracking], [Disable dependency tracking. Dependency tracking doesn't work with BSD make]),,
41660564
NM
229 [enable_dependency_tracking=yes])
230
231DEP_FLAGS=''
232DEP_PROCESS='true'
233if test x$enable_dependency_tracking = xyes ; then
234 if test x$GCC = xyes ; then
235 gcc_version=`gcc --version | head -1`
236 case "$gcc_version" in
237 2.*|*[[!0-9.]]2.*)
238 enable_dependency_tracking=no
239 AC_MSG_WARN([Dependency tracking disabled, gcc-3.x is needed])
240 ;;
241 *)
242 DEP_FLAGS='-MT $[]@ -MD -MP -MF $[]@.d'
243 DEP_PROCESS='true'
244 ;;
245 esac
246 else
247 enable_dependency_tracking=no
248 AC_MSG_WARN([Dependency tracking disabled])
249 fi
250fi
251
41660564
NM
252AC_SUBST([DEP_FLAGS])
253AC_SUBST([DEP_PROCESS])])
254
255dnl GMP_TRY_ASSEMBLE(asm-code,[action-success][,action-fail])
256dnl ----------------------------------------------------------
257dnl Attempt to assemble the given code.
258dnl Do "action-success" if this succeeds, "action-fail" if not.
259dnl
260dnl conftest.o and conftest.out are available for inspection in
261dnl "action-success". If either action does a "break" out of a loop then
262dnl an explicit "rm -f conftest*" will be necessary.
263dnl
95fa09b7 264dnl This is not unlike AC_COMPILE_IFELSE, but there's no default includes or
41660564
NM
265dnl anything in "asm-code", everything wanted must be given explicitly.
266
267AC_DEFUN([GMP_TRY_ASSEMBLE],
268[cat >conftest.s <<EOF
269[$1]
270EOF
0cecedba 271gmp_assemble="$CC $CFLAGS $CPPFLAGS $ASM_FLAGS -c conftest.s >conftest.out 2>&1"
41660564 272if AC_TRY_EVAL(gmp_assemble); then
95fa09b7 273 cat conftest.out >&AS_MESSAGE_LOG_FD
41660564
NM
274 ifelse([$2],,:,[$2])
275else
95fa09b7
NM
276 cat conftest.out >&AS_MESSAGE_LOG_FD
277 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
278 cat conftest.s >&AS_MESSAGE_LOG_FD
41660564
NM
279 ifelse([$3],,:,[$3])
280fi
281rm -f conftest*
282])
283
ae944d88
NM
284dnl GMP_PROG_CC_FOR_BUILD
285dnl ---------------------
286dnl Establish CC_FOR_BUILD, a C compiler for the build system.
287dnl
288dnl If CC_FOR_BUILD is set then it's expected to work, likewise the old
289dnl style HOST_CC, otherwise some likely candidates are tried, the same as
290dnl configfsf.guess.
291
292AC_DEFUN([GMP_PROG_CC_FOR_BUILD],
293[AC_REQUIRE([AC_PROG_CC])
294if test -n "$CC_FOR_BUILD"; then
295 GMP_PROG_CC_FOR_BUILD_WORKS($CC_FOR_BUILD,,
296 [AC_MSG_ERROR([Specified CC_FOR_BUILD doesn't seem to work])])
297elif test -n "$HOST_CC"; then
298 GMP_PROG_CC_FOR_BUILD_WORKS($HOST_CC,
299 [CC_FOR_BUILD=$HOST_CC],
300 [AC_MSG_ERROR([Specified HOST_CC doesn't seem to work])])
ae944d88 301else
b672e553
NM
302 if test $cross_compiling = no ; then
303 CC_FOR_BUILD="$CC"
304 else
305 for i in gcc cc c89 c99; do
306 GMP_PROG_CC_FOR_BUILD_WORKS($i,
307 [CC_FOR_BUILD=$i
308 break])
309 done
310 if test -z "$CC_FOR_BUILD"; then
311 AC_MSG_ERROR([Cannot find a build system compiler])
312 fi
313 fi
314 if test "$CC_FOR_BUILD" = gcc ; then
8904bb7e 315 CC_FOR_BUILD="$CC_FOR_BUILD -O -g"
ae944d88
NM
316 fi
317fi
318
319AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
320AC_SUBST(CC_FOR_BUILD)
321])
322
323
324dnl GMP_PROG_CC_FOR_BUILD_WORKS(cc/cflags[,[action-if-good][,action-if-bad]])
325dnl -------------------------------------------------------------------------
326dnl See if the given cc/cflags works on the build system.
327dnl
328dnl It seems easiest to just use the default compiler output, rather than
329dnl figuring out the .exe or whatever at this stage.
330
331AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
332[AC_MSG_CHECKING([build system compiler $1])
333# remove anything that might look like compiler output to our "||" expression
334rm -f conftest* a.out b.out a.exe a_out.exe
335cat >conftest.c <<EOF
336int
337main ()
338{
91df6813 339 return 0;
ae944d88
NM
340}
341EOF
342gmp_compile="$1 conftest.c"
343cc_for_build_works=no
344if AC_TRY_EVAL(gmp_compile); then
95fa09b7 345 if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AS_MESSAGE_LOG_FD 2>&1; then
ae944d88
NM
346 cc_for_build_works=yes
347 fi
348fi
349rm -f conftest* a.out b.out a.exe a_out.exe
350AC_MSG_RESULT($cc_for_build_works)
351if test "$cc_for_build_works" = yes; then
352 ifelse([$2],,:,[$2])
353else
354 ifelse([$3],,:,[$3])
355fi
356])
357
358dnl GMP_PROG_EXEEXT_FOR_BUILD
359dnl -------------------------
360dnl Determine EXEEXT_FOR_BUILD, the build system executable suffix.
361dnl
362dnl The idea is to find what "-o conftest$foo" will make it possible to run
363dnl the program with ./conftest. On Unix-like systems this is of course
364dnl nothing, for DOS it's ".exe", or for a strange RISC OS foreign file
365dnl system cross compile it can be ",ff8" apparently. Not sure if the
366dnl latter actually applies to a build-system executable, maybe it doesn't,
367dnl but it won't hurt to try.
368
369AC_DEFUN([GMP_PROG_EXEEXT_FOR_BUILD],
370[AC_REQUIRE([GMP_PROG_CC_FOR_BUILD])
371AC_CACHE_CHECK([for build system executable suffix],
372 gmp_cv_prog_exeext_for_build,
373[if test $cross_compiling = no ; then
374 gmp_cv_prog_exeext_for_build="$EXEEXT"
375else
376 cat >conftest.c <<EOF
377int
378main ()
379{
91df6813 380 return 0;
ae944d88
NM
381}
382EOF
383 for i in .exe ,ff8 ""; do
384 gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
385 if AC_TRY_EVAL(gmp_compile); then
95fa09b7 386 if (./conftest) 2>&AS_MESSAGE_LOG_FD; then
ae944d88
NM
387 gmp_cv_prog_exeext_for_build=$i
388 break
389 fi
390 fi
391 done
392 rm -f conftest*
393 if test "${gmp_cv_prog_exeext_for_build+set}" != set; then
394 AC_MSG_ERROR([Cannot determine executable suffix])
395 fi
396fi
397])
398AC_SUBST(EXEEXT_FOR_BUILD,$gmp_cv_prog_exeext_for_build)
399])
400
ade7779c
NM
401dnl NETTLE_CHECK_ARM_NEON
402dnl ---------------------
1f1b2f10
MS
403dnl Check if ARM Neon instructions should be used.
404dnl Obeys enable_arm_neon, which should be set earlier.
ade7779c
NM
405AC_DEFUN([NETTLE_CHECK_ARM_NEON],
406[if test "$enable_arm_neon" = auto ; then
407 if test "$cross_compiling" = yes ; then
408 dnl Check if compiler/assembler accepts it,
409 dnl without an explicit .fpu neon directive.
410 AC_CACHE_CHECK([if assembler accepts Neon instructions],
411 nettle_cv_asm_arm_neon,
412 [GMP_TRY_ASSEMBLE([
413.text
414foo:
415 vmlal.u32 q1, d0, d1
416],
417 [nettle_cv_asm_arm_neon=yes],
418 [nettle_cv_asm_arm_neon=no])])
419 enable_arm_neon="$nettle_cv_asm_arm_neon"
420 else
421 AC_MSG_CHECKING([if /proc/cpuinfo claims neon support])
422 if grep '^Features.*:.* neon' /proc/cpuinfo >/dev/null ; then
423 enable_arm_neon=yes
424 else
425 enable_arm_neon=no
426 fi
427 AC_MSG_RESULT($enable_arm_neon)
428 fi
429fi
430])
431
2185ed0d
NM
432dnl NETTLE_CHECK_IFUNC
433dnl ------------------
434dnl Check if __attribute__ ((ifunc(...))) works
435AC_DEFUN([NETTLE_CHECK_IFUNC],
436[AC_REQUIRE([AC_PROG_CC])
437AC_CACHE_CHECK([for ifunc support],
438 nettle_cv_link_ifunc,
e07e5605 439 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
2185ed0d
NM
440static int
441foo_imp(int x)
442{
443 return 1;
444}
445
446typedef void void_func (void);
447
448static void_func *
449foo_resolv(void)
450{
451 return (void_func *) foo_imp;
452}
453
454int foo (int x) __attribute__ ((ifunc("foo_resolv")));
455],[
456 return foo(0);
457
458])],
459[nettle_cv_link_ifunc=yes],
e07e5605 460[nettle_cv_link_ifunc=no])])
2185ed0d
NM
461AH_TEMPLATE([HAVE_LINK_IFUNC], [Define if compiler and linker supports __attribute__ ifunc])
462if test "x$nettle_cv_link_ifunc" = xyes ; then
463 AC_DEFINE(HAVE_LINK_IFUNC)
464fi
465])
466
d1c1ebd9
NM
467# ld-version-script.m4 serial 3
468dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
469dnl This file is free software; the Free Software Foundation
470dnl gives unlimited permission to copy and/or distribute it,
471dnl with or without modifications, as long as this notice is preserved.
472
473dnl From Simon Josefsson
474
475# FIXME: The test below returns a false positive for mingw
476# cross-compiles, 'local:' statements does not reduce number of
477# exported symbols in a DLL. Use --disable-ld-version-script to work
478# around the problem.
479
480# gl_LD_VERSION_SCRIPT
481# --------------------
482# Check if LD supports linker scripts, and define automake conditional
483# HAVE_LD_VERSION_SCRIPT if so.
484AC_DEFUN([LD_VERSION_SCRIPT],
485[
486 AC_ARG_ENABLE([ld-version-script],
487 AS_HELP_STRING([--enable-ld-version-script],
488 [enable linker version script (default is enabled when possible)]),
489 [have_ld_version_script=$enableval], [])
490 if test -z "$have_ld_version_script"; then
491 AC_MSG_CHECKING([if LD -Wl,--version-script works])
492 save_LDFLAGS="$LDFLAGS"
493 LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
494 cat > conftest.map <<EOF
495foo
496EOF
497 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
498 [accepts_syntax_errors=yes], [accepts_syntax_errors=no])
499 if test "$accepts_syntax_errors" = no; then
500 cat > conftest.map <<EOF
501VERS_1 {
502 global: sym;
503};
504
505VERS_2 {
506 global: sym;
507} VERS_1;
508EOF
509 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
510 [have_ld_version_script=yes], [have_ld_version_script=no])
511 else
512 have_ld_version_script=no
513 fi
514 rm -f conftest.map
515 LDFLAGS="$save_LDFLAGS"
516 AC_MSG_RESULT($have_ld_version_script)
517 fi
518 if test "$have_ld_version_script" = "yes";then
af011b1c 519 EXTRA_LINKER_FLAGS="-Wl,--version-script=libnettle.map"
d1c1ebd9 520 AC_SUBST(EXTRA_LINKER_FLAGS)
af011b1c 521 EXTRA_HOGWEED_LINKER_FLAGS="-Wl,--version-script=libhogweed.map"
d1c1ebd9
NM
522 AC_SUBST(EXTRA_HOGWEED_LINKER_FLAGS)
523 fi
524])
2e6c93ca
NM
525
526dnl GMP_ASM_POWERPC_R_REGISTERS
527dnl ---------------------------
528dnl Determine whether the assembler takes powerpc registers with an "r" as
529dnl in "r6", or as plain "6". The latter is standard, but NeXT, Rhapsody,
530dnl and MacOS-X require the "r" forms.
531dnl
42db8e0c 532dnl See also powerpc64/machine.m4 which uses the result of this
2e6c93ca
NM
533dnl test.
534
535AC_DEFUN([GMP_ASM_POWERPC_R_REGISTERS],
536[AC_CACHE_CHECK([if the assembler needs r on registers],
537 gmp_cv_asm_powerpc_r_registers,
538[GMP_TRY_ASSEMBLE(
539[ $gmp_cv_asm_text
2e6c93ca
NM
540 mtctr r6],
541[gmp_cv_asm_powerpc_r_registers=yes],
567d0e9f
NM
542[GMP_TRY_ASSEMBLE(
543[ .text
544 mtctr 6],
545[gmp_cv_asm_powerpc_r_registers=no],
2e6c93ca
NM
546[AC_MSG_ERROR([neither "mtctr 6" nor "mtctr r6" works])])])])
547ASM_PPC_WANT_R_REGISTERS="$gmp_cv_asm_powerpc_r_registers"
548])
97f9b45b
NM
549
550# Check if valgrind supports the platform we are compiling for.
551AC_DEFUN([NETTLE_PROG_VALGRIND],
552[AC_CACHE_CHECK([if valgrind is working],
553 nettle_cv_prog_valgrind,
554 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
555 if valgrind -q ./conftest$EXEEXT 2>&AS_MESSAGE_LOG_FD; then
556 nettle_cv_prog_valgrind=yes
557 else
558 nettle_cv_prog_valgrind=no
559 fi], [nettle_cv_prog_valgrind=no])])
560 if test "$nettle_cv_prog_valgrind" = yes ; then
561 IF_VALGRIND=''
562 else
563 IF_VALGRIND='#'
564 fi
565 AC_SUBST(IF_VALGRIND)
566])