diff options
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 295 |
1 files changed, 32 insertions, 263 deletions
diff --git a/configure.ac b/configure.ac index 42b1189..0c71d91 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,3 +1,17 @@ | |||
1 | # Copyright (c) 2014-2015 Brent Cook | ||
2 | # | ||
3 | # Permission to use, copy, modify, and distribute this software for any | ||
4 | # purpose with or without fee is hereby granted, provided that the above | ||
5 | # copyright notice and this permission notice appear in all copies. | ||
6 | # | ||
7 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
8 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
9 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
10 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
11 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
12 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
13 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
14 | |||
1 | AC_INIT([libressl], m4_esyscmd([tr -d '\n' < VERSION])) | 15 | AC_INIT([libressl], m4_esyscmd([tr -d '\n' < VERSION])) |
2 | AC_SUBST([LIBCRYPTO_VERSION], m4_esyscmd([tr -d '\n' < crypto/VERSION])) | 16 | AC_SUBST([LIBCRYPTO_VERSION], m4_esyscmd([tr -d '\n' < crypto/VERSION])) |
3 | AC_SUBST([LIBSSL_VERSION], m4_esyscmd([tr -d '\n' < ssl/VERSION])) | 17 | AC_SUBST([LIBSSL_VERSION], m4_esyscmd([tr -d '\n' < ssl/VERSION])) |
@@ -9,7 +23,7 @@ AC_CONFIG_MACRO_DIR([m4]) | |||
9 | 23 | ||
10 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) | 24 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
11 | 25 | ||
12 | # This must be called before AC_PROG_CC | 26 | # This must be saved before AC_PROG_CC |
13 | USER_CFLAGS="$CFLAGS" | 27 | USER_CFLAGS="$CFLAGS" |
14 | 28 | ||
15 | AC_PROG_CC | 29 | AC_PROG_CC |
@@ -18,272 +32,25 @@ AM_PROG_CC_C_O | |||
18 | AC_PROG_LIBTOOL | 32 | AC_PROG_LIBTOOL |
19 | LT_INIT | 33 | LT_INIT |
20 | 34 | ||
21 | CFLAGS="$CFLAGS -Wall -std=gnu99" | 35 | CHECK_OS_OPTIONS |
22 | |||
23 | case $host_os in | ||
24 | *aix*) | ||
25 | HOST_OS=aix | ||
26 | if test "`echo $CC | cut -d ' ' -f 1`" != "gcc" ; then | ||
27 | CFLAGS="$USER_CFLAGS" | ||
28 | fi | ||
29 | AC_SUBST([PLATFORM_LDADD], ['-lperfstat -lpthread']) | ||
30 | ;; | ||
31 | *cygwin*) | ||
32 | HOST_OS=cygwin | ||
33 | ;; | ||
34 | *darwin*) | ||
35 | HOST_OS=darwin | ||
36 | HOST_ABI=macosx | ||
37 | ;; | ||
38 | *freebsd*) | ||
39 | HOST_OS=freebsd | ||
40 | HOST_ABI=elf | ||
41 | AC_SUBST([PROG_LDADD], ['-lthr']) | ||
42 | ;; | ||
43 | *hpux*) | ||
44 | HOST_OS=hpux; | ||
45 | if test "`echo $CC | cut -d ' ' -f 1`" = "gcc" ; then | ||
46 | CFLAGS="$CFLAGS -mlp64" | ||
47 | else | ||
48 | CFLAGS="-g -O2 +DD64 $USER_CFLAGS" | ||
49 | fi | ||
50 | CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT" | ||
51 | AC_SUBST([PLATFORM_LDADD], ['-lpthread']) | ||
52 | ;; | ||
53 | *linux*) | ||
54 | HOST_OS=linux | ||
55 | HOST_ABI=elf | ||
56 | CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_SOURCE -D_GNU_SOURCE" | ||
57 | ;; | ||
58 | *netbsd*) | ||
59 | HOST_OS=netbsd | ||
60 | CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE" | ||
61 | ;; | ||
62 | *openbsd* | *bitrig*) | ||
63 | HOST_ABI=elf | ||
64 | AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD gcc has bounded]) | ||
65 | ;; | ||
66 | *mingw*) | ||
67 | HOST_OS=win | ||
68 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_POSIX -D_POSIX_SOURCE -D__USE_MINGW_ANSI_STDIO" | ||
69 | CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_THREAD_SAFE_FUNCTIONS" | ||
70 | CPPFLAGS="$CPPFLAGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600" | ||
71 | CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_SPEED -DNO_SYSLOG" | ||
72 | CFLAGS="$CFLAGS -static-libgcc" | ||
73 | LDFLAGS="$LDFLAGS -static-libgcc" | ||
74 | AC_SUBST([PLATFORM_LDADD], ['-lws2_32']) | ||
75 | ;; | ||
76 | *solaris*) | ||
77 | HOST_OS=solaris | ||
78 | HOST_ABI=elf | ||
79 | CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 -DBSD_COMP" | ||
80 | AC_SUBST([PLATFORM_LDADD], ['-lnsl -lsocket']) | ||
81 | ;; | ||
82 | *) ;; | ||
83 | esac | ||
84 | |||
85 | AM_CONDITIONAL([HOST_AIX], [test x$HOST_OS = xaix]) | ||
86 | AM_CONDITIONAL([HOST_CYGWIN], [test x$HOST_OS = xcygwin]) | ||
87 | AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) | ||
88 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) | ||
89 | AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) | ||
90 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) | ||
91 | AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd]) | ||
92 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) | ||
93 | AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) | ||
94 | |||
95 | AC_CHECK_FUNC([clock_gettime],, | ||
96 | [AC_SEARCH_LIBS([clock_gettime],[rt posix4])]) | ||
97 | |||
98 | AC_CHECK_FUNC([dl_iterate_phdr],, | ||
99 | [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])]) | ||
100 | |||
101 | AC_MSG_CHECKING([if compiling with clang]) | ||
102 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ | ||
103 | #ifndef __clang__ | ||
104 | not clang | ||
105 | #endif | ||
106 | ]])], | ||
107 | [CLANG=yes], | ||
108 | [CLANG=no] | ||
109 | ) | ||
110 | AC_MSG_RESULT([$CLANG]) | ||
111 | AS_IF([test "x$CLANG" = "xyes"], [CLANG_FLAGS=-Qunused-arguments]) | ||
112 | |||
113 | CFLAGS="$CFLAGS $CLANG_FLAGS" | ||
114 | LDFLAGS="$LDFLAGS $CLANG_FLAGS" | ||
115 | |||
116 | # We want to check for compiler flag support. Prior to clang v5.1, there was no | ||
117 | # way to make clang's "argument unused" warning fatal. So we invoke the | ||
118 | # compiler through a wrapper script that greps for this message. | ||
119 | saved_CC="$CC" | ||
120 | saved_LD="$LD" | ||
121 | flag_wrap="$srcdir/scripts/wrap-compiler-for-flag-check" | ||
122 | CC="$flag_wrap $CC" | ||
123 | LD="$flag_wrap $LD" | ||
124 | |||
125 | AC_ARG_ENABLE([hardening], | ||
126 | [AS_HELP_STRING([--disable-hardening], | ||
127 | [Disable options to frustrate memory corruption exploits])], | ||
128 | [], [enable_hardening=yes]) | ||
129 | |||
130 | AC_ARG_ENABLE([windows-ssp], | ||
131 | [AS_HELP_STRING([--enable-windows-ssp], | ||
132 | [Enable building the stack smashing protection on | ||
133 | Windows. This currently distributing libssp-0.dll.])]) | ||
134 | |||
135 | AC_DEFUN([CHECK_CFLAG], [ | ||
136 | AC_LANG_ASSERT(C) | ||
137 | AC_MSG_CHECKING([if $saved_CC supports "$1"]) | ||
138 | old_cflags="$CFLAGS" | ||
139 | CFLAGS="$1 -Wall -Werror" | ||
140 | AC_TRY_LINK([ | ||
141 | #include <stdio.h> | ||
142 | ], | ||
143 | [printf("Hello")], | ||
144 | AC_MSG_RESULT([yes]) | ||
145 | CFLAGS=$old_cflags | ||
146 | HARDEN_CFLAGS="$HARDEN_CFLAGS $1", | ||
147 | AC_MSG_RESULT([no]) | ||
148 | CFLAGS=$old_cflags | ||
149 | [$2]) | ||
150 | ]) | ||
151 | |||
152 | AC_DEFUN([CHECK_LDFLAG], [ | ||
153 | AC_LANG_ASSERT(C) | ||
154 | AC_MSG_CHECKING([if $saved_LD supports "$1"]) | ||
155 | old_ldflags="$LDFLAGS" | ||
156 | LDFLAGS="$1 -Wall -Werror" | ||
157 | AC_TRY_LINK([ | ||
158 | #include <stdio.h> | ||
159 | ], | ||
160 | [printf("Hello")], | ||
161 | AC_MSG_RESULT([yes]) | ||
162 | LDFLAGS=$old_ldflags | ||
163 | HARDEN_LDFLAGS="$HARDEN_LDFLAGS $1", | ||
164 | AC_MSG_RESULT([no]) | ||
165 | LDFLAGS=$old_ldflags | ||
166 | [$2]) | ||
167 | ]) | ||
168 | |||
169 | AS_IF([test "x$enable_hardening" = "xyes"], [ | ||
170 | # Tell GCC to NOT optimize based on signed arithmetic overflow | ||
171 | CHECK_CFLAG([[-fno-strict-overflow]]) | ||
172 | |||
173 | # _FORTIFY_SOURCE replaces builtin functions with safer versions. | ||
174 | CHECK_CFLAG([[-D_FORTIFY_SOURCE=2]]) | ||
175 | |||
176 | # Enable read only relocations | ||
177 | CHECK_LDFLAG([[-Wl,-z,relro]]) | ||
178 | CHECK_LDFLAG([[-Wl,-z,now]]) | ||
179 | |||
180 | # Windows security flags | ||
181 | AS_IF([test "x$HOST_OS" = "xwin"], [ | ||
182 | CHECK_LDFLAG([[-Wl,--nxcompat]]) | ||
183 | CHECK_LDFLAG([[-Wl,--dynamicbase]]) | ||
184 | CHECK_LDFLAG([[-Wl,--high-entropy-va]]) | ||
185 | ]) | ||
186 | |||
187 | # Use stack-protector-strong if available; if not, fallback to | ||
188 | # stack-protector-all which is considered to be overkill | ||
189 | AS_IF([test "x$enable_windows_ssp" = "xyes" -o "x$HOST_OS" != "xwin"], [ | ||
190 | CHECK_CFLAG([[-fstack-protector-strong]], | ||
191 | CHECK_CFLAG([[-fstack-protector-all]], | ||
192 | AC_MSG_WARN([compiler does not appear to support stack protection]) | ||
193 | ) | ||
194 | ) | ||
195 | AS_IF([test "x$HOST_OS" = "xwin"], [ | ||
196 | AC_SEARCH_LIBS([__stack_chk_guard],[ssp]) | ||
197 | ]) | ||
198 | ]) | ||
199 | ]) | ||
200 | 36 | ||
37 | CHECK_C_HARDENING_OPTIONS | ||
201 | 38 | ||
202 | # Restore CC, LD | 39 | DISABLE_AS_EXECUTABLE_STACK |
203 | CC="$saved_CC" | ||
204 | LD="$saved_LD" | ||
205 | |||
206 | CFLAGS="$CFLAGS $HARDEN_CFLAGS" | ||
207 | LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS" | ||
208 | |||
209 | # Removing the dependency on -Wno-pointer-sign should be a goal | ||
210 | save_cflags="$CFLAGS" | ||
211 | CFLAGS=-Wno-pointer-sign | ||
212 | AC_MSG_CHECKING([whether CC supports -Wno-pointer-sign]) | ||
213 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], | ||
214 | [AC_MSG_RESULT([yes])] | ||
215 | [AM_CFLAGS=-Wno-pointer-sign], | ||
216 | [AC_MSG_RESULT([no])] | ||
217 | ) | ||
218 | CFLAGS="$save_cflags $AM_CFLAGS" | ||
219 | |||
220 | save_cflags="$CFLAGS" | ||
221 | CFLAGS= | ||
222 | AC_MSG_CHECKING([whether AS supports .note.GNU-stack]) | ||
223 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
224 | __asm__(".section .note.GNU-stack,\"\",@progbits");]])], | ||
225 | [AC_MSG_RESULT([yes])] | ||
226 | [AM_CFLAGS=-DHAVE_GNU_STACK], | ||
227 | [AC_MSG_RESULT([no])] | ||
228 | ) | ||
229 | CFLAGS="$save_cflags $AM_CFLAGS" | ||
230 | AM_PROG_AS | 40 | AM_PROG_AS |
231 | 41 | ||
232 | AC_CHECK_FUNCS([arc4random_buf asprintf explicit_bzero funopen getauxval]) | 42 | DISABLE_COMPILER_WARNINGS |
233 | AC_CHECK_FUNCS([getentropy memmem poll reallocarray]) | ||
234 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | ||
235 | AC_CHECK_FUNCS([symlink]) | ||
236 | AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp]) | ||
237 | 43 | ||
238 | # Share test results with automake | 44 | # Check if the certhash command should be built |
239 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes]) | 45 | AC_CHECK_FUNCS([symlink]) |
240 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | ||
241 | AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes]) | ||
242 | AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes]) | ||
243 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | ||
244 | AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes]) | ||
245 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) | ||
246 | AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) | ||
247 | AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) | ||
248 | AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes]) | ||
249 | AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes]) | ||
250 | AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) | ||
251 | AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) | ||
252 | AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes]) | ||
253 | AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes]) | ||
254 | AM_CONDITIONAL([BUILD_CERTHASH], [test "x$ac_cv_func_symlink" = xyes]) | 46 | AM_CONDITIONAL([BUILD_CERTHASH], [test "x$ac_cv_func_symlink" = xyes]) |
255 | 47 | ||
256 | # overrides for arc4random_buf implementations with known issues | 48 | # Check if funopen exists |
257 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], | 49 | AC_CHECK_FUNC([funopen]) |
258 | [test "x$HOST_OS" != xdarwin \ | ||
259 | -a "x$HOST_OS" != xfreebsd \ | ||
260 | -a "x$HOST_OS" != xnetbsd \ | ||
261 | -a "x$ac_cv_func_arc4random_buf" = xyes]) | ||
262 | |||
263 | AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ | ||
264 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
265 | #include <stdarg.h> | ||
266 | va_list x,y; | ||
267 | ]], [[ va_copy(x,y); ]])], | ||
268 | [ ac_cv_have_va_copy="yes" ], | ||
269 | [ ac_cv_have_va_copy="no" | ||
270 | ]) | ||
271 | ]) | ||
272 | if test "x$ac_cv_have_va_copy" = "xyes" ; then | ||
273 | AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists]) | ||
274 | fi | ||
275 | 50 | ||
276 | AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [ | 51 | CHECK_LIBC_COMPAT |
277 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | 52 | CHECK_LIBC_CRYPTO_COMPAT |
278 | #include <stdarg.h> | 53 | CHECK_VA_COPY |
279 | va_list x,y; | ||
280 | ]], [[ __va_copy(x,y); ]])], | ||
281 | [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no" | ||
282 | ]) | ||
283 | ]) | ||
284 | if test "x$ac_cv_have___va_copy" = "xyes" ; then | ||
285 | AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists]) | ||
286 | fi | ||
287 | 54 | ||
288 | AC_CHECK_HEADERS([err.h]) | 55 | AC_CHECK_HEADERS([err.h]) |
289 | 56 | ||
@@ -299,14 +66,11 @@ AC_ARG_WITH([enginesdir], | |||
299 | AC_DEFINE_UNQUOTED(ENGINESDIR, "$withval") | 66 | AC_DEFINE_UNQUOTED(ENGINESDIR, "$withval") |
300 | ) | 67 | ) |
301 | 68 | ||
302 | AC_ARG_ENABLE([asm], | ||
303 | AS_HELP_STRING([--disable-asm], [Disable assembly])) | ||
304 | AM_CONDITIONAL([OPENSSL_NO_ASM], [test "x$enable_asm" = "xno"]) | ||
305 | |||
306 | AC_ARG_ENABLE([extratests], | 69 | AC_ARG_ENABLE([extratests], |
307 | AS_HELP_STRING([--enable-extratests], [Enable extra tests that may be unreliable on some platforms])) | 70 | AS_HELP_STRING([--enable-extratests], [Enable extra tests that may be unreliable on some platforms])) |
308 | AM_CONDITIONAL([ENABLE_EXTRATESTS], [test "x$enable_extratests" = xyes]) | 71 | AM_CONDITIONAL([ENABLE_EXTRATESTS], [test "x$enable_extratests" = xyes]) |
309 | 72 | ||
73 | # Add CPU-specific alignment flags | ||
310 | old_cflags=$CFLAGS | 74 | old_cflags=$CFLAGS |
311 | CFLAGS="$CFLAGS -I$srcdir/include" | 75 | CFLAGS="$CFLAGS -I$srcdir/include" |
312 | AC_MSG_CHECKING([if BSWAP4 builds without __STRICT_ALIGNMENT]) | 76 | AC_MSG_CHECKING([if BSWAP4 builds without __STRICT_ALIGNMENT]) |
@@ -328,6 +92,11 @@ case $host_cpu in | |||
328 | ;; | 92 | ;; |
329 | esac | 93 | esac |
330 | 94 | ||
95 | AC_ARG_ENABLE([asm], | ||
96 | AS_HELP_STRING([--disable-asm], [Disable assembly])) | ||
97 | AM_CONDITIONAL([OPENSSL_NO_ASM], [test "x$enable_asm" = "xno"]) | ||
98 | |||
99 | # Conditionally enable assembly by default | ||
331 | AM_CONDITIONAL([HOST_ASM_ELF_X86_64], | 100 | AM_CONDITIONAL([HOST_ASM_ELF_X86_64], |
332 | [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"]) | 101 | [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"]) |
333 | AM_CONDITIONAL([HOST_ASM_MACOSX_X86_64], | 102 | AM_CONDITIONAL([HOST_ASM_MACOSX_X86_64], |