xref: /aosp_15_r20/external/tpm2-tss/m4/flags.m4 (revision 758e9fba6fc9adbf15340f70c73baee7b168b1c9)
1*758e9fbaSOystein Eftevaagdnl ADD_COMPILER_FLAG:
2*758e9fbaSOystein Eftevaagdnl   A macro to add a CFLAG to the EXTRA_CFLAGS variable. This macro will
3*758e9fbaSOystein Eftevaagdnl   check to be sure the compiler supports the flag. Flags can be made
4*758e9fbaSOystein Eftevaagdnl   mandatory (configure will fail).
5*758e9fbaSOystein Eftevaagdnl $1: C compiler flag to add to EXTRA_CFLAGS.
6*758e9fbaSOystein Eftevaagdnl $2: Set to "required" to cause configure failure if flag not supported.
7*758e9fbaSOystein EftevaagAC_DEFUN([ADD_COMPILER_FLAG],[
8*758e9fbaSOystein Eftevaag    AX_CHECK_COMPILE_FLAG([$1],[
9*758e9fbaSOystein Eftevaag        EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
10*758e9fbaSOystein Eftevaag        AC_SUBST([EXTRA_CFLAGS])],[
11*758e9fbaSOystein Eftevaag        AS_IF([test x$2 != xrequired],[
12*758e9fbaSOystein Eftevaag            AC_MSG_WARN([Optional CFLAG "$1" not supported by your compiler, continuing.])],[
13*758e9fbaSOystein Eftevaag            AC_MSG_ERROR([Required CFLAG "$1" not supported by your compiler, aborting.])]
14*758e9fbaSOystein Eftevaag        )],[
15*758e9fbaSOystein Eftevaag        -Wall -Werror]
16*758e9fbaSOystein Eftevaag    )]
17*758e9fbaSOystein Eftevaag)
18*758e9fbaSOystein Eftevaagdnl ADD_PREPROC_FLAG:
19*758e9fbaSOystein Eftevaagdnl   Add the provided preprocessor flag to the EXTRA_CFLAGS variable. This
20*758e9fbaSOystein Eftevaagdnl   macro will check to be sure the preprocessor supports the flag.
21*758e9fbaSOystein Eftevaagdnl   The flag can be made mandatory by providing the string 'required' as
22*758e9fbaSOystein Eftevaagdnl   the second parameter.
23*758e9fbaSOystein Eftevaagdnl $1: Preprocessor flag to add to EXTRA_CFLAGS.
24*758e9fbaSOystein Eftevaagdnl $2: Set to "required" t ocause configure failure if preprocesor flag
25*758e9fbaSOystein Eftevaagdnl     is not supported.
26*758e9fbaSOystein EftevaagAC_DEFUN([ADD_PREPROC_FLAG],[
27*758e9fbaSOystein Eftevaag    AX_CHECK_PREPROC_FLAG([$1],[
28*758e9fbaSOystein Eftevaag        EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
29*758e9fbaSOystein Eftevaag        AC_SUBST([EXTRA_CFLAGS])],[
30*758e9fbaSOystein Eftevaag        AS_IF([test x$2 != xrequired],[
31*758e9fbaSOystein Eftevaag            AC_MSG_WARN([Optional preprocessor flag "$1" not supported by your compiler, continuing.])],[
32*758e9fbaSOystein Eftevaag            AC_MSG_ERROR([Required preprocessor flag "$1" not supported by your compiler, aborting.])]
33*758e9fbaSOystein Eftevaag        )],[
34*758e9fbaSOystein Eftevaag        -Wall -Werror]
35*758e9fbaSOystein Eftevaag    )]
36*758e9fbaSOystein Eftevaag)
37*758e9fbaSOystein Eftevaagdnl ADD_LINK_FLAG:
38*758e9fbaSOystein Eftevaagdnl   A macro to add a LDLAG to the EXTRA_LDFLAGS variable. This macro will
39*758e9fbaSOystein Eftevaagdnl   check to be sure the linker supports the flag. Flags can be made
40*758e9fbaSOystein Eftevaagdnl   mandatory (configure will fail).
41*758e9fbaSOystein Eftevaagdnl $1: linker flag to add to EXTRA_LDFLAGS.
42*758e9fbaSOystein Eftevaagdnl $2: Set to "required" to cause configure failure if flag not supported.
43*758e9fbaSOystein EftevaagAC_DEFUN([ADD_LINK_FLAG],[
44*758e9fbaSOystein Eftevaag    AX_CHECK_LINK_FLAG([$1],[
45*758e9fbaSOystein Eftevaag        EXTRA_LDFLAGS="$EXTRA_LDFLAGS $1"
46*758e9fbaSOystein Eftevaag        AC_SUBST([EXTRA_LDFLAGS])],[
47*758e9fbaSOystein Eftevaag        AS_IF([test x$2 != xrequired],[
48*758e9fbaSOystein Eftevaag            AC_MSG_WARN([Optional LDFLAG "$1" not supported by your linker, continuing.])],[
49*758e9fbaSOystein Eftevaag            AC_MSG_ERROR([Required LDFLAG "$1" not supported by your linker, aborting.])]
50*758e9fbaSOystein Eftevaag        )]
51*758e9fbaSOystein Eftevaag    )]
52*758e9fbaSOystein Eftevaag)
53*758e9fbaSOystein Eftevaagdnl ADD_FUZZING_FLAG:
54*758e9fbaSOystein Eftevaagdnl   A macro to add a CFLAG to the EXTRA_CFLAGS variable.
55*758e9fbaSOystein Eftevaagdnl $1: C++ linker flag to add to FUZZ_LDFLAGS.
56*758e9fbaSOystein EftevaagAC_DEFUN([ADD_FUZZING_FLAG],[
57*758e9fbaSOystein Eftevaag    FUZZ_LDFLAGS="$FUZZ_LDFLAGS $1"
58*758e9fbaSOystein Eftevaag    AC_SUBST([FUZZ_LDFLAGS])
59*758e9fbaSOystein Eftevaag])
60