libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

mhd_append_flag_to_var.m4 (1770B)


      1 # SPDX-License-Identifier: FSFAP
      2 #
      3 # SYNOPSIS
      4 #
      5 #   MHD_APPEND_FLAG_TO_VAR([VARIABLE-TO-EXTEND], [FLAG-TO-APPEND])
      6 #
      7 # DESCRIPTION
      8 #
      9 #   This macro sets VARIABLE-TO-EXTEND to the value of VARIABLE-TO-EXTEND with
     10 #   appended FLAG-TO-APPEND. If current value of VARIABLE-TO-EXTEND and
     11 #   FLAG-TO-APPEND are both non-empty strings then space is added between them.
     12 #
     13 #   Example usage:
     14 #
     15 #     MHD_APPEND_FLAG_TO_VAR([my_CFLAGS], [-Wall])
     16 #
     17 #
     18 # LICENSE
     19 #
     20 #   Copyright (c) 2022 Karlson2k (Evgeny Grin) <k2k@narod.ru>
     21 #
     22 #   Copying and distribution of this file, with or without modification, are
     23 #   permitted in any medium without royalty provided the copyright notice
     24 #   and this notice are preserved. This file is offered as-is, without any
     25 #   warranty.
     26 
     27 #serial 2
     28 
     29 AC_DEFUN([MHD_APPEND_FLAG_TO_VAR],[dnl
     30 m4_ifblank([$1],[m4_fatal([$0: First macro argument must not be empty])])dnl
     31 m4_bmatch([$1], [\$], [m4_fatal([$0: First macro argument must not contain '$'])])dnl
     32 m4_bmatch([$1], [,], [m4_fatal([$0: First macro argument must not contain ','])])dnl
     33 m4_bmatch(_mhd_norm_expd([$1]), [\s],dnl
     34 [m4_fatal([$0: First macro argument must not contain whitespaces])])dnl
     35 m4_pushdef([varExtd],_mhd_norm_expd([$1]))dnl
     36 m4_bmatch([$2],[\$],dnl
     37 [dnl The second parameter is a variable value
     38 AS_IF([test -z "_mhd_norm_expd([$2])"],dnl
     39 [varExtd="${varExtd}"],dnl
     40 [test -z "${varExtd}"],dnl
     41 [varExtd="_mhd_norm_expd([$2])"],dnl
     42 [varExtd="${varExtd} _mhd_norm_expd([$2])"])
     43 ],dnl
     44 [dnl The second parameter is not a variable value
     45 m4_ifnblank(_mhd_norm_expd([$2]),dnl
     46 [AS_IF([test -z "${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="${varExtd} _mhd_norm_expd([$2])"])
     47 ],dnl
     48 [m4_n([varExtd="${varExtd}"])])])dnl m4_ifnblank m4_bmatch
     49 m4_popdef([varExtd])dnl
     50 ])dnl AC_DEFUN