diff --git a/autogen.sh b/autogen.sh index 38665be47..b492bd9e9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,6 +3,15 @@ # Create configure and makefile stuff... # +# Git hooks should come before autoreconf. +if test -d .git; then + if ! test -d .git; then + mkdir .git/hooks + fi + ln -s -f ../../pre-commit.sh .git/hooks/pre-commit +fi + +# If this is a source checkout then call autoreconf with error as well if test -d .git; then WARNINGS="all,error" else @@ -11,6 +20,3 @@ fi autoreconf --install --force --verbose -if test -d .git; then - ln -s -f ../../pre-commit.sh .git/hooks/pre-commit -fi diff --git a/configure.ac b/configure.ac index 04b9db2b0..561122815 100644 --- a/configure.ac +++ b/configure.ac @@ -6,25 +6,30 @@ # # -AC_INIT([cyassl],[2.8.1],[http://www.yassl.com]) +AC_INIT([cyassl],[2.8.1],[https://github.com/cyassl/cyassl/issues],[cyassl],[http://www.yassl.com]) AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_MACRO_DIR([m4]) - -AC_CANONICAL_TARGET -AC_USE_SYSTEM_EXTENSIONS - -AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects]) AC_CANONICAL_HOST AC_CANONICAL_BUILD +AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests]) AC_PREREQ([2.63]) +AC_ARG_PROGRAM +AC_DEFUN([PROTECT_AC_USE_SYSTEM_EXTENSIONS], + [AX_SAVE_FLAGS + AC_LANG_PUSH([C]) + AC_USE_SYSTEM_EXTENSIONS + AC_LANG_POP([C]) + AX_RESTORE_FLAGS + ]) +#PROTECT_AC_USE_SYSTEM_EXTENSIONS + +AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS. - #shared library versioning CYASSL_LIBRARY_VERSION=5:2:0 # | | | @@ -57,8 +62,6 @@ AS_IF([ test -n "$CFLAG_VISIBILITY" ], [ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AX_CXX_COMPILER_VERSION - AC_CHECK_FUNCS([gethostbyname]) AC_CHECK_FUNCS([getaddrinfo]) AC_CHECK_FUNCS([gettimeofday]) diff --git a/m4/ax_append_to_file.m4 b/m4/ax_append_to_file.m4 index c88affb46..f9f54e088 100644 --- a/m4/ax_append_to_file.m4 +++ b/m4/ax_append_to_file.m4 @@ -19,9 +19,9 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 7 +#serial 8 AC_DEFUN([AX_APPEND_TO_FILE],[ AC_REQUIRE([AX_FILE_ESCAPES]) -printf "$2" >> "$1" +printf "$2\n" >> "$1" ]) diff --git a/m4/ax_check_library.m4 b/m4/ax_check_library.m4 new file mode 100644 index 000000000..dd27ff41f --- /dev/null +++ b/m4/ax_check_library.m4 @@ -0,0 +1,95 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_library.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LIBRARY(VARIABLE-PREFIX, HEADER-FILE, LIBRARY-FILE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND]) +# +# DESCRIPTION +# +# Provides a generic test for a given library, similar in concept to the +# PKG_CHECK_MODULES macro used by pkg-config. +# +# Most simplest libraries can be checked against simply through the +# presence of a header file and a library to link to. This macro allows to +# wrap around the test so that it doesn't have to be recreated each time. +# +# Rather than define --with-$LIBRARY arguments, it uses variables in the +# same way that PKG_CHECK_MODULES does. It doesn't, though, use the same +# names, since you shouldn't provide a value for LIBS or CFLAGS but rather +# for LDFLAGS and CPPFLAGS, to tell the linker and compiler where to find +# libraries and headers respectively. +# +# If the library is find, HAVE_PREFIX is defined, and in all cases +# PREFIX_LDFLAGS and PREFIX_CPPFLAGS are substituted. +# +# Example: +# +# AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event], [], +# [AC_MSG_ERROR([Unable to find libevent])]) +# +# LICENSE +# +# Copyright (c) 2012 Brian Aker +# Copyright (c) 2010 Diego Elio Petteno` +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AC_DEFUN([AX_CHECK_LIBRARY], + [AC_ARG_VAR($1[_CPPFLAGS],[C preprocessor flags for ]$1[ headers]) + AC_ARG_VAR($1[_LDFLAGS],[linker flags for ]$1[ libraries]) + + AC_CACHE_VAL(AS_TR_SH([ax_cv_have_]$1), + [AX_SAVE_FLAGS + + AS_IF([test "x$]$1[_CPPFLAGS" != "x"], + [CPPFLAGS="$CPPFLAGS $]$1[_CPPFLAGS"]) + + AS_IF([test "x$]$1[_LDFLAGS" != "x"], + [LDFLAGS="$LDFLAGS $]$1[_LDFLAGS"]) + + AC_CHECK_HEADER($2, [ + AC_CHECK_LIB($3, [main], + [AS_TR_SH([ax_cv_have_]$1)=yes], + [AS_TR_SH([ax_cv_have_]$1)=no]) + ], [AS_TR_SH([ax_cv_have_]$1)=no]) + + AX_RESTORE_FLAGS + ]) + + AS_IF([test "$]AS_TR_SH([ax_cv_have_]$1)[" = "yes"], + [AC_DEFINE([HAVE_]$1, [1], [Define to 1 if ]$1[ is found]) + AC_SUBST($1[_CPPFLAGS]) + AC_SUBST($1[_LDFLAGS]) + AC_SUBST($1[_LIB],[-l]$3) + ifelse([$4], , :, [$4])], + [ifelse([$5], , :, [$5])]) + ]) diff --git a/m4/ax_compiler_version.m4 b/m4/ax_compiler_version.m4 index 7f6708d5d..e074cf743 100644 --- a/m4/ax_compiler_version.m4 +++ b/m4/ax_compiler_version.m4 @@ -1,36 +1,100 @@ -AC_DEFUN([AX_C_COMPILER_VERSION],[ +# =========================================================================== +# https://github.com/BrianAker/ddm4/ +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_VERSION() +# +# DESCRIPTION +# +# Capture version of C/C++ compiler +# +# LICENSE +# +# Copyright (C) 2012 Brian Aker +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# +# * The names of its contributors may not be used to endorse or +# promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - dnl Print version of C compiler - AC_MSG_CHECKING("C Compiler version--$GCC") - AS_IF([test "$GCC" = "yes"],[ - CC_VERSION=`$CC --version | sed 1q` ],[ - test "$SUNCC" = "yes"],[ - CC_VERSION=`$CC -V 2>&1 | sed 1q` ],[ - test "$CLANG" = "yes"],[ - CC_VERSION=`$CC --version 2>&1 | sed 1q` ],[ - CC_VERSION="" - ]) - AC_MSG_RESULT("$CC_VERSION") - AC_SUBST(CC_VERSION) - ]) +#serial 5 +AC_DEFUN([_C_COMPILER_VERSION], + [AC_MSG_CHECKING([C Compiler version]) + AS_CASE(["$ax_cv_c_compiler_vendor"], + [sun],[ax_c_compiler_version=`$CC -V 2>&1 | sed 1q`], + [intel],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`], + [clang],[ax_c_compiler_version=`$CC --version 2>&1 | sed 1q`], + [gnu],[ax_c_compiler_version=`$CC --version | sed 1q`], + [mingw],[ax_c_compiler_version=`$CC --version | sed 1q`], + [ax_c_compiler_version="unknown: $ax_cv_c_compiler_vendor"]) -AC_DEFUN([AX_CXX_COMPILER_VERSION], [ - - dnl Check C version while at it - AC_REQUIRE([AX_C_COMPILER_VERSION]) - - dnl Print version of CXX compiler - AC_MSG_CHECKING("C++ Compiler version") - AS_IF([test "$GCC" = "yes"],[ - CXX_VERSION=`$CXX --version | sed 1q` ],[ - test "$SUNCC" = "yes"],[ - CXX_VERSION=`$CXX -V 2>&1 | sed 1q` ],[ - test "$CLANG" = "yes"],[ - CXX_VERSION=`$CXX --version 2>&1 | sed 1q` ],[ - CXX_VERSION="" - ]) - AC_MSG_RESULT("$CXX_VERSION") - AC_SUBST(CXX_VERSION) + AC_MSG_RESULT(["$ax_c_compiler_version"]) + AC_SUBST([CC_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"]) + AC_SUBST([CC_VERSION],["$ax_c_compiler_version"]) ]) +AC_DEFUN([_CXX_COMPILER_VERSION], + [AC_MSG_CHECKING([C++ Compiler version]) + + AS_CASE(["$ax_cv_c_compiler_vendor"], + [sun],[ax_cxx_compiler_version=`$CXX -V 2>&1 | sed 1q`], + [intel],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`], + [clang],[ax_cxx_compiler_version=`$CXX --version 2>&1 | sed 1q`], + [gnu],[ax_cxx_compiler_version=`$CXX --version | sed 1q`], + [mingw],[ax_cxx_compiler_version=`$CXX --version | sed 1q`], + [ax_cxx_compiler_version="unknown: $ax_cv_c_compiler_vendor"]) + + AC_MSG_RESULT(["$ax_cxx_compiler_version"]) + AC_SUBST([CXX_VERSION_VENDOR],["$ax_cv_c_compiler_vendor"]) + AC_SUBST([CXX_VERSION],["$ax_cxx_compiler_version"]) + ]) + +AC_DEFUN([AX_COMPILER_VERSION], + [AC_REQUIRE([AX_COMPILER_VENDOR]) + + AC_MSG_CHECKING([MINGW]) + AC_CHECK_DECL([__MINGW32__], + [MINGW=yes + ax_c_compiler_version_vendor=mingw], + [MINGW=no]) + AC_MSG_RESULT([$MINGW]) + + AC_REQUIRE([_C_COMPILER_VERSION]) + AC_REQUIRE([_CXX_COMPILER_VERSION]) + AS_IF([test "x$GCC" = xyes], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(__GNUC__) || (__GNUC__ < 4) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ < 7)) +# error GCC is Too Old! +#endif + ]])], + [ac_c_gcc_recent=yes], + [ac_c_gcc_recent=no]) + ]) + ]) diff --git a/m4/ax_debug.m4 b/m4/ax_debug.m4 index 5c63daa11..5522d7215 100644 --- a/m4/ax_debug.m4 +++ b/m4/ax_debug.m4 @@ -43,19 +43,22 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#serial 2 +#serial 6 -AC_DEFUN([AX_DEBUG],[ +AC_DEFUN([AX_DEBUG], + [AC_PREREQ([2.63])dnl AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], - [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],[ - ax_enable_debug=$enableval - AC_DEFINE(DEBUG, [ 1 ], [Define to 1 to enable debugging code.]) - ],[ - ax_enable_debug=no - AC_DEFINE(DEBUG, [ 0 ], [Define to 1 to enable debugging code.]) - ]) + [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])], + [ax_enable_debug=yes + AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.]) + AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])]) + AX_ADD_AM_MACRO([--debug],[AM_YFLAGS]) + AX_ADD_AM_MACRO([-D_GLIBCXX_DEBUG],[AM_CPPFLAGS])], + [ax_enable_debug=no + AC_SUBST([MCHECK]) + AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])]) AC_MSG_CHECKING([for debug]) AC_MSG_RESULT([$ax_enable_debug]) - ]) + AM_CONDITIONAL([DEBUG],[test "x${ax_enable_debug}" = "xyes"])]) diff --git a/m4/ax_harden_compiler_flags.m4 b/m4/ax_harden_compiler_flags.m4 index 2c225db58..6f01c1aca 100644 --- a/m4/ax_harden_compiler_flags.m4 +++ b/m4/ax_harden_compiler_flags.m4 @@ -67,7 +67,6 @@ AC_REQUIRE([AX_CHECK_LINK_FLAG]) AC_REQUIRE([AX_VCS_CHECKOUT]) AC_REQUIRE([AX_DEBUG]) - AC_REQUIRE([AX_CXX_COMPILER_VERSION]) dnl If we are inside of VCS we append -Werror, otherwise we just use it to test other flags AX_HARDEN_LIB= diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index 82ae1faf2..6d400ed4e 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -82,7 +82,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 19 +#serial 20 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -159,12 +159,8 @@ case ${host_os} in ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" ;; - darwin12* | darwin11.4*) - ax_pthread_flags="$ax_pthread_flags" - ;; - darwin*) - ax_pthread_flags="-pthreads $ax_pthread_flags" + ax_pthread_flags="-pthread $ax_pthread_flags" ;; esac @@ -287,16 +283,24 @@ if test "x$ax_pthread_ok" = xyes; then LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) - else - PTHREAD_CC=$CC + # More AIX lossage: compile with *_r variant + if test "x$GCC" != xyes; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + ;; + esac fi -else - PTHREAD_CC="$CC" fi +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) diff --git a/m4/ax_vcs_checkout.m4 b/m4/ax_vcs_checkout.m4 index 08bd37465..8047b65ec 100644 --- a/m4/ax_vcs_checkout.m4 +++ b/m4/ax_vcs_checkout.m4 @@ -45,15 +45,31 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#serial 1 - -AC_DEFUN([AX_VCS_CHECKOUT],[ - AC_CACHE_CHECK([for vcs checkout], [ac_cv_vcs_checkout], [ - AS_IF([test -d ".bzr"],[ac_cv_vcs_checkout=yes]) - AS_IF([test -d ".svn"],[ac_cv_vcs_checkout=yes]) - AS_IF([test -d ".hg"], [ac_cv_vcs_checkout=yes]) - AS_IF([test -d ".git"],[ac_cv_vcs_checkout=yes]) +#serial 6 + +AC_DEFUN([AX_VCS_SYSTEM], + [AC_PREREQ([2.63])dnl + AC_CACHE_CHECK([for vcs system], [ac_cv_vcs_system], + [ac_cv_vcs_system="none" + AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"]) + AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"]) + AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"]) + AS_IF([test -d ".git"],[ac_cv_vcs_system="git"]) + ]) + AC_DEFINE_UNQUOTED([VCS_SYSTEM],["$ac_cv_vcs_system"],[VCS system]) + ]) + +AC_DEFUN([AX_VCS_CHECKOUT], + [AC_PREREQ([2.63])dnl + AC_REQUIRE([AX_VCS_SYSTEM]) + AC_CACHE_CHECK([for vcs checkout],[ac_cv_vcs_checkout], + [AS_IF([test "x$ac_cv_vcs_system" != "xnone"], + [ac_cv_vcs_checkout=yes], + [ac_cv_vcs_checkout=no]) ]) - AS_IF([test "$ac_cv_vcs_checkout" = yes], []) + AM_CONDITIONAL([IS_VCS_CHECKOUT],[test "x$ac_cv_vcs_checkout" = "xyes"]) + AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"], + [AC_DEFINE([VCS_CHECKOUT],[1],[Define if the code was built from VCS.])], + [AC_DEFINE([VCS_CHECKOUT],[0],[Define if the code was built from VCS.])]) ])