aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPhilip Tricca <philip.b.tricca@intel.com>2017-03-08 14:29:49 -0800
committerPhilip Tricca <philip.b.tricca@intel.com>2017-03-08 14:57:03 -0800
commit2744781e04959c88bef84f7a665753e207a23712 (patch)
tree73aa7a5b0b09bae8402236fefa87b7571cd0b036 /m4
parent5b285cec96ffd2497e6b398492f73696efb85d9a (diff)
downloadtpm2-tss-2744781e04959c88bef84f7a665753e207a23712.tar.gz
configure.ac: Move compiler / preproc / link flag macros to m4/.
This also renames these macros to align better with autoconf conventions (puts them in the AX_ namespace & uppercase name) and fixes a bug in the AX_ADD_LINK_FLAG macro where flags were being added to EXTRA_CFLAGS instead of EXTRA_LDFLAGS. Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
Diffstat (limited to 'm4')
-rw-r--r--m4/flags.m450
1 files changed, 50 insertions, 0 deletions
diff --git a/m4/flags.m4 b/m4/flags.m4
new file mode 100644
index 00000000..d5ed9445
--- /dev/null
+++ b/m4/flags.m4
@@ -0,0 +1,50 @@
+dnl AX_ADD_COMPILER_FLAG:
+dnl A macro to add a CFLAG to the EXTRA_CFLAGS variable. This macro will
+dnl check to be sure the compiler supprts the flag. Flags can be made
+dnl mandatory (configure will fail).
+dnl $1: C compiler flag to add to EXTRA_CFLAGS.
+dnl $2: Set to "required" to cause configure failure if flag not supported..
+AC_DEFUN([AX_ADD_COMPILER_FLAG],[
+ AX_CHECK_COMPILE_FLAG([$1],[
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
+ AC_SUBST([EXTRA_CFLAGS])],[
+ AS_IF([test x$2 != xrequired],[
+ AC_MSG_WARN([Optional CFLAG "$1" not supported by your compiler, continuing.])],[
+ AC_MSG_ERROR([Required CFLAG "$1" not supported by your compiler, aborting.])]
+ )]
+ )]
+)
+dnl AX_ADD_PREPROC_FLAG:
+dnl Add the provided preprocessor flag to the EXTRA_CFLAGS variable. This
+dnl macro will check to be sure the preprocessor supports the flag.
+dnl The flag can be made mandatory by provideing the string 'required' as
+dnl the second parameter.
+dnl $1: Preprocessor flag to add to EXTRA_CFLAGS.
+dnl $2: Set to "required" t ocause configure failure if preprocesor flag
+dnl is not supported.
+AC_DEFUN([AX_ADD_PREPROC_FLAG],[
+ AX_CHECK_PREPROC_FLAG([$1],[
+ EXTRA_CFLAGS="$EXTRA_CFLAGS $1"
+ AC_SUBST([EXTRA_CFLAGS])],[
+ AS_IF([test x$2 != xrequired],[
+ AC_MSG_WARN([Optional preprocessor flag "$1" not supported by your compiler, continuing.])],[
+ AC_MSG_ERROR([Required preprocessor flag "$1" not supported by your compiler, aborting.])]
+ )]
+ )]
+)
+dnl AX_ADD_LINK_FLAG:
+dnl A macro to add a LDLAG to the EXTRA_LDFLAGS variable. This macro will
+dnl check to be sure the linker supprts the flag. Flags can be made
+dnl mandatory (configure will fail).
+dnl $1: linker flag to add to EXTRA_LDFLAGS.
+dnl $2: Set to "required" to cause configure failure if flag not supported.
+AC_DEFUN([AX_ADD_LINK_FLAG],[
+ AX_CHECK_LINK_FLAG([$1],[
+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $1"
+ AC_SUBST([EXTRA_LDFLAGS])],[
+ AS_IF([test x$2 != xrequired],[
+ AC_MSG_WARN([Optional LDFLAG "$1" not supported by your linker, continuing.])],[
+ AC_MSG_ERROR([Required LDFLAG "$1" not supported by your linker, aborting.])]
+ )]
+ )]
+)