I have code that I want to compile on all unix systems, but if -m64 i available and it works, I want the configure script to use it. How do I get autoconf to check to see if -m64 works and, if so, use it?
my_save_cflags="$CFLAGS" CFLAGS=-m64 AC_MSG_CHECKING([whether CC supports -m64]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes])] [AM_CFLAGS=-m64], [AC_MSG_RESULT([no])] ) CFLAGS="$my_save_cflags" AC_SUBST([AM_CFLAGS])
Using AM_CFLAGS to add -m64 to the build assumes automake (or the use of AM_CFLAGS in your own non-automade makefiles.)
dnl @synopsis CXX_FLAGS_CHECK [compiler flags]
dnl @summary check whether compiler supports given C++ flags or not
AC_DEFUN([CXX_FLAG_CHECK],
[dnl
AC_MSG_CHECKING([if $CXX supports $1])
AC_LANG_PUSH([C++])
ac_saved_cxxflags="$CXXFLAGS"
CXXFLAGS="-Werror $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([no])]
)
CXXFLAGS="$ac_saved_cxxflags"
AC_LANG_POP([C++])
])
And use
CXX_FLAGS_CHECK([-m64])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With