1 dnl acinclude.m4 - configure macros used by pacman and libalpm
2 dnl Add some custom macros for pacman and libalpm
4 dnl GCC_STACK_PROTECT_LIB
5 dnl adds -lssp to LIBS if it is available
6 dnl ssp is usually provided as part of libc, but was previously a separate lib
7 dnl It does not hurt to add -lssp even if libc provides SSP - in that case
8 dnl libssp will simply be ignored.
9 AC_DEFUN([GCC_STACK_PROTECT_LIB],[
10 AC_CACHE_CHECK([whether libssp exists], ssp_cv_lib,
13 AC_TRY_LINK(,, ssp_cv_lib=yes, ssp_cv_lib=no)
16 if test $ssp_cv_lib = yes; then
21 dnl GCC_STACK_PROTECT_CC
22 dnl checks -fstack-protector-all with the C compiler, if it exists then updates
23 dnl CFLAGS and defines ENABLE_SSP_CC
24 AC_DEFUN([GCC_STACK_PROTECT_CC],[
26 if test "X$CC" != "X"; then
27 AC_CACHE_CHECK([whether ${CC} accepts -fstack-protector-all],
29 [ssp_old_cflags="$CFLAGS"
30 CFLAGS="$CFLAGS -fstack-protector-all"
31 AC_TRY_COMPILE(,, ssp_cv_cc=yes, ssp_cv_cc=no)
32 CFLAGS="$ssp_old_cflags"
34 if test $ssp_cv_cc = yes; then
35 CFLAGS="$CFLAGS -fstack-protector-all"
36 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
41 dnl GCC_FORTIFY_SOURCE_CC
42 dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
44 AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[
46 if test "X$CC" != "X"; then
47 AC_MSG_CHECKING(for FORTIFY_SOURCE support)
48 AC_TRY_COMPILE([#include <features.h>], [
50 #if !(__GNUC_PREREQ (4, 1) )
51 #error No FORTIFY_SOURCE support
57 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
65 dnl checks -fvisibility=internal with the C compiler, if it exists then
66 dnl defines ENABLE_VISIBILITY_CC in both configure script and Makefiles
67 AC_DEFUN([GCC_VISIBILITY_CC],[
69 if test "X$CC" != "X"; then
70 AC_CACHE_CHECK([whether ${CC} accepts -fvisibility=internal],
72 [visibility_old_cflags="$CFLAGS"
73 CFLAGS="$CFLAGS -fvisibility=internal"
74 AC_TRY_COMPILE(,, visibility_cv_cc=yes, visibility_cv_cc=no)
75 CFLAGS="$visibility_old_cflags"
77 if test $visibility_cv_cc = yes; then
78 AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
80 AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
84 dnl GCC_GNU89_INLINE_CC
85 dnl checks -fgnu89-inline with the C compiler, if it exists then defines
86 dnl ENABLE_GNU89_INLINE_CC in both configure script and Makefiles
87 AC_DEFUN([GCC_GNU89_INLINE_CC],[
89 if test "X$CC" != "X"; then
90 AC_CACHE_CHECK([for -fgnu89-inline],
92 [ gnu89_inline_old_cflags="$CFLAGS"
93 CFLAGS="$CFLAGS -fgnu89-inline"
94 AC_TRY_COMPILE(,, gnu89_inline_cv_cc=yes, gnu89_inline_cv_cc=no)
95 CFLAGS="$gnu89_inline_old_cflags"
97 if test $gnu89_inline_cv_cc = yes; then
98 AC_DEFINE([ENABLE_GNU89_INLINE_CC], 1, [Define if gnu89 inlining semantics should be used.])
100 AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")