Prototype disk space checking functionality
[pacman-ng.git] / acinclude.m4
blob740d9ecc1d259d940435377e84cff933bada8aa0
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,
11     [ssp_old_libs="$LIBS"
12      LIBS="$LIBS -lssp"
13      AC_TRY_LINK(,, ssp_cv_lib=yes, ssp_cv_lib=no)
14      LIBS="$ssp_old_libs"
15     ])
16   if test $ssp_cv_lib = yes; then
17     LIBS="$LIBS -lssp"
18   fi
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],[
25   AC_LANG_ASSERT(C)
26   if test "X$CC" != "X"; then
27     AC_CACHE_CHECK([whether ${CC} accepts -fstack-protector-all],
28       ssp_cv_cc,
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"
33       ])
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.])
37     fi
38   fi
41 dnl GCC_FORTIFY_SOURCE_CC
42 dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
43 dnl CFLAGS
44 AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[
45   AC_LANG_ASSERT(C)
46   if test "X$CC" != "X"; then
47     AC_MSG_CHECKING(for FORTIFY_SOURCE support)
48     AC_TRY_COMPILE([#include <features.h>], [
49       int main() {
50       #if !(__GNUC_PREREQ (4, 1) )
51       #error No FORTIFY_SOURCE support
52       #endif
53         return 0;
54       }
55     ], [
56       AC_MSG_RESULT(yes)
57       CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
58     ], [
59       AC_MSG_RESULT(no)
60   ])
61   fi
64 dnl GCC_VISIBILITY_CC
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],[
68   AC_LANG_ASSERT(C)
69   if test "X$CC" != "X"; then
70     AC_CACHE_CHECK([whether ${CC} accepts -fvisibility=internal],
71       visibility_cv_cc,
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"
76       ])
77     if test $visibility_cv_cc = yes; then
78       AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
79     fi
80         AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
81   fi
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],[
88   AC_LANG_ASSERT(C)
89   if test "X$CC" != "X"; then
90     AC_CACHE_CHECK([for -fgnu89-inline],
91     gnu89_inline_cv_cc,
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"
96     ])
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.])
99     fi
100         AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")
101   fi