diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-04-03 19:44:15 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-04-03 20:17:43 +0300 |
commit | a3579e7061d233d20170d3d3ac04a04a49be12a1 (patch) | |
tree | 69db4be8692b96bda69adfdae6aaee9086f1a705 /m4/mhd_prepend_flag_to_var.m4 | |
parent | 29dfdc7cfb972ee666bc36b9ec1e3388706d672d (diff) | |
download | libmicrohttpd-a3579e7061d233d20170d3d3ac04a04a49be12a1.tar.gz libmicrohttpd-a3579e7061d233d20170d3d3ac04a04a49be12a1.zip |
Added two helper macros to manipulate *FLAGS vars
Diffstat (limited to 'm4/mhd_prepend_flag_to_var.m4')
-rw-r--r-- | m4/mhd_prepend_flag_to_var.m4 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/m4/mhd_prepend_flag_to_var.m4 b/m4/mhd_prepend_flag_to_var.m4 new file mode 100644 index 00000000..788ce3ca --- /dev/null +++ b/m4/mhd_prepend_flag_to_var.m4 | |||
@@ -0,0 +1,46 @@ | |||
1 | # SYNOPSIS | ||
2 | # | ||
3 | # MHD_PREPEND_FLAG_TO_VAR([VARIABLE-TO-EXTEND], [FLAG-TO-PREPEND]) | ||
4 | # | ||
5 | # DESCRIPTION | ||
6 | # | ||
7 | # This macro sets VARIABLE-TO-EXTEND to the value of VARIABLE-TO-EXTEND with | ||
8 | # appended FLAG-TO-APPEND. If current value of VARIABLE-TO-EXTEND and | ||
9 | # FLAG-TO-APPEND are both non-empty strings then space is added between them. | ||
10 | # | ||
11 | # Example usage: | ||
12 | # | ||
13 | # MHD_PREPEND_FLAG_TO_VAR([my_CFLAGS], [-Wall]) | ||
14 | # | ||
15 | # | ||
16 | # LICENSE | ||
17 | # | ||
18 | # Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru> | ||
19 | # | ||
20 | # Copying and distribution of this file, with or without modification, are | ||
21 | # permitted in any medium without royalty provided the copyright notice | ||
22 | # and this notice are preserved. This file is offered as-is, without any | ||
23 | # warranty. | ||
24 | |||
25 | #serial 1 | ||
26 | |||
27 | AC_DEFUN([MHD_PREPEND_FLAG_TO_VAR],[dnl | ||
28 | m4_ifblank([$1],[m4_fatal([$0: First macro argument must not be empty])])dnl | ||
29 | m4_bmatch([$1], [\$], [m4_fatal([$0: First macro argument must not contain '$'])])dnl | ||
30 | m4_bmatch([$1], [,], [m4_fatal([$0: First macro argument must not contain ','])])dnl | ||
31 | m4_bmatch(_mhd_norm_expd([$1]), [\s],dnl | ||
32 | [m4_fatal([$0: First macro argument must not contain whitespaces])])dnl | ||
33 | m4_pushdef([varExtd],_mhd_norm_expd([$1]))dnl | ||
34 | m4_bmatch([$2],[\$],dnl | ||
35 | [dnl The second parameter is a variable value | ||
36 | AS_IF([test -z "_mhd_norm_expd([$2])"],dnl | ||
37 | [varExtd="${varExtd}"],dnl | ||
38 | [AS_IF([test -z "${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="_mhd_norm_expd([$2]) ${varExtd}"])]) | ||
39 | ],dnl | ||
40 | [dnl The second parameter is not a variable value | ||
41 | m4_ifnblank(_mhd_norm_expd([$2]),dnl | ||
42 | [AS_IF([test -z "${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="_mhd_norm_expd([$2]) ${varExtd}"]) | ||
43 | ],dnl | ||
44 | [m4_n([varExtd="${varExtd}"])])])dnl m4_ifnblank m4_bmatch | ||
45 | m4_popdef([varExtd])dnl | ||
46 | ])dnl AC_DEFUN | ||