gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated (0498e99f -> b908403e)


From: gnunet
Subject: [libmicrohttpd] branch master updated (0498e99f -> b908403e)
Date: Sat, 16 Apr 2022 12:39:25 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 0498e99f use ifdef for several HAVE header macros
     new 75125088 configure: further improved *FLAGS reporting
     new 66f8a4b5 helper m4 macros: minor code simplification
     new 27922699 Makefile: fixed: user LDFLAGS was not honored
     new fff6d80c Makefile: fixed dependency on libmicrohttpd.la
     new 9b1865f6 configure: added --enable-build-type=TYPE
     new b908403e configure: set minimal supported OS version in W32 binaries

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 configure.ac                                       | 253 ++++++++++++++++++---
 m4/mhd_append_flag_to_var.m4                       |   6 +-
 m4/mhd_check_add_cc_cflag.m4                       |  63 +++++
 m4/mhd_check_add_cc_cflags.m4                      |  39 ++++
 m4/mhd_check_add_cc_ldflag.m4                      |  34 +++
 m4/mhd_check_add_cc_ldflags.m4                     |  39 ++++
 m4/{mhd_check_cc_flag.m4 => mhd_check_cc_cflag.m4} | 138 +++++------
 m4/mhd_check_cc_ldflag.m4                          |  43 ++++
 m4/mhd_find_add_cc_cflag.m4                        |  70 ++++++
 m4/mhd_find_add_cc_ldflag.m4                       |  39 ++++
 m4/mhd_prepend_flag_to_var.m4                      |   6 +-
 src/microhttpd/Makefile.am                         |  20 +-
 12 files changed, 633 insertions(+), 117 deletions(-)
 create mode 100644 m4/mhd_check_add_cc_cflag.m4
 create mode 100644 m4/mhd_check_add_cc_cflags.m4
 create mode 100644 m4/mhd_check_add_cc_ldflag.m4
 create mode 100644 m4/mhd_check_add_cc_ldflags.m4
 rename m4/{mhd_check_cc_flag.m4 => mhd_check_cc_cflag.m4} (60%)
 create mode 100644 m4/mhd_check_cc_ldflag.m4
 create mode 100644 m4/mhd_find_add_cc_cflag.m4
 create mode 100644 m4/mhd_find_add_cc_ldflag.m4

diff --git a/configure.ac b/configure.ac
index 39587fe3..cbafd7d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@ AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE([gnu] [check-news] [filename-length-max=99] [tar-v7] 
[silent-rules] [subdir-objects])
 AC_CONFIG_HEADERS([MHD_config.h])
 AC_CONFIG_MACRO_DIR([m4])
+m4_pattern_forbid([^_?MHD_[A-Z_]+_CC_])dnl
 
 LIB_VERSION_CURRENT=72
 LIB_VERSION_REVISION=0
@@ -71,6 +72,33 @@ AS_IF([test -z "$CC" && test -z "$CPP"], [
   )
 ])
 
+
+AC_MSG_CHECKING([for build type])
+AC_ARG_ENABLE([build-type],
+  [AS_HELP_STRING([[--enable-build-type=TYPE]],
+  [enable build TYPE, a set of configuration parameters; individual settings ]
+  [(asserts, sanitizers, compiler and linker flags) can be overriden by ]
+  [additional configure parameters (debug, neutral, release, release-compact, ]
+  [release-hardened) [neutral]])],
+  [], [enable_build_type=neutral])
+AS_IF([test "x${enable_build_type}" = "x"], [enable_build_type="neutral"])
+AS_VAR_IF([enable_build_type], ["no"], [enable_build_type="neutral"])
+AS_VAR_IF([enable_build_type], ["yes"], [AC_MSG_ERROR([[Missing TYPE for 
--enable-build-type=]])])
+AS_CASE([${enable_build_type}],
+  [debug], [AC_MSG_RESULT([debug: enable asserts, sanitizers (if any 
supported), debug information, compiler optimisation for debugging])],
+  [neutral], [AC_MSG_RESULT([neutral: use only user-specified compiler and 
linker flags])],
+  [release], [AC_MSG_RESULT([release: disable asserts, enable compiler 
optimisations])],
+  [release-compact], [AC_MSG_RESULT([release-compact: disable asserts, enable 
compiler optimisations for size, enable compact code])],
+  [release-hardened], [AC_MSG_RESULT([release-hardened: disable asserts, 
enable compiler optimisations, enable linker and compiler hardening])],
+  [AC_MSG_ERROR([[Unknown build type: ${enable_build_type}]])]
+)
+AS_VAR_IF([enable_build_type], ["neutral"], [:],
+  [
+    # For all non-neutreal build types do not use automatic "-g -O2" for CFLAGS
+    AS_IF([test -z "${CFLAGS}"], [CFLAGS=""])
+  ]
+)
+
 # Checks for programs.
 AC_PROG_AWK
 AC_PROG_GREP
@@ -109,6 +137,86 @@ CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
 LT_INIT([win32-dll])
 LT_LANG([Windows Resource])
 
