[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 02/10: MHD_FIND_ADD_CC_{C,LD}FLAG_IFELSE: added new auto
From: |
gnunet |
Subject: |
[libmicrohttpd] 02/10: MHD_FIND_ADD_CC_{C,LD}FLAG_IFELSE: added new autoconf macros |
Date: |
Tue, 31 May 2022 19:38:11 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 5fd6ea3071fe0330d23f231441290fd5ee44d14c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Tue May 31 16:44:17 2022 +0300
MHD_FIND_ADD_CC_{C,LD}FLAG_IFELSE: added new autoconf macros
---
m4/mhd_find_add_cc_cflag.m4 | 39 +++++++++++++------
m4/mhd_find_add_cc_cflag_ifelse.m4 | 45 ++++++++++++++++++++++
m4/mhd_find_add_cc_ldflag.m4 | 6 +--
..._ldflag.m4 => mhd_find_add_cc_ldflag_ifelse.m4} | 15 +++++---
4 files changed, 85 insertions(+), 20 deletions(-)
diff --git a/m4/mhd_find_add_cc_cflag.m4 b/m4/mhd_find_add_cc_cflag.m4
index 7afc0f39..49c7bfff 100644
--- a/m4/mhd_find_add_cc_cflag.m4
+++ b/m4/mhd_find_add_cc_cflag.m4
@@ -33,38 +33,53 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 1
+#serial 2
AC_DEFUN([MHD_FIND_ADD_CC_CFLAG],[dnl
-_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],$@)])
+_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],[],[],$@)])
# SYNOPSIS
#
# _MHD_FIND_ADD_CC_XFLAG([CFLAGS|LDFLAGS],
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
# [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_if(m4_eval([$# >= 5]), [0], [m4_fatal([$0: Macro must have at least five
parameters])])dnl
+ m4_ifblank([$5],[m4_fatal([$0: Fifth macro argument must not be empty])])dnl
+ m4_ifnblank([$2$3],[m4_newline([m4_n([AS_UNSET([mhd_cc_found_flag])])])])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_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS;
']_mhd_norm_expd([$1])[' is not supported])])dnl
+
m4_ifnblank([$4],[_MHD_FIND_ADD_CC_XFLAG_BODY(m4_ifnblank([$2$3],[mhd_cc_found_flag]),[$1],[$4],m4_shiftn([4],$@))],dnl
+
[_MHD_FIND_ADD_CC_XFLAG_BODY(m4_ifnblank([$2$3],[mhd_cc_found_flag]),[$1],[$1],m4_shiftn([4],$@))])dnl
+ m4_ifnblank([$2$3],[
+ AS_IF([test -n "${mhd_cc_found_flag}"],[$2],[$3])
+ AS_UNSET([mhd_cc_found_flag])
+ ])dnl
+ ])dnl
])
+# SYNOPSIS
+#
+# _MHD_FIND_ADD_CC_XFLAG_BODY([VAR-TO-SET],
+# [CFLAGS|LDFLAGS],
+# [VARIABLE-TO-EXTEND],
+# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
+#
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_bmatch(_mhd_norm_expd([$2]),[^\(CFLAGS\|LDFLAGS\)$],[],dnl
+[m4_fatal([$0: Second macro argument must be either 'CFLAGS' or 'LDFLAGS;
']_mhd_norm_expd([$2])[' 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
+m4_if([$#],[3],[m4_fatal([$0: not enough parameters])])dnl
+m4_if([$#],[4],[m4_ifnblank([$4],[_MHD_CHECK_ADD_CC_XFLAG([$4],[$3],m4_ifnblank([$1],[$1="_mhd_norm_expd([$4])"]),[],[$2])])],
+[m4_ifnblank([$4],[_MHD_CHECK_ADD_CC_XFLAG([$4],[$3],m4_ifnblank([$1],[$1="_mhd_norm_expd([$4])"]),[$0([$1],[$2],[$3],m4_shiftn([4],$@))],[$2])],
+[$0([$1],[$2],[$3],m4_shiftn([4],$@))])])dnl
])
diff --git a/m4/mhd_find_add_cc_cflag_ifelse.m4
b/m4/mhd_find_add_cc_cflag_ifelse.m4
new file mode 100644
index 00000000..337c4561
--- /dev/null
+++ b/m4/mhd_find_add_cc_cflag_ifelse.m4
@@ -0,0 +1,45 @@
+# SYNOPSIS
+#
+# MHD_FIND_ADD_CC_CFLAG_IFELSE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [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.
+# If any suitable flag is found, ACTION-IF-FOUND is executed otherwise
+# ACTION-IF-NOT-FOUND is executed. Found flag (if any) is available as
+# value of shell variable $mhd_cc_found_flag during action execution.
+#
+# Example usage:
+#
+# MHD_FIND_ADD_CC_CFLAG_IFELSE([AC_MSG_NOTICE([Enabled debug
information])],
+# [],
+# [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_IFELSE],[dnl
+_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],$@)])
diff --git a/m4/mhd_find_add_cc_ldflag.m4 b/m4/mhd_find_add_cc_ldflag.m4
index 224a4e29..374ecf0f 100644
--- a/m4/mhd_find_add_cc_ldflag.m4
+++ b/m4/mhd_find_add_cc_ldflag.m4
@@ -19,7 +19,7 @@
# Example usage:
#
# MHD_CHECK_CC_LDFLAG([additional_LDFLAGS],
-# [-Wl,--strip-all], [-Wl,--strip-debug])
+# [-Wl,--strip-all], [-Wl,--strip-debug])
#
# Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another
# order of parameters.
@@ -33,7 +33,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 1
+#serial 2
AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG],[dnl
-_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],$@)])
+_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],[],[],$@)])
diff --git a/m4/mhd_find_add_cc_ldflag.m4 b/m4/mhd_find_add_cc_ldflag_ifelse.m4
similarity index 64%
copy from m4/mhd_find_add_cc_ldflag.m4
copy to m4/mhd_find_add_cc_ldflag_ifelse.m4
index 224a4e29..fbb0fd40 100644
--- a/m4/mhd_find_add_cc_ldflag.m4
+++ b/m4/mhd_find_add_cc_ldflag_ifelse.m4
@@ -1,7 +1,8 @@
# SYNOPSIS
#
-# MHD_FIND_ADD_CC_LDFLAG([VARIABLE-TO-EXTEND],
-# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
+# MHD_FIND_ADD_CC_LDFLAG_IFELSE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+# [VARIABLE-TO-EXTEND],
+# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
#
# DESCRIPTION
#
@@ -15,11 +16,15 @@
# 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.
+# If any suitable flag is found, ACTION-IF-FOUND is executed otherwise
+# ACTION-IF-NOT-FOUND is executed. Found flag (if any) is available as
+# value of shell variable $mhd_cc_found_flag during action execution.
#
# Example usage:
#
-# MHD_CHECK_CC_LDFLAG([additional_LDFLAGS],
-# [-Wl,--strip-all], [-Wl,--strip-debug])
+# MHD_CHECK_CC_LDFLAG([],[AC_MSG_WARN([Stripping is not supported]),
+# [additional_LDFLAGS],
+# [-Wl,--strip-all], [-Wl,--strip-debug])
#
# Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another
# order of parameters.
@@ -35,5 +40,5 @@
#serial 1
-AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG],[dnl
+AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG_IFELSE],[dnl
_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],$@)])
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (afb8ed41 -> 1b8c52f1), gnunet, 2022/05/31
- [libmicrohttpd] 01/10: connection.c: fixed compiler warnings, gnunet, 2022/05/31
- [libmicrohttpd] 02/10: MHD_FIND_ADD_CC_{C,LD}FLAG_IFELSE: added new autoconf macros,
gnunet <=
- [libmicrohttpd] 04/10: MHD_get_timeout*(): improved doxy, gnunet, 2022/05/31
- [libmicrohttpd] 05/10: Fixed wrong variable type used for result of gnutls_priority_init(), gnunet, 2022/05/31
- [libmicrohttpd] 06/10: configure: disabled one more warning on clang, gnunet, 2022/05/31
- [libmicrohttpd] 07/10: mhd_sockets: muted compiler warning with very minor optimisation, gnunet, 2022/05/31
- [libmicrohttpd] 08/10: daemon.c: fixed possible uninitialized value, gnunet, 2022/05/31
- [libmicrohttpd] 03/10: configure: added more workarounds for clang, gnunet, 2022/05/31
- [libmicrohttpd] 09/10: Fixed 'int' instead of 'MHD_Result', gnunet, 2022/05/31
- [libmicrohttpd] 10/10: daemon: muted compiler warning, refactored code for readability, gnunet, 2022/05/31