We need an autoconf macro that determines if -m64 is a valid compiler option

I have code that I want to compile on all Unix systems, but if -m64 is available and it works, I want the configure script to use it. How to get autoconf to check if -m64 works and if so, use it?

+4
source share
2 answers
  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 assembly implies automake (or using AM_CFLAGS in your own non-automatic makefiles.)

+9
source
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]) 
+2
source

All Articles