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
15AC_INIT([libressl], m4_esyscmd([tr -d '\n' < VERSION]))
16AC_SUBST([LIBCRYPTO_VERSION], m4_esyscmd([tr -d '\n' < crypto/VERSION]))
17AC_SUBST([LIBSSL_VERSION], m4_esyscmd([tr -d '\n' < ssl/VERSION]))
18AC_SUBST([LIBTLS_VERSION], m4_esyscmd([tr -d '\n' < tls/VERSION]))
19
20AC_CANONICAL_HOST
21AM_INIT_AUTOMAKE([subdir-objects foreign])
22AC_CONFIG_MACRO_DIR([m4])
23
24m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25
26# This must be saved before AC_PROG_CC
27USER_CFLAGS="$CFLAGS"
28
29AC_PROG_CC([cc gcc])
30AC_PROG_CC_STDC
31AM_PROG_CC_C_O
32LT_INIT([pic-only])
33
34CHECK_OS_OPTIONS
35
36CHECK_C_HARDENING_OPTIONS
37
38DISABLE_AS_EXECUTABLE_STACK
39AM_PROG_AS
40
41DISABLE_COMPILER_WARNINGS
42
43# Check if the certhash command should be built
44AC_CHECK_FUNCS([symlink])
45AM_CONDITIONAL([BUILD_CERTHASH], [test "x$ac_cv_func_symlink" = xyes])
46
47# Check if funopen exists
48AC_CHECK_FUNC([funopen])
49
50CHECK_LIBC_COMPAT
51CHECK_SYSCALL_COMPAT
52CHECK_CRYPTO_COMPAT
53CHECK_VA_COPY
54CHECK_B64_NTOP
55
56AC_ARG_WITH([openssldir],
57	AS_HELP_STRING([--with-openssldir],
58		       [Set the default openssl directory]),
59	OPENSSLDIR="$withval"
60	AC_SUBST(OPENSSLDIR)
61)
62AM_CONDITIONAL([OPENSSLDIR_DEFINED], [test x$with_openssldir != x])
63
64AC_ARG_ENABLE([extratests],
65	AS_HELP_STRING([--enable-extratests], [Enable extra tests that may be unreliable on some platforms]))
66AM_CONDITIONAL([ENABLE_EXTRATESTS], [test "x$enable_extratests" = xyes])
67
68AC_ARG_ENABLE([tests],
69       [AS_HELP_STRING([--disable-tests], [Disable tests @<:@default=enabled@:>@])],
70       [
71        if ! test "x${enable_tests}" = "xyes"; then
72		enable_tests="no"
73	fi],
74       [enable_tests="yes"])
75AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = xyes])
76
77AS_CASE([$host_cpu],
78	[*arm*], [host_cpu=arm],
79	[*amd64*], [host_cpu=x86_64 HOSTARCH=intel],
80	[i?86], [HOSTARCH=intel],
81	[x86_64], [HOSTARCH=intel]
82)
83AM_CONDITIONAL([HOST_CPU_IS_INTEL], [test "x$HOSTARCH" = "xintel"])
84
85AC_MSG_CHECKING([if .gnu.warning accepts long strings])
86AC_LINK_IFELSE([AC_LANG_SOURCE([[
87extern void SSLv3_method();
88__asm__(".section .gnu.warning.SSLv3_method\n\t.ascii \"SSLv3_method is insecure\"\n\t.text");
89int main() {return 0;}
90]])], [
91    AC_DEFINE(HAS_GNU_WARNING_LONG, 1, [Define if .gnu.warning accepts long strings.])
92    AC_MSG_RESULT(yes)
93], [
94   AC_MSG_RESULT(no)
95])
96
97AC_ARG_ENABLE([asm],
98	AS_HELP_STRING([--disable-asm], [Disable assembly]))
99AM_CONDITIONAL([OPENSSL_NO_ASM], [test "x$enable_asm" = "xno"])
100
101# Conditionally enable assembly by default
102AM_CONDITIONAL([HOST_ASM_ELF_ARM],
103    [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "arm" -a "x$enable_asm" != "xno"])
104AM_CONDITIONAL([HOST_ASM_ELF_X86_64],
105    [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"])
106AM_CONDITIONAL([HOST_ASM_MACOSX_X86_64],
107    [test "x$HOST_ABI" = "xmacosx" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"])
108AM_CONDITIONAL([HOST_ASM_MASM_X86_64],
109    [test "x$HOST_ABI" = "xmasm" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"])
110AM_CONDITIONAL([HOST_ASM_MINGW64_X86_64],
111    [test "x$HOST_ABI" = "xmingw64" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"])
112
113AC_CONFIG_FILES([
114	Makefile
115	include/Makefile
116	include/openssl/Makefile
117	crypto/Makefile
118	ssl/Makefile
119	tls/Makefile
120	tests/Makefile
121	apps/Makefile
122	apps/ocspcheck/Makefile
123	apps/openssl/Makefile
124	apps/nc/Makefile
125	man/Makefile
126	libcrypto.pc
127	libssl.pc
128	libtls.pc
129	openssl.pc
130])
131
132AC_ARG_ENABLE([nc],
133	AS_HELP_STRING([--enable-nc], [Enable installing TLS-enabled nc(1)]))
134AM_CONDITIONAL([ENABLE_NC], [test "x$enable_nc" = xyes])
135AM_CONDITIONAL([BUILD_NC],  [test x$BUILD_NC = xyes -o "x$enable_nc" = xyes])
136
137AC_ARG_ENABLE([libtls-only],
138	AS_HELP_STRING([--enable-libtls-only], [Enable installing libtls only]))
139AM_CONDITIONAL([ENABLE_LIBTLS_ONLY], [test "x$enable_libtls_only" = xyes])
140
141AC_REQUIRE_AUX_FILE([tap-driver.sh])
142
143AC_OUTPUT
144