+
+CFLAGS="${user_CFLAGS}"
+# Compiler options to always enable (if supported)
+MHD_CHECK_ADD_CC_CFLAG([-fno-strict-aliasing], [CFLAGS_ac])
+
+AS_VAR_IF([enable_build_type],["neutral"],[],
+  [ # Any non-neutral build types
+    MHD_CHECK_ADD_CC_CFLAGS([-Wall -Wnull-dereference 
-Wdeclaration-after-statement], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wredundant-decls -Wtrampolines 
-Wunsafe-loop-optimizations], [CFLAGS_ac])
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    LDFLAGS="${user_LDFLAGS}"
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,--warn-common], [LDFLAGS_ac])
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  ]
+)
+AS_VAR_IF([enable_build_type],["debug"],
+  [ # Debug build
+    CFLAGS="${user_CFLAGS}"
+    MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Og], [-O0])
+    MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wextra -Wdouble-promotion -Wformat=2 
-Wformat-overflow=2 -Wformat-truncation=2], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wmissing-include-dirs -Wshift-overflow=2 
-Wstringop-overflow=4 -Walloc-zero], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wduplicated-branches -Wduplicated-cond 
-Wfloat-equal -Wshadow -Wpointer-arith], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wbad-function-cast -Wcast-qual 
-Wcast-align=strict -Wwrite-strings -Wconversion], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wjump-misses-init -Wlogical-op 
-Waggregate-return -Wstrict-prototypes], [CFLAGS_ac])
+    MHD_CHECK_ADD_CC_CFLAGS([-Wold-style-definition -Wmissing-prototypes 
-Wformat-security -Wshift-negative-value], [CFLAGS_ac])
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    LDFLAGS="${user_LDFLAGS}"
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,--enable-long-section-names], [LDFLAGS_ac])
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  ]
+)
+AS_CASE([${enable_build_type}],[release|release-*],
+  [ # All release types
+    CFLAGS="${user_CFLAGS}"
+    AS_VAR_IF([enable_build_type],
+      [release-compact],
+      [
+        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
+          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
+            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_SMALL_CODE=1])],
+            [/* no includes */])],[/* no includes */])
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Oz], [-Os], [-O])
+      ],
+      [ # All non-compact release types
+        AC_CHECK_DECL([MHD_FAVOR_SMALL_CODE],[],
+          [AC_CHECK_DECL([MHD_FAVOR_FAST_CODE],[],
+            [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-DMHD_FAVOR_FAST_CODE=1])],
+            [/* no includes */])],[/* no includes */])
+        CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+        MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-O2], [-O])
+        MHD_CHECK_ADD_CC_CFLAGS([-fsched-pressure -fira-loop-pressure 
-fmerge-all-constants], [CFLAGS_ac]) # These flags may improve size, recheck 
with LTO and linker garbage collection
+        MHD_CHECK_ADD_CC_CFLAGS([-ftree-partial-pre -fgcse-after-reload 
-fipa-pta], [CFLAGS_ac])
+        MHD_CHECK_ADD_CC_CFLAGS([-fisolate-erroneous-paths-attribute 
-ffinite-loops -floop-nest-optimize], [CFLAGS_ac])
+        MHD_CHECK_ADD_CC_CFLAGS([-fpredictive-commoning -frename-registers], 
[CFLAGS_ac])
+        MHD_CHECK_ADD_CC_CFLAGS([-ftree-loop-distribute-patterns -fpeel-loops 
-fsplit-loops -ftree-vectorize], [CFLAGS_ac])
+      ]
+    )
+
+    AS_VAR_IF([enable_build_type],
+      [release-hardened],
+      [
+        MHD_CHECK_ADD_CC_CFLAGS([-Wformat-security -Wstack-protector], 
[CFLAGS_ac])
+      ]
+    )
+    AS_VAR_IF([enable_build_type],
+      [ # Flags are not suitable for 'compact' and for 'hardened'
+        MHD_CHECK_ADD_CC_CFLAGS([-ffast-math -fno-trapping-math], [CFLAGS_ac])
+      ]
+    )
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    # W32-specific
+    LDFLAGS="${user_LDFLAGS}"
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,--disable-long-section-names], [LDFLAGS_ac])
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  ]
+)
+CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+
 # Check for headers that are ALWAYS required
 AC_CHECK_HEADERS_ONCE([stdio.h string.h stdint.h errno.h limits.h fcntl.h], [],
   [AC_MSG_ERROR([Compiling libmicrohttpd requires standard POSIX headers 
files])], [AC_INCLUDES_DEFAULT])
@@ -189,26 +297,80 @@ AC_CHECK_HEADERS([sys/sysctl.h netinet/ip_icmp.h 
netinet/icmp_var.h], [], [],
   ]]
 )
 
-# Adam shostack suggests the following for Windows:
-# -D_FORTIFY_SOURCE=2 -fstack-protector-all
-AC_ARG_ENABLE([gcc-hardening],
-   [AS_HELP_STRING([--enable-gcc-hardening], [enable compiler security 
checks])],
-[AS_IF([test x$enableval = xyes],[
-    CFLAGS_ac="${CFLAGS_ac} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 
-fstack-protector-all"
-    CFLAGS_ac="${CFLAGS_ac} -fwrapv -fPIE -Wstack-protector"
-    CFLAGS_ac="${CFLAGS_ac} --param ssp-buffer-size=1"
+AC_ARG_ENABLE([compiler-hardening],
+  [AS_HELP_STRING([--enable-compiler-hardening], [enable compiler security 
checks])],
+  [],
+  [AS_CASE([${enable_build_type}],[*-hardened],
+    [enable_compiler_hardening='yes'],[enable_compiler_hardening='no'])]
+)
+AS_VAR_IF([enable_compiler_hardening],["yes"],
+  [
+    CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+    AC_CHECK_DECL([_FORTIFY_SOURCE],
+      [MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-U_FORTIFY_SOURCE])],
+      [],[/* no includes */])
+    MHD_APPEND_FLAG_TO_VAR([CPPFLAGS_ac],[-D_FORTIFY_SOURCE=2])
+    CPPFLAGS="${CPPFLAGS_ac} ${user_CPPFLAGS}"
+    CFLAGS="${user_CFLAGS}"
+    
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac],[-fstack-protector-strong],[-fstack-protector-all],[-fstack-protector])
+    MHD_CHECK_ADD_CC_CFLAGS([-fstack-clash-protection 
-ftrivial-auto-var-init=pattern],[CFLAGS_ac])
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    AS_VAR_IF([pic_mode],["no"],[],
+      [
+        AS_VAR_IF([enable_shared],["yes"],[],
+          [
+            # PIE cannot be used for shared lib
+            # PIE static lib can be used within non-PIE application, but
+            # PIE static lib cannot be used in non-PIE shared lib. Let's assume
+            # that static lib will not be used in shared lib
+            CFLAGS="${user_CFLAGS}"
+            # Perform tests with "-pie" enabled
+            LDFLAGS="${LDFLAGS_ac} -pie ${user_LDFLAGS}"
+            MHD_CHECK_ADD_CC_CFLAG([-fPIE],[CFLAGS_ac],
+              [
+                MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
+              ],
+              [
+                MHD_CHECK_CC_CFLAG([-fpie],[CFLAGS_ac],
+                  [
+                    MHD_APPEND_FLAG_TO_VAR([LDFLAGS_ac],[-pie])
+                  ]
+                )
+              ]
+            )
+            CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+            LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+          ]
+        )
+      ]
+    )
     CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
-    LDFLAGS_ac="${LDFLAGS_ac} -pie"
     LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
- ])])
+  ]
+)
 
 # Linker hardening options
-# Currently these options are ELF specific - you can't use this with MacOSX
+# Currently these options are ELF specific, they don't work on Darwin and W32
 AC_ARG_ENABLE([linker-hardening],
   [AS_HELP_STRING([--enable-linker-hardening], [enable linker security 
fixups])],
-[AS_IF([test x$enableval = xyes],
-   [LDFLAGS_ac="${LDFLAGS_ac} -z relro -z now"])])
-LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  [],
+  [AS_CASE([${enable_build_type}],[*-hardened],
+    [enable_linker_hardening='yes'],[enable_linker_hardening='no'])]
+)
+AS_VAR_IF([enable_linker_hardening],["yes"],
+  [
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    LDFLAGS="${user_LDFLAGS}"
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,relro],[LDFLAGS_ac],
+      [MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,now],[LDFLAGS_ac])])
+    # Actually should be "noexec" by default, but let's try to enforce it.
+    MHD_CHECK_ADD_CC_LDFLAG([-Wl,-z,noexecstack],[LDFLAGS_ac])
+    # W32-specific. Some are enabled by default, but they will be enfored to 
be sure.
+    MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--large-address-aware 
-Wl,--enable-auto-image-base],[LDFLAGS_ac])
+    MHD_CHECK_ADD_CC_LDFLAGS([-Wl,--dynamicbase -Wl,--nxcompat 
-Wl,--high-entropy-va],[LDFLAGS_ac])
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
+  ]
+)
 
 
 AH_TEMPLATE([[HAVE_STDBOOL_H]], [Define to 1 i][f you have the <stdbool.h> 
header file and <stdbool.h> defines 'bool' type.])
@@ -714,6 +876,16 @@ int main(void)
         AC_SUBST([W32CRT], [MSVCRT])
       ], [AC_SUBST([W32CRT], [UCRT])]
     )
