| 1 |
# SYNOPSIS |
| 2 |
# |
| 3 |
# MHD_CHECK_ADD_CC_CFLAG([FLAG-TO-TEST], [VARIABLE-TO-EXTEND], |
| 4 |
# [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED]) |
| 5 |
# |
| 6 |
# DESCRIPTION |
| 7 |
# |
| 8 |
# This macro checks whether the specific compiler flag is supported. |
| 9 |
# The check is performing by appending FLAG-TO-TEST to the value of |
| 10 |
# VARIABLE-TO-EXTEND (CFLAGS if not specified), then prepending result to |
| 11 |
# CFLAGS (unless VARIABLE-TO-EXTEND is CFLAGS), and then performing compile |
| 12 |
# and link test. If test succeed without warnings, then the flag is added to |
| 13 |
# VARIABLE-TO-EXTEND. Otherwise, if compile and link without test flag cannot |
| 14 |
# be done without any warning, the flag is considered to be unsuppoted. |
| 15 |
# |
| 16 |
# Example usage: |
| 17 |
# |
| 18 |
# MHD_CHECK_ADD_CC_CFLAG([-Wshadow], [additional_CFLAGS]) |
| 19 |
# |
| 20 |
# |
| 21 |
# LICENSE |
| 22 |
# |
| 23 |
# Copyright (c) 2022 Karlson2k (Evgeny Grin) <[email protected]> |
| 24 |
# |
| 25 |
# Copying and distribution of this file, with or without modification, are |
| 26 |
# permitted in any medium without royalty provided the copyright notice |
| 27 |
# and this notice are preserved. This file is offered as-is, without any |
| 28 |
# warranty. |
| 29 |
|
| 30 |
#serial 1 |
| 31 |
|
| 32 |
AC_DEFUN([MHD_CHECK_ADD_CC_CFLAG],[dnl |
| 33 |
_MHD_CHECK_ADD_CC_XFLAG([$1],[$2],[$3],[$4],[[CFLAGS]])dnl |
| 34 |
]) |
| 35 |
|
| 36 |
|
| 37 |
# SYNOPSIS |
| 38 |
# |
| 39 |
# _MHD_CHECK_ADD_CC_XFLAG([FLAG-TO-TEST], [VARIABLE-TO-EXTEND], |
| 40 |
# [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED], |
| 41 |
# [CFLAGS|LDFLAGS]) |
| 42 |
# |
| 43 |
AC_DEFUN([_MHD_CHECK_ADD_CC_XFLAG],[dnl |
| 44 |
AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank, m4_default |
| 45 |
AC_LANG_ASSERT([C])dnl |
| 46 |
m4_ifblank([$1], [m4_fatal([First macro argument must not be empty])])dnl |
| 47 |
m4_bmatch(_mhd_norm_expd([$1]), [\s],dnl |
| 48 |
[m4_fatal([First macro argument must not contain whitespaces])])dnl |
| 49 |
m4_bmatch(_mhd_norm_expd([$2]), [\s],dnl |
| 50 |
[m4_fatal([Second macro argument must not contain whitespaces])])dnl |
| 51 |
m4_bmatch([$1], [\$], [m4_fatal([$0: First macro argument must not contain '$'])])dnl |
| 52 |
m4_bmatch([$2], [\$], [m4_fatal([$0: Second macro argument must not contain '$'])])dnl |
| 53 |
m4_bmatch(_mhd_norm_expd([$5]), [^\(CFLAGS\|LDFLAGS\)$],[],dnl |
| 54 |
[m4_fatal([$0: Fifth macro argument must be either 'CFLAGS' or 'LDFLAGS; ']_mhd_norm_expd([$5])[' is not supported])])dnl |
| 55 |
m4_ifnblank([$2], |
| 56 |
[_MHD_CHECK_CC_XFLAG([$1], [$2], |
| 57 |
[MHD_APPEND_FLAG_TO_VAR(_mhd_norm_expd([$2]),_mhd_norm_expd([$1])) |
| 58 |
$3],[$4],[$5])], |
| 59 |
[_MHD_CHECK_CC_XFLAG([$1],_mhd_norm_expd([$5]), |
| 60 |
[MHD_APPEND_FLAG_TO_VAR(_mhd_norm_expd([$5]),_mhd_norm_expd([$1])) |
| 61 |
$3],[$4],[$5])] |
| 62 |
) |
| 63 |
]) |