aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2015-04-14 08:43:52 -0500
committerBrent Cook <busterb@gmail.com>2015-04-14 08:45:47 -0500
commit5cf05de18ce848d7579f235758160ee12fcd85a5 (patch)
treee6de6bef4d1fdf263efcea9a48a4b66eb93b8936 /configure.ac
parent3096ab0e45351b05b1f1df51cedc183ba6ca7763 (diff)
downloadportable-5cf05de18ce848d7579f235758160ee12fcd85a5.tar.gz
portable-5cf05de18ce848d7579f235758160ee12fcd85a5.tar.bz2
portable-5cf05de18ce848d7579f235758160ee12fcd85a5.zip
make compiler checks for -Wall and -std=gnu99
Yes, there are compilers that do not understand or need these.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac50
1 files changed, 36 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac
index 2cd9814..31efac7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,14 +9,13 @@ AC_CONFIG_MACRO_DIR([m4])
9 9
10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 10m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11 11
12AM_PROG_AS
12AC_PROG_CC 13AC_PROG_CC
13AC_PROG_CC_STDC 14AC_PROG_CC_STDC
14AM_PROG_CC_C_O 15AM_PROG_CC_C_O
15AC_PROG_LIBTOOL 16AC_PROG_LIBTOOL
16LT_INIT 17LT_INIT
17 18
18CFLAGS="$CFLAGS -Wall -std=gnu99"
19
20case $host_os in 19case $host_os in
21 *aix*) 20 *aix*)
22 HOST_OS=aix 21 HOST_OS=aix
@@ -88,6 +87,40 @@ AC_CHECK_FUNC([clock_gettime],,
88AC_CHECK_FUNC([dl_iterate_phdr],, 87AC_CHECK_FUNC([dl_iterate_phdr],,
89 [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])]) 88 [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])])
90 89
90# Check if -Wno-pointer-sign is supported, a lot of ASN1 code needs this due to
91# char*/unsigned char* mismatches.
92save_cflags="$CFLAGS"
93CFLAGS=-Wno-pointer-sign
94AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign])
95AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
96 [AC_MSG_RESULT([yes])]
97 [AM_CFLAGS=-Wno-pointer-sign],
98 [AC_MSG_RESULT([no])]
99)
100CFLAGS="$save_cflags $AM_CFLAGS"
101
102# Check for some common compiler flag support
103save_cflags="$CFLAGS"
104CFLAGS=-Wall
105AC_MSG_CHECKING([whether CC supports -Wall])
106AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
107 [AC_MSG_RESULT([yes])]
108 [AM_CFLAGS=-Wall],
109 [AC_MSG_RESULT([no])]
110)
111CFLAGS="$save_cflags $AM_CFLAGS"
112
113save_cflags="$CFLAGS"
114CFLAGS=--std=gnu99
115AC_MSG_CHECKING([whether CC supports --std=gnu99])
116AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
117 [AC_MSG_RESULT([yes])]
118 [AM_CFLAGS=--std=gnu99],
119 [AC_MSG_RESULT([no])]
120)
121CFLAGS="$save_cflags $AM_CFLAGS"
122
123# Clang needs some workarounds, check for it
91AC_MSG_CHECKING([if compiling with clang]) 124AC_MSG_CHECKING([if compiling with clang])
92AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ 125AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
93#ifndef __clang__ 126#ifndef __clang__
@@ -182,6 +215,7 @@ AS_IF([test "x$enable_hardening" = "xyes"], [
182 AC_MSG_WARN([compiler does not appear to support stack protection]) 215 AC_MSG_WARN([compiler does not appear to support stack protection])
183 ) 216 )
184 ) 217 )
218 # Make sure we can actually link libssp on Windows platforms.
185 AS_IF([test "x$HOST_OS" = "xwin"], [ 219 AS_IF([test "x$HOST_OS" = "xwin"], [
186 AC_SEARCH_LIBS([__stack_chk_guard],[ssp]) 220 AC_SEARCH_LIBS([__stack_chk_guard],[ssp])
187 ]) 221 ])
@@ -196,17 +230,6 @@ LD="$saved_LD"
196CFLAGS="$CFLAGS $HARDEN_CFLAGS" 230CFLAGS="$CFLAGS $HARDEN_CFLAGS"
197LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS" 231LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS"
198 232
199# Removing the dependency on -Wno-pointer-sign should be a goal
200save_cflags="$CFLAGS"
201CFLAGS=-Wno-pointer-sign
202AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign])
203AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
204 [AC_MSG_RESULT([yes])]
205 [AM_CFLAGS=-Wno-pointer-sign],
206 [AC_MSG_RESULT([no])]
207)
208CFLAGS="$save_cflags $AM_CFLAGS"
209
210save_cflags="$CFLAGS" 233save_cflags="$CFLAGS"
211CFLAGS= 234CFLAGS=
212AC_MSG_CHECKING([whether AS supports .note.GNU-stack]) 235AC_MSG_CHECKING([whether AS supports .note.GNU-stack])
@@ -217,7 +240,6 @@ __asm__(".section .note.GNU-stack,\"\",@progbits");]])],
217 [AC_MSG_RESULT([no])] 240 [AC_MSG_RESULT([no])]
218) 241)
219CFLAGS="$save_cflags $AM_CFLAGS" 242CFLAGS="$save_cflags $AM_CFLAGS"
220AM_PROG_AS
221 243
222AC_CHECK_FUNCS([arc4random_buf asprintf explicit_bzero funopen getauxval]) 244AC_CHECK_FUNCS([arc4random_buf asprintf explicit_bzero funopen getauxval])
223AC_CHECK_FUNCS([getentropy memmem poll reallocarray]) 245AC_CHECK_FUNCS([getentropy memmem poll reallocarray])