libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

mhd_prepend_flag_to_var.m4 (1739B)


      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 2
     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 [test -z "${varExtd}"],dnl
     39 [varExtd="_mhd_norm_expd([$2])"],dnl
     40 [varExtd="_mhd_norm_expd([$2]) ${varExtd}"])
     41 ],dnl
     42 [dnl The second parameter is not a variable value
     43 m4_ifnblank(_mhd_norm_expd([$2]),dnl
     44 [AS_IF([test -z "${varExtd}"],[varExtd="_mhd_norm_expd([$2])"],[varExtd="_mhd_norm_expd([$2]) ${varExtd}"])
     45 ],dnl
     46 [m4_n([varExtd="${varExtd}"])])])dnl m4_ifnblank m4_bmatch
     47 m4_popdef([varExtd])dnl
     48 ])dnl AC_DEFUN