blob: 8dcee7d0e58d3c6a03af2873876cd8e4ce9d8ac1 [file] [log] [blame]
Philip Tricca27447812017-03-08 14:29:49 -08001dnl AX_ADD_COMPILER_FLAG:
2dnl A macro to add a CFLAG to the EXTRA_CFLAGS variable. This macro will
dantpm4db13b02018-04-06 14:30:28 -07003dnl check to be sure the compiler supports the flag. Flags can be made
Philip Tricca27447812017-03-08 14:29:49 -08004dnl mandatory (configure will fail).
5dnl $1: C compiler flag to add to EXTRA_CFLAGS.
dantpm4db13b02018-04-06 14:30:28 -07006dnl $2: Set to "required" to cause configure failure if flag not supported.
Philip Tricca27447812017-03-08 14:29:49 -08007AC_DEFUN([AX_ADD_COMPILER_FLAG],[
8 AX_CHECK_COMPILE_FLAG([$1],[
9 EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
10 AC_SUBST([EXTRA_CFLAGS])],[
11 AS_IF([test x$2 != xrequired],[
12 AC_MSG_WARN([Optional CFLAG "$1" not supported by your compiler, continuing.])],[
13 AC_MSG_ERROR([Required CFLAG "$1" not supported by your compiler, aborting.])]
Philip Triccac3a8fdc2017-09-21 21:01:42 -070014 )],[
15 -Wall -Werror]
Philip Tricca27447812017-03-08 14:29:49 -080016 )]
17)
18dnl AX_ADD_PREPROC_FLAG:
19dnl Add the provided preprocessor flag to the EXTRA_CFLAGS variable. This
20dnl macro will check to be sure the preprocessor supports the flag.
dantpm4db13b02018-04-06 14:30:28 -070021dnl The flag can be made mandatory by providing the string 'required' as
Philip Tricca27447812017-03-08 14:29:49 -080022dnl the second parameter.
23dnl $1: Preprocessor flag to add to EXTRA_CFLAGS.
24dnl $2: Set to "required" t ocause configure failure if preprocesor flag
25dnl is not supported.
26AC_DEFUN([AX_ADD_PREPROC_FLAG],[
27 AX_CHECK_PREPROC_FLAG([$1],[
28 EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
29 AC_SUBST([EXTRA_CFLAGS])],[
30 AS_IF([test x$2 != xrequired],[
31 AC_MSG_WARN([Optional preprocessor flag "$1" not supported by your compiler, continuing.])],[
32 AC_MSG_ERROR([Required preprocessor flag "$1" not supported by your compiler, aborting.])]
Philip Tricca198e8972017-09-26 10:47:04 -070033 )],[
34 -Wall -Werror]
Philip Tricca27447812017-03-08 14:29:49 -080035 )]
36)
37dnl AX_ADD_LINK_FLAG:
38dnl A macro to add a LDLAG to the EXTRA_LDFLAGS variable. This macro will
dantpm4db13b02018-04-06 14:30:28 -070039dnl check to be sure the linker supports the flag. Flags can be made
Philip Tricca27447812017-03-08 14:29:49 -080040dnl mandatory (configure will fail).
41dnl $1: linker flag to add to EXTRA_LDFLAGS.
42dnl $2: Set to "required" to cause configure failure if flag not supported.
43AC_DEFUN([AX_ADD_LINK_FLAG],[
44 AX_CHECK_LINK_FLAG([$1],[
45 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $1"
46 AC_SUBST([EXTRA_LDFLAGS])],[
47 AS_IF([test x$2 != xrequired],[
48 AC_MSG_WARN([Optional LDFLAG "$1" not supported by your linker, continuing.])],[
49 AC_MSG_ERROR([Required LDFLAG "$1" not supported by your linker, aborting.])]
50 )]
51 )]
52)