From be080a402fc780c8211eb2117ddf0150cfd7a946 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Mon, 28 Mar 2016 19:59:35 +0000 Subject: [PATCH 1/7] Replace obsolete macros with modern equivalents --- acinclude.m4 | 18 +++++++++--------- configure.ac | 32 ++++++++++++++++---------------- m4/ax_check_sign.m4 | 4 ++-- m4/pc_from_ucontext.m4 | 20 ++++++++++---------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index ab1231713..bf39601ef 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -51,12 +51,12 @@ AC_DEFUN([TOR_TRY_COMPILE_WITH_CFLAGS], [ AC_CACHE_CHECK([whether the compiler accepts $1], VAR, [ tor_saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -pedantic -Werror $1" - AC_TRY_COMPILE([], [return 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [AS_VAR_SET(VAR,yes)], [AS_VAR_SET(VAR,no)]) if test x$2 != x; then AS_VAR_PUSHDEF([can_link],[tor_can_link_$1]) - AC_TRY_LINK([], [return 0;], + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [AS_VAR_SET(can_link,yes)], [AS_VAR_SET(can_link,no)]) AS_VAR_POPDEF([can_link]) @@ -93,7 +93,7 @@ AC_DEFUN([TOR_CHECK_LDFLAGS], [ AC_RUN_IFELSE([AC_LANG_PROGRAM([#include ], [fputs("", stdout)])], [AS_VAR_SET(VAR,yes)], [AS_VAR_SET(VAR,no)], - [AC_TRY_LINK([], [return 0;], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [AS_VAR_SET(VAR,yes)], [AS_VAR_SET(VAR,no)])]) CFLAGS="$tor_saved_CFLAGS" @@ -113,21 +113,21 @@ if test x$2 = xdevpkg; then h=" headers for" fi if test -f /etc/debian_version && test x"$tor_$1_$2_debian" != x; then - AC_WARN([On Debian, you can install$h $1 using "apt-get install $tor_$1_$2_debian"]) + AC_MSG_WARN([On Debian, you can install$h $1 using "apt-get install $tor_$1_$2_debian"]) if test x"$tor_$1_$2_debian" != x"$tor_$1_devpkg_debian"; then - AC_WARN([ You will probably need $tor_$1_devpkg_debian too.]) + AC_MSG_WARN([ You will probably need $tor_$1_devpkg_debian too.]) fi fi if test -f /etc/fedora-release && test x"$tor_$1_$2_redhat" != x; then - AC_WARN([On Fedora, you can install$h $1 using "dnf install $tor_$1_$2_redhat"]) + AC_MSG_WARN([On Fedora, you can install$h $1 using "dnf install $tor_$1_$2_redhat"]) if test x"$tor_$1_$2_redhat" != x"$tor_$1_devpkg_redhat"; then - AC_WARN([ You will probably need to install $tor_$1_devpkg_redhat too.]) + AC_MSG_WARN([ You will probably need to install $tor_$1_devpkg_redhat too.]) fi else if test -f /etc/redhat-release && test x"$tor_$1_$2_redhat" != x; then - AC_WARN([On most Redhat-based systems, you can get$h $1 by installing the $tor_$1_$2_redhat RPM package]) + AC_MSG_WARN([On most Redhat-based systems, you can get$h $1 by installing the $tor_$1_$2_redhat RPM package]) if test x"$tor_$1_$2_redhat" != x"$tor_$1_devpkg_redhat"; then - AC_WARN([ You will probably need to install $tor_$1_devpkg_redhat too.]) + AC_MSG_WARN([ You will probably need to install $tor_$1_devpkg_redhat too.]) fi fi fi diff --git a/configure.ac b/configure.ac index 721f5cd8c..b0fd73ef2 100644 --- a/configure.ac +++ b/configure.ac @@ -429,7 +429,7 @@ AC_CHECK_FUNCS( # checks. So we should only probe for those functions if we are sure that we # are not targetting OSX 10.11 or earlier. AC_MSG_CHECKING([for a pre-Sierra OSX build target]) -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __APPLE__ # include # ifndef MAC_OS_X_VERSION_10_12 @@ -441,7 +441,7 @@ AC_TRY_COMPILE([ # endif # endif #endif -], [], +]], [[]])], [on_macos_pre_10_12=no ; AC_MSG_RESULT([no])], [on_macos_pre_10_12=yes; AC_MSG_RESULT([yes])]) @@ -640,16 +640,16 @@ LIBS="$TOR_OPENSSL_LIBS $LIBS" LDFLAGS="$TOR_LDFLAGS_openssl $LDFLAGS" CPPFLAGS="$TOR_CPPFLAGS_openssl $CPPFLAGS" -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1000100fL #error "too old" #endif - ], [], + ]], [[]])], [ : ], - [ AC_ERROR([OpenSSL is too old. We require 1.0.1 or later. You can specify a path to a newer one with --with-openssl-dir.]) ]) + [ AC_MSG_ERROR([OpenSSL is too old. We require 1.0.1 or later. You can specify a path to a newer one with --with-openssl-dir.]) ]) -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #if defined(OPENSSL_NO_EC) || defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_ECDSA) @@ -658,9 +658,9 @@ AC_TRY_COMPILE([ #if !defined(NID_X9_62_prime256v1) || !defined(NID_secp224r1) #error "curves unavailable" #endif - ], [], + ]], [[]])], [ : ], - [ AC_ERROR([OpenSSL is built without full ECC support, including curves P256 and P224. You can specify a path to one with ECC support with --with-openssl-dir.]) ]) + [ AC_MSG_ERROR([OpenSSL is built without full ECC support, including curves P256 and P224. You can specify a path to one with ECC support with --with-openssl-dir.]) ]) AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , , [#include @@ -1465,9 +1465,9 @@ AC_CHECK_FUNC(gethostbyname_r, [ AC_MSG_CHECKING([how many arguments gethostbyname_r() wants]) OLD_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ], [[ + ]], [[ char *cp1, *cp2; struct hostent *h1, *h2; int i1, i2; @@ -1478,27 +1478,27 @@ AC_CHECK_FUNC(gethostbyname_r, [ [Define this if gethostbyname_r takes 6 arguments]) AC_MSG_RESULT(6) ], [ - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ], [ + ]], [[ char *cp1, *cp2; struct hostent *h1; int i1, i2; (void)gethostbyname_r(cp1,h1,cp2,i1,&i2); - ], [ + ]])], [ AC_DEFINE(HAVE_GETHOSTBYNAME_R) AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, [Define this if gethostbyname_r takes 5 arguments]) AC_MSG_RESULT(5) ], [ - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ], [ + ]], [[ char *cp1; struct hostent *h1; struct hostent_data hd; (void) gethostbyname_r(cp1,h1,&hd); - ], [ + ]])], [ AC_DEFINE(HAVE_GETHOSTBYNAME_R) AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, [Define this if gethostbyname_r takes 3 arguments]) diff --git a/m4/ax_check_sign.m4 b/m4/ax_check_sign.m4 index 104b17014..d67e114db 100644 --- a/m4/ax_check_sign.m4 +++ b/m4/ax_check_sign.m4 @@ -41,8 +41,8 @@ AU_ALIAS([VL_CHECK_SIGN], [AX_CHECK_SIGN]) AC_DEFUN([AX_CHECK_SIGN], [ typename=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g"` AC_CACHE_CHECK([whether $1 is signed], ax_cv_decl_${typename}_signed, [ - AC_TRY_COMPILE([$4], - [ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$4]], + [[ int foo @<:@ 1 - 2 * !((($1) -1) < 0) @:>@ ]])], [ eval "ax_cv_decl_${typename}_signed=\"yes\"" ], [ eval "ax_cv_decl_${typename}_signed=\"no\"" ])]) symbolname=`echo $1 | sed "s/@<:@^a-zA-Z0-9_@:>@/_/g" | tr "a-z" "A-Z"` diff --git a/m4/pc_from_ucontext.m4 b/m4/pc_from_ucontext.m4 index 8a9dc459e..9b66bf752 100644 --- a/m4/pc_from_ucontext.m4 +++ b/m4/pc_from_ucontext.m4 @@ -79,29 +79,29 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], if ! $pc_field_found; then # Prefer sys/ucontext.h to ucontext.h, for OS X's sake. if test "x$ac_cv_header_cygwin_signal_h" = xyes; then - AC_TRY_COMPILE([#include ], - [ucontext_t u; return u.$pc_field == 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ucontext_t u; return u.$pc_field == 0;]])], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) pc_field_found=true) elif test "x$ac_cv_header_sys_ucontext_h" = xyes; then - AC_TRY_COMPILE([#include ], - [ucontext_t u; return u.$pc_field == 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ucontext_t u; return u.$pc_field == 0;]])], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) pc_field_found=true) elif test "x$ac_cv_header_ucontext_h" = xyes; then - AC_TRY_COMPILE([#include ], - [ucontext_t u; return u.$pc_field == 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ucontext_t u; return u.$pc_field == 0;]])], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) pc_field_found=true) else # hope some standard header gives it to us - AC_TRY_COMPILE([], - [ucontext_t u; return u.$pc_field == 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], + [[ucontext_t u; return u.$pc_field == 0;]])], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) @@ -114,8 +114,8 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], pc_fields="$pc_fields sc_rip" # OpenBSD (x86_64) for pc_field in $pc_fields; do if ! $pc_field_found; then - AC_TRY_COMPILE([#include ], - [ucontext_t u; return u.$pc_field == 0;], + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ucontext_t u; return u.$pc_field == 0;]])], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) From ef2b7c8a9b99bbee2b4c8563fe35491783e95033 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Mon, 28 Mar 2016 20:29:19 +0000 Subject: [PATCH 2/7] Add a cross-compile action to AC_RUN_IFELSE --- acinclude.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index bf39601ef..193d3a7a0 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -245,7 +245,10 @@ if test "$cross_compiling" != yes; then LDFLAGS="$tor_tryextra $orig_LDFLAGS" fi AC_RUN_IFELSE([AC_LANG_PROGRAM([$5], [$6])], - [runnable=yes], [runnable=no]) + [runnable=yes], [runnable=no], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [runnable=yes], + [runnable=no])]) if test "$runnable" = yes; then tor_cv_library_$1_linker_option=$tor_tryextra break From dee0b869c9393ba2b0d84527be4ed606f320a236 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Thu, 15 Dec 2016 15:33:19 +0000 Subject: [PATCH 3/7] Use the Autoconf macro for finding sed The AC_PROG_SED macro was added in Autoconf 2.59b and the minimum supported Autoconf version is now 2.63 so we can safely assume it is available. --- configure.ac | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b0fd73ef2..130ec0964 100644 --- a/configure.ac +++ b/configure.ac @@ -194,14 +194,12 @@ AC_PROG_CC AC_PROG_CPP AC_PROG_MAKE_SET AC_PROG_RANLIB +AC_PROG_SED AC_ARG_VAR([PERL], [path to Perl binary]) AC_CHECK_PROGS([PERL], [perl]) AM_CONDITIONAL(USE_PERL, [test "x$ac_cv_prog_PERL" != "x"]) -dnl autoconf 2.59 appears not to support AC_PROG_SED -AC_CHECK_PROG([SED],[sed],[sed],[/bin/false]) - dnl check for asciidoc and a2x AC_PATH_PROG([ASCIIDOC], [asciidoc], none) AC_PATH_PROGS([A2X], [a2x a2x.py], none) From a1c0ebc3ebc49924fa38dd4f60d89204208aacc8 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Thu, 15 Dec 2016 16:15:42 +0000 Subject: [PATCH 4/7] Use AM_PROG_AR to improve portability Turning on warnings in Automake makes it complain about not using the AM_PROG_AR macro. The AM_PROG_AR macro is required when LIBRARIES or LTLIBRARIES is used. The macro looks for an archiver and wraps it in the ar-lib script which is automatically generated so Git should ignore it. It makes the custom check for 'ar' obsolete so it is removed. The AM_PROG_AR macro was added in Automake 1.11.2 thus the minimum Automake version is increased. --- .gitignore | 1 + configure.ac | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dc6738c07..ef3517569 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ uptime-*.json /Makefile /Makefile.in /aclocal.m4 +/ar-lib /autom4te.cache /build-stamp /compile diff --git a/configure.ac b/configure.ac index 130ec0964..44f7fe675 100644 --- a/configure.ac +++ b/configure.ac @@ -171,10 +171,7 @@ AC_ARG_ENABLE(libscrypt, AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt])) dnl check for the correct "ar" when cross-compiling -AN_MAKEVAR([AR], [AC_PROG_AR]) -AN_PROGRAM([ar], [AC_PROG_AR]) -AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [ar])]) -AC_PROG_AR +AM_PROG_AR dnl Check whether the above macro has settled for a simply named tool even dnl though we're cross compiling. We must do this before running AC_PROG_CC, From b4c95bb42a85d6c620b694d9eb03803ed3b4de2d Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Thu, 15 Dec 2016 17:02:30 +0000 Subject: [PATCH 5/7] Report errors when updating configuration files --- autogen.sh | 4 ++-- configure.ac | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autogen.sh b/autogen.sh index 8c43a9798..276dd4047 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,12 +1,12 @@ #!/bin/sh if [ -x "`which autoreconf 2>/dev/null`" ] ; then - opt="-if" + opt="-i -f -W all,error" for i in $@; do case "$i" in -v) - opt=$opt"v" + opt="${opt} -v" ;; esac done diff --git a/configure.ac b/configure.ac index 44f7fe675..3f64e1e66 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_CONFIG_MACRO_DIR([m4]) # "foreign" means we don't follow GNU package layout standards # "1.11" means we require automake version 1.11 or newer # "subdir-objects" means put .o files in the same directory as the .c files -AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects]) +AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects -Wall -Werror]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CONFIG_HEADERS([orconfig.h]) From 3a0639a64c9dfcbc2650ee48cc4b4048ff7f945a Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Fri, 16 Dec 2016 08:12:36 +0000 Subject: [PATCH 6/7] Add a changes file for ticket 20990 --- changes/ticket20990 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changes/ticket20990 diff --git a/changes/ticket20990 b/changes/ticket20990 new file mode 100644 index 000000000..3dbe44105 --- /dev/null +++ b/changes/ticket20990 @@ -0,0 +1,4 @@ + o Minor bugfixes (build): + - Replace obsolete Autoconf macros with their modern equivalent and + prevent similar issues in the future. Fixes bug 20990; bugfix on + 0.1.0.1-rc. From 114f57b23e0484fa0bac021095dff1d3f5a3c2ae Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 23 Dec 2016 10:44:34 -0500 Subject: [PATCH 7/7] Use the old replacement when AM_PROG_AR doesn't exist. --- configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 3f64e1e66..baf9f52c4 100644 --- a/configure.ac +++ b/configure.ac @@ -170,8 +170,15 @@ AC_ARG_ENABLE(seccomp, AC_ARG_ENABLE(libscrypt, AS_HELP_STRING(--disable-libscrypt, [do not attempt to use libscrypt])) -dnl check for the correct "ar" when cross-compiling -AM_PROG_AR +dnl check for the correct "ar" when cross-compiling. +dnl (AM_PROG_AR was new in automake 1.11.2, which we do not yet require, +dnl so kludge up a replacement for the case where it isn't there yet.) +m4_ifdef([AM_PROG_AR], + [AM_PROG_AR], + [AN_MAKEVAR([AR], [AC_PROG_AR]) + AN_PROGRAM([ar], [AC_PROG_AR]) + AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL([AR], [ar], [:])]) + AC_PROG_AR]) dnl Check whether the above macro has settled for a simply named tool even dnl though we're cross compiling. We must do this before running AC_PROG_CC,