summaryrefslogtreecommitdiff
path: root/libtorrent-rasterbar/libtorrent-rasterbar-cxx14-fix.patch
blob: 85c3288ef42fd792d6005d93052bc46fdac6c0dd (plain)
    1 From ec286b37283a2bc03cf8b0b6ae72e920265eb754 Mon Sep 17 00:00:00 2001
    2 From: Nam Nguyen <namn@berkeley.edu>
    3 Date: Fri, 21 Aug 2020 09:01:40 +0000
    4 Subject: [PATCH 01/10] Use ax_cxx_compile_stdcxx.m4 and move to c++14 Use
    5  ax_cxx_compile_stdcxx.m4 instead of ax_cxx_compile_stdcxx_11.m4. Use c++14
    6  instead of c++11.
    7 
    8 ---
    9  configure.ac | 3 +--
   10  1 file changed, 1 insertion(+), 2 deletions(-)
   11 
   12 diff --git a/configure.ac b/configure.ac
   13 index 0b9b0c446b..c037607874 100644
   14 --- a/configure.ac
   15 +++ b/configure.ac
   16 @@ -143,8 +143,7 @@ AS_ECHO
   17  AS_ECHO "Checking for boost libraries:"
   18  
   19  AX_BOOST_BASE([1.58])
   20 -
   21 -AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
   22 +AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
   23  
   24  AX_BOOST_SYSTEM()
   25  AS_IF([test -z "$BOOST_SYSTEM_LIB"],
   26 
   27 From a9012add4018381ce50b83a81980b2fd7831606b Mon Sep 17 00:00:00 2001
   28 From: Nam Nguyen <namn@berkeley.edu>
   29 Date: Fri, 21 Aug 2020 21:35:37 +0000
   30 Subject: [PATCH 02/10] add --with-std=c++14 configure switch --with-std=c++14
   31  allows the user to specify what C++ standard to use. It supports
   32  {c,gnu}++{11,14,17}. If unspecified the default is c++11. Either
   33  AX_CXX_COMPILE_STDCXX_11 or AX_CXX_COMPILE_STDCXX are called appropriately.
   34 
   35 ---
   36  configure.ac | 37 ++++++++++++++++++++++++++++++++++++-
   37  1 file changed, 36 insertions(+), 1 deletion(-)
   38 
   39 diff --git a/configure.ac b/configure.ac
   40 index c037607874..c7ee9b8edd 100644
   41 --- a/configure.ac
   42 +++ b/configure.ac
   43 @@ -143,7 +143,41 @@ AS_ECHO
   44  AS_ECHO "Checking for boost libraries:"
   45  
   46  AX_BOOST_BASE([1.58])
   47 -AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
   48 +
   49 +AC_ARG_WITH(
   50 +  [std],
   51 +  [AS_HELP_STRING(
   52 +    [--with-std[=ARG]],
   53 +    [specify C++ standard (e.g., c++14 or gnu++11) [default=c++11]])],
   54 +  [[ARG_STD=$withval]],
   55 +  [[ARG_STD=c++11]]
   56 +)
   57 +
   58 +AC_MSG_CHECKING([which c++ standard to use])
   59 +AS_CASE(["$ARG_STD"],
   60 +  ["c++17"|"C++17"], [
   61 +      AC_MSG_RESULT([-std=c++17])
   62 +      AX_CXX_COMPILE_STDCXX(17, [noext], [mandatory])
   63 +    ],
   64 +  ["gnu++17"], [
   65 +      AC_MSG_RESULT([-std=gnu++17])
   66 +      AX_CXX_COMPILE_STDCXX(17, [ext], [mandatory])
   67 +    ],
   68 +  ["c++14"|"C++14"], [
   69 +      AC_MSG_RESULT([-std=c++14])
   70 +      AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
   71 +    ],
   72 +  [gnu++14], [
   73 +      AC_MSG_RESULT([-std=gnu++14])
   74 +      AX_CXX_COMPILE_STDCXX(14, [ext], [mandatory])
   75 +    ],
   76 +  [gnu++11], [
   77 +      AC_MSG_RESULT([-std=gnu++11])
   78 +      AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
   79 +    ],
   80 +  [AC_MSG_RESULT([-std=c++11])
   81 +   AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])]
   82 +)
   83  
   84  AX_BOOST_SYSTEM()
   85  AS_IF([test -z "$BOOST_SYSTEM_LIB"],
   86 @@ -589,6 +623,7 @@ Build options:
   87    debug build:          ${ARG_ENABLE_DEBUG:-no}
   88    invariant checks:     ${ARG_ENABLE_INVARIANT:-no}
   89    logging support:      ${ARG_ENABLE_LOGGING:-yes}
   90 +  with std:             ${ARG_STD:-c++11}
   91  
   92  Features:
   93    encryption support:   ${ARG_ENABLE_ENCRYPTION:-yes}
   94 
   95 From bca36cdcce209d1dfb473eab2e049ccf29b8a72e Mon Sep 17 00:00:00 2001
   96 From: Nam Nguyen <namn@berkeley.edu>
   97 Date: Fri, 21 Aug 2020 21:53:20 +0000
   98 Subject: [PATCH 03/10] add quotes
   99 
  100 ---
  101  configure.ac | 4 ++--
  102  1 file changed, 2 insertions(+), 2 deletions(-)
  103 
  104 diff --git a/configure.ac b/configure.ac
  105 index c7ee9b8edd..ba9b02106a 100644
  106 --- a/configure.ac
  107 +++ b/configure.ac
  108 @@ -167,11 +167,11 @@ AS_CASE(["$ARG_STD"],
  109        AC_MSG_RESULT([-std=c++14])
  110        AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
  111      ],
  112 -  [gnu++14], [
  113 +  ["gnu++14"], [
  114        AC_MSG_RESULT([-std=gnu++14])
  115        AX_CXX_COMPILE_STDCXX(14, [ext], [mandatory])
  116      ],
  117 -  [gnu++11], [
  118 +  ["gnu++11"], [
  119        AC_MSG_RESULT([-std=gnu++11])
  120        AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
  121      ],
  122 
  123 From bf6ed65a4068071a6b8565128f8cebd3f29fef55 Mon Sep 17 00:00:00 2001
  124 From: Nam Nguyen <namn@berkeley.edu>
  125 Date: Fri, 21 Aug 2020 23:07:08 +0000
  126 Subject: [PATCH 04/10] capitalization
  127 
  128 ---
  129  configure.ac | 2 +-
  130  1 file changed, 1 insertion(+), 1 deletion(-)
  131 
  132 diff --git a/configure.ac b/configure.ac
  133 index ba9b02106a..6ea4a4fde2 100644
  134 --- a/configure.ac
  135 +++ b/configure.ac
  136 @@ -153,7 +153,7 @@ AC_ARG_WITH(
  137    [[ARG_STD=c++11]]
  138  )
  139  
  140 -AC_MSG_CHECKING([which c++ standard to use])
  141 +AC_MSG_CHECKING([which C++ standard to use])
  142  AS_CASE(["$ARG_STD"],
  143    ["c++17"|"C++17"], [
  144        AC_MSG_RESULT([-std=c++17])
  145 
  146 From feb65af2bd7db89af0ad5ef57dfd669591742bb4 Mon Sep 17 00:00:00 2001
  147 From: Nam Nguyen <namn@berkeley.edu>
  148 Date: Sat, 22 Aug 2020 08:51:12 +0000
  149 Subject: [PATCH 05/10] add --with-cxx-standard=14 configure switch C++
  150  standard is specified by 11, 14 or 17. Either AX_CXX_COMPILE_STDCXX_11 or
  151  AX_CXX_COMPILE_STDCXX are called appropriately.
  152 
  153 ---
  154  configure.ac                | 64 ++++++++++++++++++++-----------------
  155  m4/ax_cxx_compile_stdcxx.m4 | 36 ++++++++++++---------
  156  2 files changed, 55 insertions(+), 45 deletions(-)
  157 
  158 diff --git a/configure.ac b/configure.ac
  159 index 6ea4a4fde2..2f0a4326f2 100644
  160 --- a/configure.ac
  161 +++ b/configure.ac
  162 @@ -145,39 +145,43 @@ AS_ECHO "Checking for boost libraries:"
  163  AX_BOOST_BASE([1.58])
  164  
  165  AC_ARG_WITH(
  166 -  [std],
  167 +  [cxx-standard],
  168    [AS_HELP_STRING(
  169 -    [--with-std[=ARG]],
  170 -    [specify C++ standard (e.g., c++14 or gnu++11) [default=c++11]])],
  171 -  [[ARG_STD=$withval]],
  172 -  [[ARG_STD=c++11]]
  173 +    [--with-cxx-std[=ARG]],
  174 +    [specify C++ standard (e.g., 11, 14 or 17) [default=11]])],
  175 +  [[ARG_CXX_STANDARD=$withval]],
  176 +  [[ARG_CXX_STANDARD=reverting to compiler default]]
  177  )
  178  
  179  AC_MSG_CHECKING([which C++ standard to use])
  180 -AS_CASE(["$ARG_STD"],
  181 -  ["c++17"|"C++17"], [
  182 -      AC_MSG_RESULT([-std=c++17])
  183 -      AX_CXX_COMPILE_STDCXX(17, [noext], [mandatory])
  184 -    ],
  185 -  ["gnu++17"], [
  186 -      AC_MSG_RESULT([-std=gnu++17])
  187 -      AX_CXX_COMPILE_STDCXX(17, [ext], [mandatory])
  188 -    ],
  189 -  ["c++14"|"C++14"], [
  190 -      AC_MSG_RESULT([-std=c++14])
  191 -      AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
  192 -    ],
  193 -  ["gnu++14"], [
  194 -      AC_MSG_RESULT([-std=gnu++14])
  195 -      AX_CXX_COMPILE_STDCXX(14, [ext], [mandatory])
  196 -    ],
  197 -  ["gnu++11"], [
  198 -      AC_MSG_RESULT([-std=gnu++11])
  199 -      AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
  200 -    ],
  201 -  [AC_MSG_RESULT([-std=c++11])
  202 -   AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])]
  203 -)
  204 +if test "x${ARG_CXX_STANDARD}" = "x17" ; then
  205 +  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [setcxx])
  206 +elif test "x${ARG_CXX_STANDARD}" = "x14" ; then
  207 +  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [setcxx])
  208 +elif test "x${ARG_CXX_STANDARD}" = "x11" ; then
  209 +  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [setcxx])
  210 +else
  211 +  dnl nothing specified so use compiler's default C++ dialect
  212 +  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [])
  213 +  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [])
  214 +  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [])
  215 +  if test "x${HAVE_CXX17}" = "x1" ; then
  216 +    CXX="$CXX -std=c++17"
  217 +    if test -n "$CXXCPP" ; then
  218 +      CXXCPP="$CXXCPP -std=c++17"
  219 +    fi
  220 +  elif test "x${HAVE_CXX14}" = "x1" ; then
  221 +    CXX="$CXX -std=c++14"
  222 +    if test -n "$CXXCPP" ; then
  223 +      CXXCPP="$CXXCPP -std=c++14"
  224 +    fi
  225 +  else
  226 +    CXX="$CXX -std=c++11"
  227 +    if test -n "$CXXCPP" ; then
  228 +      CXXCPP="$CXXCPP -std=c++11"
  229 +    fi
  230 +  fi
  231 +fi
  232  
  233  AX_BOOST_SYSTEM()
  234  AS_IF([test -z "$BOOST_SYSTEM_LIB"],
  235 @@ -623,7 +627,7 @@ Build options:
  236    debug build:          ${ARG_ENABLE_DEBUG:-no}
  237    invariant checks:     ${ARG_ENABLE_INVARIANT:-no}
  238    logging support:      ${ARG_ENABLE_LOGGING:-yes}
  239 -  with std:             ${ARG_STD:-c++11}
  240 +  with std:             ${ARG_CXX_STANDARD:-default}
  241  
  242  Features:
  243    encryption support:   ${ARG_ENABLE_ENCRYPTION:-yes}
  244 diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4
  245 index 43087b2e68..69989d59d7 100644
  246 --- a/m4/ax_cxx_compile_stdcxx.m4
  247 +++ b/m4/ax_cxx_compile_stdcxx.m4
  248 @@ -4,7 +4,7 @@
  249  #
  250  # SYNOPSIS
  251  #
  252 -#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
  253 +#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional], [setcxx])
  254  #
  255  # DESCRIPTION
  256  #
  257 @@ -25,6 +25,12 @@
  258  #   regardless, after defining HAVE_CXX${VERSION} if and only if a
  259  #   supporting mode is found.
  260  #
  261 +#   The fourth argument, if left unspecified, skips over setting the various
  262 +#   -std combinations and skips over setting CXX and CXXCPP. If specified
  263 +#   'setcxx' it will restore the default behavior. This argument is augmented
  264 +#   for libtorrent-rasterbar and does not exist in the stock m4 interface.
  265 +#   Skipping over setting CXX is useful for detecting the default C++ dialect.
  266 +#
  267  # LICENSE
  268  #
  269  #   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
  270 @@ -69,17 +75,17 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  271        cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  272        AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  273                       $cachevar,
  274 -        [ac_save_CXX="$CXX"
  275 -         CXX="$CXX $switch"
  276 +        [ifelse([$4], [setcxx], [ac_save_CXX="$CXX" CXX="$CXX $switch"], [])
  277           AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  278            [eval $cachevar=yes],
  279            [eval $cachevar=no])
  280 -         CXX="$ac_save_CXX"])
  281 +         ifelse([$4], [setcxx], [CXX="$ac_save_CXX"], [])])
  282        if eval test x\$$cachevar = xyes; then
  283 -        CXX="$CXX $switch"
  284 -        if test -n "$CXXCPP" ; then
  285 -          CXXCPP="$CXXCPP $switch"
  286 -        fi
  287 +	ifelse([$4], [setcxx],
  288 +               [CXX="$CXX $switch"
  289 +               if test -n "$CXXCPP" ; then
  290 +                 CXXCPP="$CXXCPP $switch"
  291 +               fi], [])
  292          ac_success=yes
  293          break
  294        fi
  295 @@ -96,17 +102,17 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  296          cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  297          AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  298                         $cachevar,
  299 -          [ac_save_CXX="$CXX"
  300 -           CXX="$CXX $switch"
  301 +          [ifelse([$4], [setcxx], [ac_save_CXX="$CXX" CXX="$CXX $switch"], [])
  302             AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  303              [eval $cachevar=yes],
  304              [eval $cachevar=no])
  305 -           CXX="$ac_save_CXX"])
  306 +           ifelse([$4], [setcxx], [CXX="$ac_save_CXX"], [])])
  307          if eval test x\$$cachevar = xyes; then
  308 -          CXX="$CXX $switch"
  309 -          if test -n "$CXXCPP" ; then
  310 -            CXXCPP="$CXXCPP $switch"
  311 -          fi
  312 +	  ifelse([$4], [setcxx],
  313 +               [CXX="$CXX $switch"
  314 +               if test -n "$CXXCPP" ; then
  315 +                 CXXCPP="$CXXCPP $switch"
  316 +               fi], [])
  317            ac_success=yes
  318            break
  319          fi
  320 
  321 From e7aeeaabd0ec6f623fd94d348e6db9312cb727c2 Mon Sep 17 00:00:00 2001
  322 From: Nam Nguyen <namn@berkeley.edu>
  323 Date: Sat, 22 Aug 2020 09:29:12 +0000
  324 Subject: [PATCH 06/10] typo with naming
  325 
  326 ---
  327  configure.ac | 2 +-
  328  1 file changed, 1 insertion(+), 1 deletion(-)
  329 
  330 diff --git a/configure.ac b/configure.ac
  331 index 2f0a4326f2..7e48078a7c 100644
  332 --- a/configure.ac
  333 +++ b/configure.ac
  334 @@ -147,7 +147,7 @@ AX_BOOST_BASE([1.58])
  335  AC_ARG_WITH(
  336    [cxx-standard],
  337    [AS_HELP_STRING(
  338 -    [--with-cxx-std[=ARG]],
  339 +    [--with-cxx-standard[=ARG]],
  340      [specify C++ standard (e.g., 11, 14 or 17) [default=11]])],
  341    [[ARG_CXX_STANDARD=$withval]],
  342    [[ARG_CXX_STANDARD=reverting to compiler default]]
  343 
  344 From 9b45e622d4a815d31f50f5e4fba6e4316fe14272 Mon Sep 17 00:00:00 2001
  345 From: Nam Nguyen <namn@berkeley.edu>
  346 Date: Sat, 22 Aug 2020 20:55:20 +0000
  347 Subject: [PATCH 07/10] invert behavior and be explicit with 'skip' argument
  348  The 4th argument left unspecified means default behavior. 'skip' means to
  349  skip setting CXX as should be done when detecting the default compiler.
  350 
  351 ---
  352  configure.ac                | 12 ++++++------
  353  m4/ax_cxx_compile_stdcxx.m4 | 39 +++++++++++++++++++++----------------
  354  2 files changed, 28 insertions(+), 23 deletions(-)
  355 
  356 diff --git a/configure.ac b/configure.ac
  357 index 7e48078a7c..59b0d6603b 100644
  358 --- a/configure.ac
  359 +++ b/configure.ac
  360 @@ -155,16 +155,16 @@ AC_ARG_WITH(
  361  
  362  AC_MSG_CHECKING([which C++ standard to use])
  363  if test "x${ARG_CXX_STANDARD}" = "x17" ; then
  364 -  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [setcxx])
  365 +  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [])
  366  elif test "x${ARG_CXX_STANDARD}" = "x14" ; then
  367 -  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [setcxx])
  368 +  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [])
  369  elif test "x${ARG_CXX_STANDARD}" = "x11" ; then
  370 -  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [setcxx])
  371 +  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [])
  372  else
  373    dnl nothing specified so use compiler's default C++ dialect
  374 -  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [])
  375 -  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [])
  376 -  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [])
  377 +  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [skip])
  378 +  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [skip])
  379 +  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [skip])
  380    if test "x${HAVE_CXX17}" = "x1" ; then
  381      CXX="$CXX -std=c++17"
  382      if test -n "$CXXCPP" ; then
  383 diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4
  384 index 69989d59d7..50859df211 100644
  385 --- a/m4/ax_cxx_compile_stdcxx.m4
  386 +++ b/m4/ax_cxx_compile_stdcxx.m4
  387 @@ -4,7 +4,7 @@
  388  #
  389  # SYNOPSIS
  390  #
  391 -#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional], [setcxx])
  392 +#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional], [skip])
  393  #
  394  # DESCRIPTION
  395  #
  396 @@ -25,11 +25,11 @@
  397  #   regardless, after defining HAVE_CXX${VERSION} if and only if a
  398  #   supporting mode is found.
  399  #
  400 -#   The fourth argument, if left unspecified, skips over setting the various
  401 -#   -std combinations and skips over setting CXX and CXXCPP. If specified
  402 -#   'setcxx' it will restore the default behavior. This argument is augmented
  403 -#   for libtorrent-rasterbar and does not exist in the stock m4 interface.
  404 -#   Skipping over setting CXX is useful for detecting the default C++ dialect.
  405 +#   The fourth argument, if left unspecified, does the default behavior. If
  406 +#   specified 'skip', it skips over setting the various -std combinations
  407 +#   and skips over setting CXX and CXXCPP. This argument is augmented for
  408 +#   libtorrent-rasterbar and does not exist in the stock m4 interface.
  409 +#   Skipping is useful for detecting the default C++ dialect.
  410  #
  411  # LICENSE
  412  #
  413 @@ -65,6 +65,9 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  414          [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
  415          [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
  416          [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
  417 +  m4_if([$4], [], [],
  418 +        [$4], [skip], [],
  419 +        [m4_fatal([invalid second argument `$4' to AX_CXX_COMPILE_STDCXX])])dnl
  420    AC_LANG_PUSH([C++])dnl
  421    ac_success=no
  422  
  423 @@ -75,17 +78,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  424        cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  425        AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  426                       $cachevar,
  427 -        [ifelse([$4], [setcxx], [ac_save_CXX="$CXX" CXX="$CXX $switch"], [])
  428 +        [ifelse([$4], [skip], [], [ac_save_CXX="$CXX" CXX="$CXX $switch"])
  429           AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  430            [eval $cachevar=yes],
  431            [eval $cachevar=no])
  432 -         ifelse([$4], [setcxx], [CXX="$ac_save_CXX"], [])])
  433 +         ifelse([$4], [skip], [], [CXX="$ac_save_CXX"])])
  434        if eval test x\$$cachevar = xyes; then
  435 -	ifelse([$4], [setcxx],
  436 +	ifelse([$4], [skip],
  437 +	       [],
  438                 [CXX="$CXX $switch"
  439                 if test -n "$CXXCPP" ; then
  440                   CXXCPP="$CXXCPP $switch"
  441 -               fi], [])
  442 +               fi])
  443          ac_success=yes
  444          break
  445        fi
  446 @@ -102,17 +106,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  447          cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  448          AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  449                         $cachevar,
  450 -          [ifelse([$4], [setcxx], [ac_save_CXX="$CXX" CXX="$CXX $switch"], [])
  451 +          [ifelse([$4], [skip], [], [ac_save_CXX="$CXX" CXX="$CXX $switch"])
  452             AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  453              [eval $cachevar=yes],
  454              [eval $cachevar=no])
  455 -           ifelse([$4], [setcxx], [CXX="$ac_save_CXX"], [])])
  456 +           ifelse([$4], [skip], [], [CXX="$ac_save_CXX"])])
  457          if eval test x\$$cachevar = xyes; then
  458 -	  ifelse([$4], [setcxx],
  459 -               [CXX="$CXX $switch"
  460 -               if test -n "$CXXCPP" ; then
  461 -                 CXXCPP="$CXXCPP $switch"
  462 -               fi], [])
  463 +	  ifelse([$4], [skip],
  464 +	         [],
  465 +                 [CXX="$CXX $switch"
  466 +                 if test -n "$CXXCPP" ; then
  467 +                   CXXCPP="$CXXCPP $switch"
  468 +                 fi])
  469            ac_success=yes
  470            break
  471          fi
  472 
  473 From 9c0a31ffb974a11a3ea00f96cfe45616cf75bcf4 Mon Sep 17 00:00:00 2001
  474 From: Nam Nguyen <namn@berkeley.edu>
  475 Date: Fri, 25 Sep 2020 09:30:52 +0000
  476 Subject: [PATCH 08/10] revert ax_cxx_compile_stdcxx.m4 to default
  477 
  478 ---
  479  configure.ac                | 53 ++++++++++++++++++++-----------------
  480  m4/ax_cxx_compile_stdcxx.m4 | 41 +++++++++++-----------------
  481  2 files changed, 44 insertions(+), 50 deletions(-)
  482 
  483 diff --git a/configure.ac b/configure.ac
  484 index 59b0d6603b..b7eee17d99 100644
  485 --- a/configure.ac
  486 +++ b/configure.ac
  487 @@ -150,36 +150,41 @@ AC_ARG_WITH(
  488      [--with-cxx-standard[=ARG]],
  489      [specify C++ standard (e.g., 11, 14 or 17) [default=11]])],
  490    [[ARG_CXX_STANDARD=$withval]],
  491 -  [[ARG_CXX_STANDARD=reverting to compiler default]]
  492 +  [[ARG_CXX_STANDARD=default]]
  493  )
  494  
  495 -AC_MSG_CHECKING([which C++ standard to use])
  496 +AC_MSG_CHECKING([which c++ standard to use])
  497  if test "x${ARG_CXX_STANDARD}" = "x17" ; then
  498 -  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [])
  499 +  AX_CXX_COMPILE_STDCXX(17, [noext], [optional])
  500  elif test "x${ARG_CXX_STANDARD}" = "x14" ; then
  501 -  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [])
  502 +  AX_CXX_COMPILE_STDCXX(14, [noext], [optional])
  503  elif test "x${ARG_CXX_STANDARD}" = "x11" ; then
  504 -  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [])
  505 +  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  506 +elif test "${ARG_CXX_STANDARD}" -lt "11" ; then
  507 +  dnl force 11 if user specified out of bounds, regardless of compiler default
  508 +  ARG_CXX_STANDARD="11"
  509 +  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  510 +elif test "${ARG_CXX_STANDARD}" -gt "17" ; then
  511 +  dnl force 11 if user specified out of bounds, regardless of compiler default
  512 +  ARG_CXX_STANDARD="11"
  513 +  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  514  else
  515 -  dnl nothing specified so use compiler's default C++ dialect
  516 -  AX_CXX_COMPILE_STDCXX(17, [noext], [optional], [skip])
  517 -  AX_CXX_COMPILE_STDCXX(14, [noext], [optional], [skip])
  518 -  AX_CXX_COMPILE_STDCXX(11, [noext], [optional], [skip])
  519 -  if test "x${HAVE_CXX17}" = "x1" ; then
  520 -    CXX="$CXX -std=c++17"
  521 -    if test -n "$CXXCPP" ; then
  522 -      CXXCPP="$CXXCPP -std=c++17"
  523 -    fi
  524 -  elif test "x${HAVE_CXX14}" = "x1" ; then
  525 -    CXX="$CXX -std=c++14"
  526 -    if test -n "$CXXCPP" ; then
  527 -      CXXCPP="$CXXCPP -std=c++14"
  528 -    fi
  529 +  dnl nothing specified so use compiler default
  530 +
  531 +  echo '#include <iostream>' > cpp_standard.cpp
  532 +  echo 'using std::cout; using std::endl; int main() { switch (__cplusplus) { case 201103L: cout << 11 << endl; break; case 201402L: cout << 14 << endl; break; case 201703L: cout << 17 << endl; break; default: cout << 1 << endl; } }' >> cpp_standard.cpp
  533 +  ${CXX} cpp_standard.cpp -o cpp_standard
  534 +  DEFAULT_CXX_STANDARD=`./cpp_standard`
  535 +  echo $DEFAULT_CXX_STANDARD
  536 +  if test "x${DEFAULT_CXX_STANDARD}" = "x17" ; then
  537 +    ARG_CXX_STANDARD="17"
  538 +    AX_CXX_COMPILE_STDCXX(17, [noext], [optional])
  539 +  elif test "x${DEFAULT_CXX_STANDARD}" = "x14" ; then
  540 +    ARG_CXX_STANDARD="14"
  541 +    AX_CXX_COMPILE_STDCXX(14, [noext], [optional])
  542    else
  543 -    CXX="$CXX -std=c++11"
  544 -    if test -n "$CXXCPP" ; then
  545 -      CXXCPP="$CXXCPP -std=c++11"
  546 -    fi
  547 +    ARG_CXX_STANDARD="11"
  548 +    AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  549    fi
  550  fi
  551  
  552 @@ -627,7 +632,7 @@ Build options:
  553    debug build:          ${ARG_ENABLE_DEBUG:-no}
  554    invariant checks:     ${ARG_ENABLE_INVARIANT:-no}
  555    logging support:      ${ARG_ENABLE_LOGGING:-yes}
  556 -  with std:             ${ARG_CXX_STANDARD:-default}
  557 +  cxx standard:         ${ARG_CXX_STANDARD:-default}
  558  
  559  Features:
  560    encryption support:   ${ARG_ENABLE_ENCRYPTION:-yes}
  561 diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4
  562 index 50859df211..43087b2e68 100644
  563 --- a/m4/ax_cxx_compile_stdcxx.m4
  564 +++ b/m4/ax_cxx_compile_stdcxx.m4
  565 @@ -4,7 +4,7 @@
  566  #
  567  # SYNOPSIS
  568  #
  569 -#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional], [skip])
  570 +#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
  571  #
  572  # DESCRIPTION
  573  #
  574 @@ -25,12 +25,6 @@
  575  #   regardless, after defining HAVE_CXX${VERSION} if and only if a
  576  #   supporting mode is found.
  577  #
  578 -#   The fourth argument, if left unspecified, does the default behavior. If
  579 -#   specified 'skip', it skips over setting the various -std combinations
  580 -#   and skips over setting CXX and CXXCPP. This argument is augmented for
  581 -#   libtorrent-rasterbar and does not exist in the stock m4 interface.
  582 -#   Skipping is useful for detecting the default C++ dialect.
  583 -#
  584  # LICENSE
  585  #
  586  #   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
  587 @@ -65,9 +59,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  588          [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
  589          [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
  590          [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
  591 -  m4_if([$4], [], [],
  592 -        [$4], [skip], [],
  593 -        [m4_fatal([invalid second argument `$4' to AX_CXX_COMPILE_STDCXX])])dnl
  594    AC_LANG_PUSH([C++])dnl
  595    ac_success=no
  596  
  597 @@ -78,18 +69,17 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  598        cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  599        AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  600                       $cachevar,
  601 -        [ifelse([$4], [skip], [], [ac_save_CXX="$CXX" CXX="$CXX $switch"])
  602 +        [ac_save_CXX="$CXX"
  603 +         CXX="$CXX $switch"
  604           AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  605            [eval $cachevar=yes],
  606            [eval $cachevar=no])
  607 -         ifelse([$4], [skip], [], [CXX="$ac_save_CXX"])])
  608 +         CXX="$ac_save_CXX"])
  609        if eval test x\$$cachevar = xyes; then
  610 -	ifelse([$4], [skip],
  611 -	       [],
  612 -               [CXX="$CXX $switch"
  613 -               if test -n "$CXXCPP" ; then
  614 -                 CXXCPP="$CXXCPP $switch"
  615 -               fi])
  616 +        CXX="$CXX $switch"
  617 +        if test -n "$CXXCPP" ; then
  618 +          CXXCPP="$CXXCPP $switch"
  619 +        fi
  620          ac_success=yes
  621          break
  622        fi
  623 @@ -106,18 +96,17 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  624          cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
  625          AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
  626                         $cachevar,
  627 -          [ifelse([$4], [skip], [], [ac_save_CXX="$CXX" CXX="$CXX $switch"])
  628 +          [ac_save_CXX="$CXX"
  629 +           CXX="$CXX $switch"
  630             AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
  631              [eval $cachevar=yes],
  632              [eval $cachevar=no])
  633 -           ifelse([$4], [skip], [], [CXX="$ac_save_CXX"])])
  634 +           CXX="$ac_save_CXX"])
  635          if eval test x\$$cachevar = xyes; then
  636 -	  ifelse([$4], [skip],
  637 -	         [],
  638 -                 [CXX="$CXX $switch"
  639 -                 if test -n "$CXXCPP" ; then
  640 -                   CXXCPP="$CXXCPP $switch"
  641 -                 fi])
  642 +          CXX="$CXX $switch"
  643 +          if test -n "$CXXCPP" ; then
  644 +            CXXCPP="$CXXCPP $switch"
  645 +          fi
  646            ac_success=yes
  647            break
  648          fi
  649 
  650 From 49b4683f484271e394612b80331af39c5a0c36c5 Mon Sep 17 00:00:00 2001
  651 From: Nam Nguyen <namn@berkeley.edu>
  652 Date: Fri, 25 Sep 2020 23:54:23 +0000
  653 Subject: [PATCH 09/10] mandatory
  654 
  655 ---
  656  configure.ac | 16 ++++++++--------
  657  1 file changed, 8 insertions(+), 8 deletions(-)
  658 
  659 diff --git a/configure.ac b/configure.ac
  660 index b7eee17d99..29c237fa8b 100644
  661 --- a/configure.ac
  662 +++ b/configure.ac
  663 @@ -155,19 +155,19 @@ AC_ARG_WITH(
  664  
  665  AC_MSG_CHECKING([which c++ standard to use])
  666  if test "x${ARG_CXX_STANDARD}" = "x17" ; then
  667 -  AX_CXX_COMPILE_STDCXX(17, [noext], [optional])
  668 +  AX_CXX_COMPILE_STDCXX(17, [noext], [mandatory])
  669  elif test "x${ARG_CXX_STANDARD}" = "x14" ; then
  670 -  AX_CXX_COMPILE_STDCXX(14, [noext], [optional])
  671 +  AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
  672  elif test "x${ARG_CXX_STANDARD}" = "x11" ; then
  673 -  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  674 +  AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  675  elif test "${ARG_CXX_STANDARD}" -lt "11" ; then
  676    dnl force 11 if user specified out of bounds, regardless of compiler default
  677    ARG_CXX_STANDARD="11"
  678 -  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  679 +  AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  680  elif test "${ARG_CXX_STANDARD}" -gt "17" ; then
  681    dnl force 11 if user specified out of bounds, regardless of compiler default
  682    ARG_CXX_STANDARD="11"
  683 -  AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  684 +  AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  685  else
  686    dnl nothing specified so use compiler default
  687  
  688 @@ -178,13 +178,13 @@ else
  689    echo $DEFAULT_CXX_STANDARD
  690    if test "x${DEFAULT_CXX_STANDARD}" = "x17" ; then
  691      ARG_CXX_STANDARD="17"
  692 -    AX_CXX_COMPILE_STDCXX(17, [noext], [optional])
  693 +    AX_CXX_COMPILE_STDCXX(17, [noext], [mandatory])
  694    elif test "x${DEFAULT_CXX_STANDARD}" = "x14" ; then
  695      ARG_CXX_STANDARD="14"
  696 -    AX_CXX_COMPILE_STDCXX(14, [noext], [optional])
  697 +    AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
  698    else
  699      ARG_CXX_STANDARD="11"
  700 -    AX_CXX_COMPILE_STDCXX_11([noext], [optional])
  701 +    AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  702    fi
  703  fi
  704  
  705 
  706 From a942fa69062f5c1719cc96f8169c175fd6607c93 Mon Sep 17 00:00:00 2001
  707 From: Nam Nguyen <namn@berkeley.edu>
  708 Date: Sat, 26 Sep 2020 00:51:45 +0000
  709 Subject: [PATCH 10/10] fix bug where unspecified default was not respected If
  710  no --with-cxx-standard is given, there was a bug that resulted in 11 being
  711  incorrectly preferred over the compiler's default. To resolve this make sure
  712  that default is handled by the final else. Ensure it does not fall into the
  713  elif clauses where the user gives an out of bounds standard (< 11 or > 17)
  714  and it clamps it to 11.
  715 
  716 ---
  717  configure.ac | 4 ++--
  718  1 file changed, 2 insertions(+), 2 deletions(-)
  719 
  720 diff --git a/configure.ac b/configure.ac
  721 index 29c237fa8b..3fa925b1fa 100644
  722 --- a/configure.ac
  723 +++ b/configure.ac
  724 @@ -160,11 +160,11 @@ elif test "x${ARG_CXX_STANDARD}" = "x14" ; then
  725    AX_CXX_COMPILE_STDCXX(14, [noext], [mandatory])
  726  elif test "x${ARG_CXX_STANDARD}" = "x11" ; then
  727    AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  728 -elif test "${ARG_CXX_STANDARD}" -lt "11" ; then
  729 +elif test "x${ARG_CXX_STANDARD}" != "xdefault" -a "${ARG_CXX_STANDARD}" -lt "11" ; then
  730    dnl force 11 if user specified out of bounds, regardless of compiler default
  731    ARG_CXX_STANDARD="11"
  732    AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  733 -elif test "${ARG_CXX_STANDARD}" -gt "17" ; then
  734 +elif test "x${ARG_CXX_STANDARD}" != "xdefault" -a "${ARG_CXX_STANDARD}" -gt "17" ; then
  735    dnl force 11 if user specified out of bounds, regardless of compiler default
  736    ARG_CXX_STANDARD="11"
  737    AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])

Generated by cgit