+
+    CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
+    LDFLAGS="${user_LDFLAGS}"
+    AS_CASE([$mhd_w32_ver],
+      [WinXP],
+      
[MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,5,--minor-subsystem-version,1],[LDFLAGS_ac])],
+      [Vista],
+      
[MHD_CHECK_ADD_CC_LDFLAG([-Wl,--major-subsystem-version,6,--minor-subsystem-version,0],[LDFLAGS_ac])]
+    )
+    LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
   ]
 )
 CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
@@ -1059,13 +1231,6 @@ AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test 
"x$mhd_cv_host_shtdwn_trgr_select"
 AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if 
your platform supports sendmsg])])
 AC_CHECK_FUNCS([writev])
 
-# set GCC options
-# use '-fno-strict-aliasing', but only if the compiler
-# and linker can take it
-AX_CHECK_LINK_FLAG([-fno-strict-aliasing],
-  [AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [CFLAGS_ac])])
-CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
-
 AC_C_BIGENDIAN
 AC_C_VARARRAYS
 
@@ -1971,7 +2136,7 @@ MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], 
[[struct timespec ts2, ts1
 HIDDEN_VISIBILITY_CFLAGS=""
 AH_TEMPLATE([_MHD_EXTERN],[defines how to decorate public symbols w][hile 
building the library])
 CFLAGS="${user_CFLAGS}"
-MHD_CHECK_CC_FLAG([-fvisibility=hidden],[CFLAGS_ac],
+MHD_CHECK_CC_CFLAG([-fvisibility=hidden],[CFLAGS_ac],
   [
     # NOTE: require setting of errattr_CFLAGS above
     CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${user_CFLAGS} ${errattr_CFLAGS}"
@@ -2893,9 +3058,12 @@ AC_MSG_RESULT([$CPU_COUNT])
 
 AC_MSG_CHECKING([[whether to enable debug asserts]])
 AC_ARG_ENABLE([[asserts]],
-              AS_HELP_STRING([[--enable-asserts]],
-                             [enable test build with debug asserts]),
-              [], [[enable_asserts='no']])
+  [AS_HELP_STRING([[--enable-asserts]],
+    [enable test build with debug asserts])],
+  [],
+  [AS_CASE([${enable_build_type}],[*-hardened],
+    [enable_compiler_hardening='yes'],[enable_compiler_hardening='no'])]
+)
 AS_CASE([[$enable_asserts]], [[yes]], [[:]], [[no]], [[:]], 
[[enable_asserts='no']])
 AC_MSG_RESULT([[$enable_asserts]])
 
@@ -2956,10 +3124,25 @@ AS_IF([test "x${enable_sanitizers}" = "xno"],
   ],
   [test "x${enable_sanitizers}" = "xauto" || test "x${enable_sanitizers}" = 
"xauto-optional"],
   [
-    enable_san_address="auto"
-    enable_san_undef="auto"
-    enable_san_leak="auto"
-    enable_san_upoison="auto"
+    AS_VAR_IF([enable_compiler_hardening],["yes"],
+      [
+        AS_VAR_IF([enable_sanitizers],["auto"],
+          [AC_MSG_ERROR([sanitizers cannot be enabled with compiler 
hardnening])],
+          [AC_MSG_WARN([sanitizers cannot be enabled with compiler 
hardnening])]
+        )
+        enable_sanitizers="no"
+        enable_san_address="no"
+        enable_san_undef="no"
+        enable_san_leak="no"
+        enable_san_upoison="no"
+      ],
+      [
+        enable_san_address="auto"
+        enable_san_undef="auto"
+        enable_san_leak="auto"
+        enable_san_upoison="auto"
+      ]
+    )
   ],
   [test "x${enable_sanitizers}" = "xauto-fallback"],
   [
@@ -3510,16 +3693,16 @@ AC_MSG_NOTICE([Toolchain flags:
   CC=$CC
   User/system flags:
     CPPFLAGS="$user_CPPFLAGS"
-    CFLAGS="$user_CFLAGS"
-    LDFLAGS="$user_LDFLAGS"
+    CFLAGS=  "$user_CFLAGS"
+    LDFLAGS= "$user_LDFLAGS"
   Final set of the flags for tests and examples:
     CPPFLAGS="$fin_CPPFLAGS"
-    CFLAGS="$fin_CFLAGS"
-    LDFLAGS="$fin_LDFLAGS"
+    CFLAGS=  "$fin_CFLAGS"
+    LDFLAGS= "$fin_LDFLAGS"
   Final set of the flags for ${PACKAGE_NAME} library:
     CPPFLAGS="$fin_lib_CPPFLAGS"
-    CFLAGS="$fin_lib_CFLAGS"
-    LDFLAGS="$fin_lib_LDFLAGS"
+    CFLAGS=  "$fin_lib_CFLAGS"
+    LDFLAGS= "$fin_lib_LDFLAGS"
 ])
 AS_UNSET([fin_CPPFLAGS])
 AS_UNSET([fin_CFLAGS])
diff --git a/m4/mhd_append_flag_to_var.m4 b/m4/mhd_append_flag_to_var.m4
index ee9e71cd..261110c0 100644
--- a/m4/mhd_append_flag_to_var.m4
+++ b/m4/mhd_append_flag_to_var.m4
@@ -22,7 +22,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 1
+#serial 2
 
 AC_DEFUN([MHD_APPEND_FLAG_TO_VAR],[dnl
 m4_ifblank([$1],[m4_fatal([$0: First macro argument must not be empty])])dnl
@@ -35,7 +35,9 @@ m4_bmatch([$2],[\$],dnl
 [dnl The second parameter is a variable value
 AS_IF([test -z "_mhd_norm_expd([$2])"],dnl
 [varExtd="${varExtd}"],dnl
-[AS_IF([test -z 
"${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="${varExtd} 
_mhd_norm_expd([$2])"])])
+[test -z "${varExtd}"],dnl
+[varExtd="_mhd_norm_expd([$2])"],dnl
+[varExtd="${varExtd} _mhd_norm_expd([$2])"])
 ],dnl
 [dnl The second parameter is not a variable value
 m4_ifnblank(_mhd_norm_expd([$2]),dnl
diff --git a/m4/mhd_check_add_cc_cflag.m4 b/m4/mhd_check_add_cc_cflag.m4
new file mode 100644
index 00000000..0d110e8c
--- /dev/null
+++ b/m4/mhd_check_add_cc_cflag.m4
@@ -0,0 +1,63 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_ADD_CC_CFLAG([FLAG-TO-TEST], [VARIABLE-TO-EXTEND],
+#                          [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flag is supported.
+#   The check is performing by appending FLAG-TO-TEST to the value of
+#   VARIABLE-TO-EXTEND (CFLAGS if not specified), then prepending result to
+#   CFLAGS (unless VARIABLE-TO-EXTEND is CFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND. Otherwise, if compile and link without test flag cannot
+#   be done without any warning, the flag is considered to be unsuppoted.
+#
+#   Example usage:
+#
+#     MHD_CHECK_ADD_CC_CFLAG([-Wshadow], [additional_CFLAGS])
+#
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_ADD_CC_CFLAG],[dnl
+_MHD_CHECK_ADD_CC_XFLAG([$1],[$2],[$3],[$4],[[CFLAGS]])dnl
+])
+
+
+# SYNOPSIS
+#
+#   _MHD_CHECK_ADD_CC_XFLAG([FLAG-TO-TEST], [VARIABLE-TO-EXTEND],
+#                           [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED],
+#                           [CFLAGS|LDFLAGS])
+#
+AC_DEFUN([_MHD_CHECK_ADD_CC_XFLAG],[dnl
+  AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank, m4_default
+  AC_LANG_ASSERT([C])dnl
+  m4_ifblank([$1], [m4_fatal([First macro argument must not be empty])])dnl
+  m4_bmatch(_mhd_norm_expd([$1]), [\s],dnl
+            [m4_fatal([First macro argument must not contain whitespaces])])dnl
+  m4_bmatch(_mhd_norm_expd([$2]), [\s],dnl
+            [m4_fatal([Second macro argument must not contain 
whitespaces])])dnl
+  m4_bmatch([$1], [\$], [m4_fatal([$0: First macro argument must not contain 
'$'])])dnl
+  m4_bmatch([$2], [\$], [m4_fatal([$0: Second macro argument must not contain 
'$'])])dnl
+  m4_bmatch(_mhd_norm_expd([$5]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl
+   [m4_fatal([$0: Fifth macro argument must be either 'CFLAGS' or 'LDFLAGS; 
']_mhd_norm_expd([$5])[' is not supported])])dnl
+  m4_ifnblank([$2],
+    [_MHD_CHECK_CC_XFLAG([$1], [$2],
+      [MHD_APPEND_FLAG_TO_VAR(_mhd_norm_expd([$2]),_mhd_norm_expd([$1]))
+       $3],[$4],[$5])],
+    [_MHD_CHECK_CC_XFLAG([$1],_mhd_norm_expd([$5]),
+      [MHD_APPEND_FLAG_TO_VAR(_mhd_norm_expd([$5]),_mhd_norm_expd([$1]))
+       $3],[$4],[$5])]
+  )
+])
diff --git a/m4/mhd_check_add_cc_cflags.m4 b/m4/mhd_check_add_cc_cflags.m4
new file mode 100644
index 00000000..2f13192d
--- /dev/null
+++ b/m4/mhd_check_add_cc_cflags.m4
@@ -0,0 +1,39 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_ADD_CC_CFLAGS([FLAGS-TO-TEST], [VARIABLE-TO-EXTEND])
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flags are supported.
+#   The FLAGS-TO-TEST parameter is whitespace-separated flagto to test.
+#   The flags are tested one-by-one, all supported flags are added to the
+#   VARIABLE-TO-EXTEND.
+#   Every flag check is performing by appending one flag to the value of
+#   VARIABLE-TO-EXTEND (CFLAGS if not specified), then prepending result to
+#   CFLAGS (unless VARIABLE-TO-EXTEND is CFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND. Otherwise, if compile and link without test flag cannot
+#   be done without any warning, the flag is considered to be unsuppoted.
+#
+#   Example usage:
+#
+#     MHD_CHECK_ADD_CC_CFLAGS([-Wshadow -Walloc-zero -Winit-self],
+#                             [additional_CFLAGS])
+#
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_ADD_CC_CFLAGS],[dnl
+m4_foreach_w([test_flag],[$1],
+[MHD_CHECK_ADD_CC_CFLAG([test_flag],[$2])
+])dnl
+])
diff --git a/m4/mhd_check_add_cc_ldflag.m4 b/m4/mhd_check_add_cc_ldflag.m4
new file mode 100644
index 00000000..132d33ab
--- /dev/null
+++ b/m4/mhd_check_add_cc_ldflag.m4
@@ -0,0 +1,34 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_ADD_CC_LDFLAG([FLAG-TO-TEST], [VARIABLE-TO-EXTEND],
+#                           [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flag is supported.
+#   The check is performing by appending FLAG-TO-TEST to the value of
+#   VARIABLE-TO-EXTEND (LDFLAGS if not specified), then prepending result to
+#   LDFLAGS (unless VARIABLE-TO-EXTEND is LDFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND. Otherwise, if compile and link without test flag cannot
+#   be done without any warning, the flag is considered to be unsuppoted.
+#
+#   Example usage:
+#
+#     MHD_CHECK_ADD_CC_LDFLAG([-pie], [additional_LDFLAGS])
+#
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_ADD_CC_LDFLAG],[dnl
+_MHD_CHECK_ADD_CC_XFLAG([$1],[$2],[$3],[$4],[[LDFLAGS]])dnl
+])
diff --git a/m4/mhd_check_add_cc_ldflags.m4 b/m4/mhd_check_add_cc_ldflags.m4
new file mode 100644
index 00000000..5b013f29
--- /dev/null
+++ b/m4/mhd_check_add_cc_ldflags.m4
@@ -0,0 +1,39 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_ADD_CC_LDFLAGS([FLAGS-TO-TEST], [VARIABLE-TO-EXTEND])
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flags are supported.
+#   The FLAGS-TO-TEST parameter is whitespace-separated flagto to test.
+#   The flags are tested one-by-one, all supported flags are added to the
+#   VARIABLE-TO-EXTEND.
+#   Every flag check is performing by appending one flag to the value of
+#   VARIABLE-TO-EXTEND (LDFLAGS if not specified), then prepending result to
+#   LDFLAGS (unless VARIABLE-TO-EXTEND is LDFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND. Otherwise, if compile and link without test flag cannot
+#   be done without any warning, the flag is considered to be unsuppoted.
+#
+#   Example usage:
+#
+#     MHD_CHECK_ADD_CC_LDFLAGS([-W,--strip-all -Wl,--fatal-warnings],
+#                              [additional_LDFLAGS])
+#
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_ADD_CC_LDFLAGS],[dnl
+m4_foreach_w([test_flag],[$1],
+[MHD_CHECK_ADD_CC_LDFLAG([test_flag],[$2])
+])dnl
+])
diff --git a/m4/mhd_check_cc_flag.m4 b/m4/mhd_check_cc_cflag.m4
similarity index 60%
rename from m4/mhd_check_cc_flag.m4
rename to m4/mhd_check_cc_cflag.m4
index e6ba38f6..f387495b 100644
--- a/m4/mhd_check_cc_flag.m4
+++ b/m4/mhd_check_cc_cflag.m4
@@ -1,7 +1,7 @@
 # SYNOPSIS
 #
-#   MHD_CHECK_CC_FLAG([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-CFLAGS],
-#                     [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
+#   MHD_CHECK_CC_CFLAG([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-CFLAGS],
+#                      [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
 #
 # DESCRIPTION
 #
@@ -15,14 +15,14 @@
 #
 #   Example usage:
 #
-#     MHD_CHECK_CC_FLAG([-Wshadow], [additional_CFLAGS],
-#                       [additional_CFLAGS="${additional_CFLAGS} -Wshadow"])
+#     MHD_CHECK_CC_CFLAG([-Wshadow], [additional_CFLAGS],
+#                        [additional_CFLAGS="${additional_CFLAGS} -Wshadow"])
 #
 #   Defined cache variable used in check so if any test will not work
 #   correctly on some platform, user may simply fix it by giving cache
 #   variable in configure parameters, for example:
 #
-#     ./configure mhd_cv_cc_fl_supp__wshadow=no
+#     ./configure mhd_cv_cc_fl_supp__Wshadow=no
 #
 #   This simplify building from source on exotic platforms as patching
 #   of configure.ac is not required to change results of tests.
@@ -36,9 +36,19 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 1
+#serial 2
 
-AC_DEFUN([MHD_CHECK_CC_FLAG],[dnl
+AC_DEFUN([MHD_CHECK_CC_CFLAG],[dnl
+_MHD_CHECK_CC_XFLAG([$1],[$2],[$3],[$4],[[CFLAGS]])dnl
+])
+
+# SYNOPSIS
+#
+#   _MHD_CHECK_CC_XFLAG([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-CFLAGS],
+#                       [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED],
+#                       [CFLAGS|LDFLAGS])
+#
+AC_DEFUN([_MHD_CHECK_CC_XFLAG],[dnl
   AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank
   AC_LANG_ASSERT([C])dnl
   AC_REQUIRE([AC_PROG_CC])dnl
@@ -49,18 +59,20 @@ AC_DEFUN([MHD_CHECK_CC_FLAG],[dnl
             [m4_fatal([$0: Second macro argument must not contain 
whitespaces])])dnl
   m4_bmatch([$1], [\$], [m4_fatal([$0: First macro argument must not contain 
'$'])])dnl
   m4_bmatch([$2], [\$], [m4_fatal([$0: Second macro argument must not contain 
'$'])])dnl
-  AC_REQUIRE([MHD_FIND_CC_FLAG_WARNPARAMS])dnl sets 'mhd_CFLAGS_params_warn' 
variable
-  _MHD_CHECK_CC_FLAG_BODY([$1],[$2],[$3],[$4],[mhd_CFLAGS_params_warn])dnl
+  AC_REQUIRE([MHD_FIND_CC_XFLAG_WARNPARAMS])dnl sets 'mhd_xFLAGS_params_warn' 
variable
+  m4_bmatch(_mhd_norm_expd([$5]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl
+   [m4_fatal([$0: Fifth macro argument must be either 'CFLAGS' or 'LDFLAGS; 
']_mhd_norm_expd([$5])[' is not supported])])dnl
+  
_MHD_CHECK_CC_XFLAG_BODY([$1],[$2],[$3],[$4],[mhd_xFLAGS_params_warn],[$5])dnl
 ])
 
 
 # SYNOPSIS
 #
-#   _MHD_CHECK_CC_FLAG_BODY([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-CFLAGS],
-#                           [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED],
-#                           [VARIABLE-TO-ENABLE-WARNS])
+#   _MHD_CHECK_CC_XFLAG_BODY([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-CFLAGS],
+#                            [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED],
+#                            [VARIABLE-TO-ENABLE-WARNS], [CFLAGS|LDFLAGS])
 #
-AC_DEFUN([_MHD_CHECK_CC_FLAG_BODY],[dnl
+AC_DEFUN([_MHD_CHECK_CC_XFLAG_BODY],[dnl
   AC_LANG_ASSERT([C])dnl
   m4_ifblank([$1], [m4_fatal([$0: First macro argument must not be empty])])dnl
   m4_bmatch(_mhd_norm_expd([$1]), [\s],dnl
@@ -71,18 +83,22 @@ AC_DEFUN([_MHD_CHECK_CC_FLAG_BODY],[dnl
   m4_bmatch([$2], [\$], [m4_fatal([$0: Second macro argument must not contain 
'$'])])dnl
   m4_ifblank([$5], [m4_fatal([$0: Fifth macro argument must not be empty])])dnl
   m4_bmatch([$5], [\$], [m4_fatal([$0: Fifth macro argument must not contain 
'$'])])dnl
-  AS_VAR_PUSHDEF([cv_Var], 
[mhd_cv_cc_fl_supp_]m4_bpatsubst(m4_tolower(_mhd_norm_expd([$1])),[[^a-z0-9]],[_]))dnl
-  dnl
+  m4_bmatch(_mhd_norm_expd([$6]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl
+   [m4_fatal([$0: Sixth macro argument must be either 'CFLAGS' or 'LDFLAGS; 
']_mhd_norm_expd([$6])[' is not supported])])dnl
+  m4_pushdef([XFLAGS],_mhd_norm_expd([$6]))dnl
+  dnl Keep uppercase letters to avoid clashes for parameters like -fPIE and 
-fpie
+  
AS_VAR_PUSHDEF([cv_Var],[mhd_cv_cc_]m4_tolower(m4_substr(_mhd_norm_expd([$6]),0,1))[fl_supp_]m4_bpatsubst(_mhd_norm_expd([$1]),[[^a-zA-Z0-9]],[_]))dnl
+
   AC_CACHE_CHECK([whether $[]CC supports _mhd_norm_expd([$1]) flag], cv_Var,
     [dnl
-      AS_VAR_PUSHDEF([save_CFLAGS_Var], [mhd_check_cc_flag_save_CFLAGS])dnl
-      AS_VAR_SET([save_CFLAGS_Var],["${CFLAGS}"])
+      AS_VAR_PUSHDEF([save_xFLAGS_Var], [mhd_check_cc_flag_save_]XFLAGS)dnl
+      AS_VAR_SET([save_xFLAGS_Var],["${XFLAGS}"])
       m4_ifnblank([$2],[dnl
-        m4_if(_mhd_norm_expd([$2]),[CFLAGS],
-          [CFLAGS="${save_CFLAGS_Var} _mhd_norm_expd([$1]) 
$[]{_mhd_norm_expd([$5])}"],
-          [CFLAGS="$[]{_mhd_norm_expd([$2])} _mhd_norm_expd([$1]) 
${save_CFLAGS_Var} $[]{_mhd_norm_expd([$5])}"])
+        m4_if(_mhd_norm_expd([$2]),[XFLAGS],
+          [XFLAGS="${save_xFLAGS_Var} _mhd_norm_expd([$1]) 
$[]{_mhd_norm_expd([$5])}"],
+          [XFLAGS="$[]{_mhd_norm_expd([$2])} _mhd_norm_expd([$1]) 
${save_xFLAGS_Var} $[]{_mhd_norm_expd([$5])}"])
       ],[dnl
-        CFLAGS="_mhd_norm_expd([$1]) $[]CFLAGS $[]{_mhd_norm_expd([$5])}"
+        XFLAGS="_mhd_norm_expd([$1]) $[]XFLAGS $[]{_mhd_norm_expd([$5])}"
       ])dnl
       mhd_check_cc_flag_save_c_werror_flag="$ac_c_werror_flag"
       ac_c_werror_flag=yes
@@ -95,23 +111,23 @@ int main(void)
       ]])])
       AC_LINK_IFELSE([],
         [AS_VAR_SET([cv_Var],["yes"])],
-        [ [#] Compile and link failed if test flag added
+        [ [#] Compile and link failed with test flag added
           m4_ifnblank([$2],[dnl
-            m4_if(_mhd_norm_expd([$2]),[CFLAGS],
-              [CFLAGS="${save_CFLAGS_Var} $[]{_mhd_norm_expd([$5])}"],
-              [CFLAGS="$[]{_mhd_norm_expd([$2])} ${save_CFLAGS_Var} 
$[]{_mhd_norm_expd([$5])}"])
+            m4_if(_mhd_norm_expd([$2]),[XFLAGS],
+              [XFLAGS="${save_xFLAGS_Var} $[]{_mhd_norm_expd([$5])}"],
+              [XFLAGS="$[]{_mhd_norm_expd([$2])} ${save_xFLAGS_Var} 
$[]{_mhd_norm_expd([$5])}"])
           ],[dnl
-            CFLAGS="${save_CFLAGS_Var} $[]{_mhd_norm_expd([$5])}"
+            XFLAGS="${save_xFLAGS_Var} $[]{_mhd_norm_expd([$5])}"
             ])dnl
           AC_LINK_IFELSE([],
             [AS_VAR_SET([cv_Var],["no"])],
-            [ [#] Compile and link failed if test flag removed as well
+            [ [#] Compile and link failed with test flag removed as well
               m4_ifnblank([$2],[dnl
-                m4_if(_mhd_norm_expd([$2]),[CFLAGS],
-                  [CFLAGS="${save_CFLAGS_Var} _mhd_norm_expd([$1])"],
-                  [CFLAGS="$[]{_mhd_norm_expd([$2])} _mhd_norm_expd([$1]) 
${save_CFLAGS_Var}"])
+                m4_if(_mhd_norm_expd([$2]),[XFLAGS],
+                  [XFLAGS="${save_xFLAGS_Var} _mhd_norm_expd([$1])"],
+                  [XFLAGS="$[]{_mhd_norm_expd([$2])} _mhd_norm_expd([$1]) 
${save_xFLAGS_Var}"])
               ],[dnl
-                CFLAGS="_mhd_norm_expd([$1]) ${save_CFLAGS_Var}"
+                XFLAGS="_mhd_norm_expd([$1]) ${save_xFLAGS_Var}"
               ])dnl
               ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag"
               AC_LINK_IFELSE([],
@@ -123,72 +139,58 @@ int main(void)
         ]
       )
       ac_c_werror_flag="$mhd_check_cc_flag_save_c_werror_flag"
-      AS_VAR_SET([CFLAGS],["${save_CFLAGS_Var}"])
-      AS_UNSET(save_CFLAGS_Var)
-      AS_VAR_POPDEF([save_CFLAGS_Var])dnl
+      AS_VAR_SET([XFLAGS],["${save_xFLAGS_Var}"])
+      AS_UNSET(save_xFLAGS_Var)
+      AS_VAR_POPDEF([save_xFLAGS_Var])dnl
     ]
   )
   m4_ifnblank([$3$4],[dnl
     AS_VAR_IF([cv_Var], ["yes"], [$3], m4_default_nblank([$4]))
     ])dnl
   AS_VAR_POPDEF([cv_Var])dnl
+  m4_popdef([XFLAGS])dnl
 ])
 
 
 #
 # SYNOPSIS
 #
-#   MHD_FIND_CC_FLAG_WARNPARAMS()
+#   MHD_FIND_CC_XFLAG_WARNPARAMS()
 #
-AC_DEFUN([MHD_FIND_CC_FLAG_WARNPARAMS],[dnl
+AC_DEFUN([MHD_FIND_CC_XFLAG_WARNPARAMS],[dnl
   AC_LANG_ASSERT([C])dnl
-  AC_REQUIRE([MHD_FIND_CC_FLAG_WWARN])dnl
-  mhd_CFLAGS_params_warn=''
-  _MHD_CHECK_CC_FLAG_BODY([-Wunused-command-line-argument],[],
+  AC_REQUIRE([MHD_FIND_CC_CFLAG_WWARN])dnl
+  mhd_xFLAGS_params_warn=''
+  _MHD_CHECK_CC_XFLAG_BODY([-Wunused-command-line-argument],[],
     [
-      AS_IF([test -z "$mhd_CFLAGS_params_warn"],
-        [mhd_CFLAGS_params_warn='-Wunused-command-line-argument'],
-        [mhd_CFLAGS_params_warn="$mhd_CFLAGS_params_warn 
-Wunused-command-line-argument"]
-      )
-    ],[],[mhd_cv_cc_flag_Wwarn]
+      
MHD_APPEND_FLAG_TO_VAR([mhd_xFLAGS_params_warn],[-Wunused-command-line-argument])
+    ],[],[mhd_cv_cc_flag_Wwarn],[[CFLAGS]]
   )
-  _MHD_CHECK_CC_FLAG_BODY([-Wignored-optimization-argument],[],
+  _MHD_CHECK_CC_XFLAG_BODY([-Wignored-optimization-argument],[],
     [
-      AS_IF([test -z "$mhd_CFLAGS_params_warn"],
-        [mhd_CFLAGS_params_warn='-Wignored-optimization-argument'],
-        [mhd_CFLAGS_params_warn="$mhd_CFLAGS_params_warn 
-Wignored-optimization-argument"]
-      )
-    ],[],[mhd_cv_cc_flag_Wwarn]
+      
MHD_APPEND_FLAG_TO_VAR([mhd_xFLAGS_params_warn],[-Wignored-optimization-argument])
+    ],[],[mhd_cv_cc_flag_Wwarn],[[CFLAGS]]
   )
-  _MHD_CHECK_CC_FLAG_BODY([-Winvalid-command-line-argument],[],
+  _MHD_CHECK_CC_XFLAG_BODY([-Winvalid-command-line-argument],[],
     [
-      AS_IF([test -z "$mhd_CFLAGS_params_warn"],
-        [mhd_CFLAGS_params_warn='-Winvalid-command-line-argument'],
-        [mhd_CFLAGS_params_warn="$mhd_CFLAGS_params_warn 
-Winvalid-command-line-argument"]
-      )
-    ],[],[mhd_cv_cc_flag_Wwarn]
+      
MHD_APPEND_FLAG_TO_VAR([mhd_xFLAGS_params_warn],[-Winvalid-command-line-argument])
+    ],[],[mhd_cv_cc_flag_Wwarn],[[CFLAGS]]
   )
-  _MHD_CHECK_CC_FLAG_BODY([-Wunknown-argument],[],
+  _MHD_CHECK_CC_XFLAG_BODY([-Wunknown-argument],[],
     [
-      AS_IF([test -z "$mhd_CFLAGS_params_warn"],
-        [mhd_CFLAGS_params_warn='-Wunknown-argument'],
-        [mhd_CFLAGS_params_warn="$mhd_CFLAGS_params_warn -Wunknown-argument"]
-      )
-    ],[],[mhd_cv_cc_flag_Wwarn]
-  )
-  AS_IF([test -z "$mhd_CFLAGS_params_warn"],
-    [mhd_CFLAGS_params_warn="$mhd_cv_cc_flag_Wwarn"],
-    [mhd_CFLAGS_params_warn="$mhd_cv_cc_flag_Wwarn $mhd_CFLAGS_params_warn"]
+      MHD_APPEND_FLAG_TO_VAR([mhd_xFLAGS_params_warn],[-Wunknown-argument])
+    ],[],[mhd_cv_cc_flag_Wwarn],[[CFLAGS]]
   )
+  MHD_PREPEND_FLAG_TO_VAR([mhd_xFLAGS_params_warn],[$mhd_cv_cc_flag_Wwarn])
 ])
 
 
 #
 # SYNOPSIS
 #
-#   MHD_FIND_CC_FLAG_WWARN()
+#   MHD_FIND_CC_CFLAG_WWARN()
 #
-AC_DEFUN([MHD_FIND_CC_FLAG_WWARN],[dnl
+AC_DEFUN([MHD_FIND_CC_CFLAG_WWARN],[dnl
   AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank
   AC_REQUIRE([AC_PROG_CC])dnl
   AC_LANG_ASSERT([C])dnl
diff --git a/m4/mhd_check_cc_ldflag.m4 b/m4/mhd_check_cc_ldflag.m4
new file mode 100644
index 00000000..e5f57953
--- /dev/null
+++ b/m4/mhd_check_cc_ldflag.m4
@@ -0,0 +1,43 @@
+# SYNOPSIS
+#
+#   MHD_CHECK_CC_LDFLAG([FLAG-TO-TEST], [VARIABLE-TO-PREPEND-LDFLAGS],
+#                       [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED])
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flag is supported.
+#   The check is performing by prepending FLAG-TO-TEST to LDFLAGS, then
+#   prepending value of VARIABLE-TO-PREPEND-LDFLAGS (if any) to LDFLAGS, and
+#   then performing compile and link test. If test succeed without warnings,
+#   then the flag is considered to be suppoted. Otherwise, if compile and link
+#   without test flag can be done without any warning, the flag is considered
+#   to be unsuppoted.
+#
+#   Example usage:
+#
+#     MHD_CHECK_CC_LDFLAG([-pie], [additional_LDFLAGS],
+#                         [additional_LDFLAGS="${additional_LDFLAGS} -pie"])
+#
+#   Defined cache variable used in check so if any test will not work
+#   correctly on some platform, user may simply fix it by giving cache
+#   variable in configure parameters, for example:
+#
+#     ./configure mhd_cv_cc_fl_supp__wshadow=no
+#
+#   This simplify building from source on exotic platforms as patching
+#   of configure.ac is not required to change results of tests.
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_CHECK_CC_LDFLAG],[dnl
+_MHD_CHECK_CC_XFLAG([$1],[$2],[$3],[$4],[[LDFLAGS]])dnl
+])
diff --git a/m4/mhd_find_add_cc_cflag.m4 b/m4/mhd_find_add_cc_cflag.m4
new file mode 100644
index 00000000..7afc0f39
--- /dev/null
+++ b/m4/mhd_find_add_cc_cflag.m4
@@ -0,0 +1,70 @@
+# SYNOPSIS
+#
+#   MHD_FIND_ADD_CC_CFLAG([VARIABLE-TO-EXTEND],
+#                         [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flags are supported.
+#   The flags are checked one-by-one. The checking is stopped when the first
+#   supported flag found.
+#   The checks are performing by appending FLAGx-TO-TEST to the value of
+#   VARIABLE-TO-EXTEND (CFLAGS if not specified), then prepending result to
+#   CFLAGS (unless VARIABLE-TO-EXTEND is CFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND and next flags are not checked. If compile-link cycle
+#   cannot be performed without warning with all tested flags, no flag is
+#   added to the VARIABLE-TO-EXTEND.
+#
+#   Example usage:
+#
+#     MHD_CHECK_CC_CFLAG([additional_CFLAGS],
+#                        [-ggdb3], [-g3], [-ggdb], [-g])
+#
+#   Note: Unlike others MHD_CHECK_*CC_CFLAG* macro, this macro uses another
+#   order of parameters.
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_FIND_ADD_CC_CFLAG],[dnl
+_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],$@)])
+
+
+# SYNOPSIS
+#
+#   _MHD_FIND_ADD_CC_XFLAG([CFLAGS|LDFLAGS],
+#                          [VARIABLE-TO-EXTEND],
+#                          [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
+#
+AC_DEFUN([_MHD_FIND_ADD_CC_XFLAG],[dnl
+  AC_PREREQ([2.64])dnl for m4_ifnblank
+  AC_LANG_ASSERT([C])dnl
+  m4_if(m4_eval([$# >= 3]), [0], [m4_fatal([$0: Macro must have at least three 
parameters])])dnl
+  m4_ifblank([$3],[m4_fatal([$0: Third macro argument must not be empty])])dnl
+  m4_bmatch(_mhd_norm_expd([$1]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl
+   [m4_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS; 
']_mhd_norm_expd([$5])[' is not supported])])dnl
+  m4_ifnblank([$2],[_MHD_FIND_ADD_CC_XFLAG_BODY($@)],dnl
+  [_MHD_FIND_ADD_CC_XFLAG_BODY([$1],[$1],m4_shift2($@))])dnl
+])
+
+
+m4_define([_MHD_FIND_ADD_CC_XFLAG_BODY],[dnl
+m4_version_prereq([2.64])dnl for m4_ifnblank
+m4_if([$#],[0],[m4_fatal([$0: no parameters])])dnl
+m4_bmatch(_mhd_norm_expd([$1]),[^\(CFLAGS\|LDFLAGS\)$],[],dnl
+[m4_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS; 
']_mhd_norm_expd([$5])[' is not supported])])dnl
+m4_if([$#],[1],[m4_fatal([$0: not enough parameters])])dnl
+m4_if([$#],[2],[m4_fatal([$0: not enough parameters])])dnl
+m4_if([$#],[3],[m4_ifnblank([$3],[_MHD_CHECK_ADD_CC_XFLAG([$3],[$2],[],[],[$1])])],
+[m4_ifnblank([$3],[_MHD_CHECK_ADD_CC_XFLAG([$3],[$2],[],[$0([$1],[$2],m4_shift3($@))],[$1])],
+[$0([$1],[$2],m4_shift3($@))])])dnl
+])
diff --git a/m4/mhd_find_add_cc_ldflag.m4 b/m4/mhd_find_add_cc_ldflag.m4
new file mode 100644
index 00000000..224a4e29
--- /dev/null
+++ b/m4/mhd_find_add_cc_ldflag.m4
@@ -0,0 +1,39 @@
+# SYNOPSIS
+#
+#   MHD_FIND_ADD_CC_LDFLAG([VARIABLE-TO-EXTEND],
+#                         [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
+#
+# DESCRIPTION
+#
+#   This macro checks whether the specific compiler flags are supported.
+#   The flags are checked one-by-one. The checking is stopped when the first
+#   supported flag found.
+#   The checks are performing by appending FLAGx-TO-TEST to the value of
+#   VARIABLE-TO-EXTEND (LDFLAGS if not specified), then prepending result to
+#   LDFLAGS (unless VARIABLE-TO-EXTEND is LDFLAGS), and then performing compile
+#   and link test. If test succeed without warnings, then the flag is added to
+#   VARIABLE-TO-EXTEND and next flags are not checked. If compile-link cycle
+#   cannot be performed without warning with all tested flags, no flag is
+#   added to the VARIABLE-TO-EXTEND.
+#
+#   Example usage:
+#
+#     MHD_CHECK_CC_LDFLAG([additional_LDFLAGS],
+#                        [-Wl,--strip-all], [-Wl,--strip-debug])
+#
+#   Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another
+#   order of parameters.
+#
+# LICENSE
+#
+#   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 1
+
+AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG],[dnl
+_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],$@)])
diff --git a/m4/mhd_prepend_flag_to_var.m4 b/m4/mhd_prepend_flag_to_var.m4
index 788ce3ca..1d0bd1c3 100644
--- a/m4/mhd_prepend_flag_to_var.m4
+++ b/m4/mhd_prepend_flag_to_var.m4
@@ -22,7 +22,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 1
+#serial 2
 
 AC_DEFUN([MHD_PREPEND_FLAG_TO_VAR],[dnl
 m4_ifblank([$1],[m4_fatal([$0: First macro argument must not be empty])])dnl
@@ -35,7 +35,9 @@ m4_bmatch([$2],[\$],dnl
 [dnl The second parameter is a variable value
 AS_IF([test -z "_mhd_norm_expd([$2])"],dnl
 [varExtd="${varExtd}"],dnl
-[AS_IF([test -z 
"${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="_mhd_norm_expd([$2]) 
${varExtd}"])])
+[test -z "${varExtd}"],dnl
+[varExtd="_mhd_norm_expd([$2])"],dnl
+[varExtd="_mhd_norm_expd([$2]) ${varExtd}"])
 ],dnl
 [dnl The second parameter is not a variable value
 m4_ifnblank(_mhd_norm_expd([$2]),dnl
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index fc742aae..6a08fe70 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -109,7 +109,7 @@ libmicrohttpd_la_CPPFLAGS = \
 libmicrohttpd_la_CFLAGS = \
   $(AM_CFLAGS) $(MHD_LIB_CFLAGS) $(MHD_TLS_LIB_CFLAGS)
 libmicrohttpd_la_LDFLAGS = \
-  $(MHD_LIB_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) \
+  $(AM_LDFLAGS) $(MHD_LIB_LDFLAGS) $(MHD_TLS_LIB_LDFLAGS) \
   $(W32_MHD_LIB_LDFLAGS) \
   -export-dynamic -no-undefined \
   -version-info @LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@
@@ -261,7 +261,7 @@ test_start_stop_LDADD = \
 test_daemon_SOURCES = \
   test_daemon.c
 test_daemon_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la
+  $(builddir)/libmicrohttpd.la
 
 test_response_entries_SOURCES = \
   test_response_entries.c
@@ -277,7 +277,7 @@ test_upgrade_CFLAGS = \
 test_upgrade_LDFLAGS = \
   $(MHD_TLS_LIB_LDFLAGS)
 test_upgrade_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+  $(builddir)/libmicrohttpd.la \
   $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) \
   $(PTHREAD_LIBS)
 
@@ -290,7 +290,7 @@ test_upgrade_large_CFLAGS = \
 test_upgrade_large_LDFLAGS = \
   $(MHD_TLS_LIB_LDFLAGS)
 test_upgrade_large_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+  $(builddir)/libmicrohttpd.la \
   $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) \
   $(PTHREAD_LIBS)
 
@@ -303,7 +303,7 @@ test_upgrade_tls_CFLAGS = \
 test_upgrade_tls_LDFLAGS = \
   $(MHD_TLS_LIB_LDFLAGS)
 test_upgrade_tls_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+  $(builddir)/libmicrohttpd.la \
   $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) \
   $(PTHREAD_LIBS)
 
@@ -316,7 +316,7 @@ test_upgrade_large_tls_CFLAGS = \
 test_upgrade_large_tls_LDFLAGS = \
   $(MHD_TLS_LIB_LDFLAGS)
 test_upgrade_large_tls_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la \
+  $(builddir)/libmicrohttpd.la \
   $(MHD_TLS_LIB_LDFLAGS) $(MHD_TLS_LIBDEPS) \
   $(PTHREAD_LIBS)
 
@@ -327,7 +327,7 @@ test_postprocessor_CPPFLAGS = \
 test_postprocessor_CFLAGS = \
   $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS)
 test_postprocessor_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la
+  $(builddir)/libmicrohttpd.la
 
 test_postprocessor_amp_SOURCES = \
   test_postprocessor_amp.c
@@ -336,7 +336,7 @@ test_postprocessor_amp_CPPFLAGS = \
 test_postprocessor_amp_CFLAGS = \
   $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS)
 test_postprocessor_amp_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la
+  $(builddir)/libmicrohttpd.la
 
 test_postprocessor_large_SOURCES = \
   test_postprocessor_large.c
@@ -345,7 +345,7 @@ test_postprocessor_large_CPPFLAGS = \
 test_postprocessor_large_CFLAGS = \
   $(AM_CFLAGS) $(MHD_TLS_LIB_CFLAGS)
 test_postprocessor_large_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la
+  $(builddir)/libmicrohttpd.la
 
 test_postprocessor_md_SOURCES = \
   test_postprocessor_md.c
@@ -427,7 +427,7 @@ test_sha1_SOURCES = \
 test_options_SOURCES = \
   test_options.c
 test_options_LDADD = \
-  $(top_builddir)/src/microhttpd/libmicrohttpd.la
+  $(builddir)/libmicrohttpd.la
 
 test_client_put_shutdown_SOURCES = \
   test_client_put_stop.c

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]