aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-31 16:44:17 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-05-31 20:19:12 +0300
commit5fd6ea3071fe0330d23f231441290fd5ee44d14c (patch)
treeb21fa724297a1e08003ad12408c69fea31ff7334
parent3ab4375160fb18979fe67950f863313fa65a424f (diff)
downloadlibmicrohttpd-5fd6ea3071fe0330d23f231441290fd5ee44d14c.tar.gz
libmicrohttpd-5fd6ea3071fe0330d23f231441290fd5ee44d14c.zip
MHD_FIND_ADD_CC_{C,LD}FLAG_IFELSE: added new autoconf macros
-rw-r--r--m4/mhd_find_add_cc_cflag.m439
-rw-r--r--m4/mhd_find_add_cc_cflag_ifelse.m445
-rw-r--r--m4/mhd_find_add_cc_ldflag.m46
-rw-r--r--m4/mhd_find_add_cc_ldflag_ifelse.m444
4 files changed, 119 insertions, 15 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 @@
33# and this notice are preserved. This file is offered as-is, without any 33# and this notice are preserved. This file is offered as-is, without any
34# warranty. 34# warranty.
35 35
36#serial 1 36#serial 2
37 37
38AC_DEFUN([MHD_FIND_ADD_CC_CFLAG],[dnl 38AC_DEFUN([MHD_FIND_ADD_CC_CFLAG],[dnl
39_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],$@)]) 39_MHD_FIND_ADD_CC_XFLAG([[CFLAGS]],[],[],$@)])
40 40
41 41
42# SYNOPSIS 42# SYNOPSIS
43# 43#
44# _MHD_FIND_ADD_CC_XFLAG([CFLAGS|LDFLAGS], 44# _MHD_FIND_ADD_CC_XFLAG([CFLAGS|LDFLAGS],
45# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
45# [VARIABLE-TO-EXTEND], 46# [VARIABLE-TO-EXTEND],
46# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...) 47# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
47# 48#
48AC_DEFUN([_MHD_FIND_ADD_CC_XFLAG],[dnl 49AC_DEFUN([_MHD_FIND_ADD_CC_XFLAG],[dnl
49 AC_PREREQ([2.64])dnl for m4_ifnblank 50 AC_PREREQ([2.64])dnl for m4_ifnblank
50 AC_LANG_ASSERT([C])dnl 51 AC_LANG_ASSERT([C])dnl
51 m4_if(m4_eval([$# >= 3]), [0], [m4_fatal([$0: Macro must have at least three parameters])])dnl 52 m4_if(m4_eval([$# >= 5]), [0], [m4_fatal([$0: Macro must have at least five parameters])])dnl
52 m4_ifblank([$3],[m4_fatal([$0: Third macro argument must not be empty])])dnl 53 m4_ifblank([$5],[m4_fatal([$0: Fifth macro argument must not be empty])])dnl
54 m4_ifnblank([$2$3],[m4_newline([m4_n([AS_UNSET([mhd_cc_found_flag])])])])dnl
53 m4_bmatch(_mhd_norm_expd([$1]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl 55 m4_bmatch(_mhd_norm_expd([$1]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl
54 [m4_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS; ']_mhd_norm_expd([$5])[' is not supported])])dnl 56 [m4_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS; ']_mhd_norm_expd([$1])[' is not supported])])dnl
55 m4_ifnblank([$2],[_MHD_FIND_ADD_CC_XFLAG_BODY($@)],dnl 57 m4_ifnblank([$4],[_MHD_FIND_ADD_CC_XFLAG_BODY(m4_ifnblank([$2$3],[mhd_cc_found_flag]),[$1],[$4],m4_shiftn([4],$@))],dnl
56 [_MHD_FIND_ADD_CC_XFLAG_BODY([$1],[$1],m4_shift2($@))])dnl 58 [_MHD_FIND_ADD_CC_XFLAG_BODY(m4_ifnblank([$2$3],[mhd_cc_found_flag]),[$1],[$1],m4_shiftn([4],$@))])dnl
59 m4_ifnblank([$2$3],[
60 AS_IF([test -n "${mhd_cc_found_flag}"],[$2],[$3])
61 AS_UNSET([mhd_cc_found_flag])
62 ])dnl
63 ])dnl
57]) 64])
58 65
59 66
67# SYNOPSIS
68#
69# _MHD_FIND_ADD_CC_XFLAG_BODY([VAR-TO-SET],
70# [CFLAGS|LDFLAGS],
71# [VARIABLE-TO-EXTEND],
72# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
73#
60m4_define([_MHD_FIND_ADD_CC_XFLAG_BODY],[dnl 74m4_define([_MHD_FIND_ADD_CC_XFLAG_BODY],[dnl
61m4_version_prereq([2.64])dnl for m4_ifnblank 75m4_version_prereq([2.64])dnl for m4_ifnblank
62m4_if([$#],[0],[m4_fatal([$0: no parameters])])dnl 76m4_if([$#],[0],[m4_fatal([$0: no parameters])])dnl
63m4_bmatch(_mhd_norm_expd([$1]),[^\(CFLAGS\|LDFLAGS\)$],[],dnl 77m4_bmatch(_mhd_norm_expd([$2]),[^\(CFLAGS\|LDFLAGS\)$],[],dnl
64[m4_fatal([$0: First macro argument must be either 'CFLAGS' or 'LDFLAGS; ']_mhd_norm_expd([$5])[' is not supported])])dnl 78[m4_fatal([$0: Second macro argument must be either 'CFLAGS' or 'LDFLAGS; ']_mhd_norm_expd([$2])[' is not supported])])dnl
65m4_if([$#],[1],[m4_fatal([$0: not enough parameters])])dnl 79m4_if([$#],[1],[m4_fatal([$0: not enough parameters])])dnl
66m4_if([$#],[2],[m4_fatal([$0: not enough parameters])])dnl 80m4_if([$#],[2],[m4_fatal([$0: not enough parameters])])dnl
67m4_if([$#],[3],[m4_ifnblank([$3],[_MHD_CHECK_ADD_CC_XFLAG([$3],[$2],[],[],[$1])])], 81m4_if([$#],[3],[m4_fatal([$0: not enough parameters])])dnl
68[m4_ifnblank([$3],[_MHD_CHECK_ADD_CC_XFLAG([$3],[$2],[],[$0([$1],[$2],m4_shift3($@))],[$1])], 82m4_if([$#],[4],[m4_ifnblank([$4],[_MHD_CHECK_ADD_CC_XFLAG([$4],[$3],m4_ifnblank([$1],[$1="_mhd_norm_expd([$4])"]),[],[$2])])],
69[$0([$1],[$2],m4_shift3($@))])])dnl 83[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])],
84[$0([$1],[$2],[$3],m4_shiftn([4],$@))])])dnl
70]) 85])
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 @@
1# SYNOPSIS
2#
3# MHD_FIND_ADD_CC_CFLAG_IFELSE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
4# [VARIABLE-TO-EXTEND],
5# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
6#
7# DESCRIPTION
8#
9# This macro checks whether the specific compiler flags are supported.
10# The flags are checked one-by-one. The checking is stopped when the first
11# supported flag found.
12# The checks are performing by appending FLAGx-TO-TEST to the value of
13# VARIABLE-TO-EXTEND (CFLAGS if not specified), then prepending result to
14# CFLAGS (unless VARIABLE-TO-EXTEND is CFLAGS), and then performing compile
15# and link test. If test succeed without warnings, then the flag is added to
16# VARIABLE-TO-EXTEND and next flags are not checked. If compile-link cycle
17# cannot be performed without warning with all tested flags, no flag is
18# added to the VARIABLE-TO-EXTEND.
19# If any suitable flag is found, ACTION-IF-FOUND is executed otherwise
20# ACTION-IF-NOT-FOUND is executed. Found flag (if any) is available as
21# value of shell variable $mhd_cc_found_flag during action execution.
22#
23# Example usage:
24#
25# MHD_FIND_ADD_CC_CFLAG_IFELSE([AC_MSG_NOTICE([Enabled debug information])],
26# [],
27# [additional_CFLAGS],
28# [-ggdb3], [-g3], [-ggdb], [-g])
29#
30# Note: Unlike others MHD_CHECK_*CC_CFLAG* macro, this macro uses another
31# order of parameters.
32#
33# LICENSE
34#
35# Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
36#
37# Copying and distribution of this file, with or without modification, are
38# permitted in any medium without royalty provided the copyright notice
39# and this notice are preserved. This file is offered as-is, without any
40# warranty.
41
42#serial 1
43
44AC_DEFUN([MHD_FIND_ADD_CC_CFLAG_IFELSE],[dnl
45_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 @@
19# Example usage: 19# Example usage:
20# 20#
21# MHD_CHECK_CC_LDFLAG([additional_LDFLAGS], 21# MHD_CHECK_CC_LDFLAG([additional_LDFLAGS],
22# [-Wl,--strip-all], [-Wl,--strip-debug]) 22# [-Wl,--strip-all], [-Wl,--strip-debug])
23# 23#
24# Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another 24# Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another
25# order of parameters. 25# order of parameters.
@@ -33,7 +33,7 @@
33# and this notice are preserved. This file is offered as-is, without any 33# and this notice are preserved. This file is offered as-is, without any
34# warranty. 34# warranty.
35 35
36#serial 1 36#serial 2
37 37
38AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG],[dnl 38AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG],[dnl
39_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],$@)]) 39_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],[],[],$@)])
diff --git a/m4/mhd_find_add_cc_ldflag_ifelse.m4 b/m4/mhd_find_add_cc_ldflag_ifelse.m4
new file mode 100644
index 00000000..fbb0fd40
--- /dev/null
+++ b/m4/mhd_find_add_cc_ldflag_ifelse.m4
@@ -0,0 +1,44 @@
1# SYNOPSIS
2#
3# MHD_FIND_ADD_CC_LDFLAG_IFELSE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
4# [VARIABLE-TO-EXTEND],
5# [FLAG1-TO-TEST], [FLAG2-TO-TEST], ...)
6#
7# DESCRIPTION
8#
9# This macro checks whether the specific compiler flags are supported.
10# The flags are checked one-by-one. The checking is stopped when the first
11# supported flag found.
12# The checks are performing by appending FLAGx-TO-TEST to the value of
13# VARIABLE-TO-EXTEND (LDFLAGS if not specified), then prepending result to
14# LDFLAGS (unless VARIABLE-TO-EXTEND is LDFLAGS), and then performing compile
15# and link test. If test succeed without warnings, then the flag is added to
16# VARIABLE-TO-EXTEND and next flags are not checked. If compile-link cycle
17# cannot be performed without warning with all tested flags, no flag is
18# added to the VARIABLE-TO-EXTEND.
19# If any suitable flag is found, ACTION-IF-FOUND is executed otherwise
20# ACTION-IF-NOT-FOUND is executed. Found flag (if any) is available as
21# value of shell variable $mhd_cc_found_flag during action execution.
22#
23# Example usage:
24#
25# MHD_CHECK_CC_LDFLAG([],[AC_MSG_WARN([Stripping is not supported]),
26# [additional_LDFLAGS],
27# [-Wl,--strip-all], [-Wl,--strip-debug])
28#
29# Note: Unlike others MHD_CHECK_*CC_LDFLAG* macro, this macro uses another
30# order of parameters.
31#
32# LICENSE
33#
34# Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
35#
36# Copying and distribution of this file, with or without modification, are
37# permitted in any medium without royalty provided the copyright notice
38# and this notice are preserved. This file is offered as-is, without any
39# warranty.
40
41#serial 1
42
43AC_DEFUN([MHD_FIND_ADD_CC_LDFLAG_IFELSE],[dnl
44_MHD_FIND_ADD_CC_XFLAG([[LDFLAGS]],$@)])