Home | History | Annotate | Line # | Download | only in cf
mips-abi.m4 revision 1.1.1.1
      1  1.1  elric dnl $Id: mips-abi.m4,v 1.1.1.1 2011/04/13 18:14:32 elric Exp $
      2  1.1  elric dnl
      3  1.1  elric dnl
      4  1.1  elric dnl Check for MIPS/IRIX ABI flags. Sets $abi and $abilibdirext to some
      5  1.1  elric dnl value.
      6  1.1  elric 
      7  1.1  elric AC_DEFUN([AC_MIPS_ABI], [
      8  1.1  elric AC_ARG_WITH(mips_abi,
      9  1.1  elric 	AS_HELP_STRING([--with-mips-abi=abi],[ABI to use for IRIX (32, n32, or 64)]))
     10  1.1  elric 
     11  1.1  elric case "$host_os" in
     12  1.1  elric irix*)
     13  1.1  elric with_mips_abi="${with_mips_abi:-yes}"
     14  1.1  elric if test -n "$GCC"; then
     15  1.1  elric 
     16  1.1  elric # GCC < 2.8 only supports the O32 ABI. GCC >= 2.8 has a flag to select
     17  1.1  elric # which ABI to use, but only supports (as of 2.8.1) the N32 and 64 ABIs.
     18  1.1  elric #
     19  1.1  elric # Default to N32, but if GCC doesn't grok -mabi=n32, we assume an old
     20  1.1  elric # GCC and revert back to O32. The same goes if O32 is asked for - old
     21  1.1  elric # GCCs doesn't like the -mabi option, and new GCCs can't output O32.
     22  1.1  elric #
     23  1.1  elric # Don't you just love *all* the different SGI ABIs?
     24  1.1  elric 
     25  1.1  elric case "${with_mips_abi}" in 
     26  1.1  elric         32|o32) abi='-mabi=32';  abilibdirext=''     ;;
     27  1.1  elric        n32|yes) abi='-mabi=n32'; abilibdirext='32'  ;;
     28  1.1  elric         64) abi='-mabi=64';  abilibdirext='64'   ;;
     29  1.1  elric 	no) abi=''; abilibdirext='';;
     30  1.1  elric          *) AC_MSG_ERROR("Invalid ABI specified") ;;
     31  1.1  elric esac
     32  1.1  elric if test -n "$abi" ; then
     33  1.1  elric ac_foo=krb_cv_gcc_`echo $abi | tr =- __`
     34  1.1  elric dnl
     35  1.1  elric dnl can't use AC_CACHE_CHECK here, since it doesn't quote CACHE-ID to
     36  1.1  elric dnl AC_MSG_RESULT
     37  1.1  elric dnl
     38  1.1  elric AC_MSG_CHECKING([if $CC supports the $abi option])
     39  1.1  elric AC_CACHE_VAL($ac_foo, [
     40  1.1  elric save_CFLAGS="$CFLAGS"
     41  1.1  elric CFLAGS="$CFLAGS $abi"
     42  1.1  elric AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[int x;]])],[eval $ac_foo=yes], [eval $ac_foo=no])dnl
     43  1.1  elric CFLAGS="$save_CFLAGS"
     44  1.1  elric ])
     45  1.1  elric ac_res=`eval echo \\\$$ac_foo`
     46  1.1  elric AC_MSG_RESULT($ac_res)
     47  1.1  elric if test $ac_res = no; then
     48  1.1  elric # Try to figure out why that failed...
     49  1.1  elric case $abi in
     50  1.1  elric 	-mabi=32) 
     51  1.1  elric 	save_CFLAGS="$CFLAGS"
     52  1.1  elric 	CFLAGS="$CFLAGS -mabi=n32"
     53  1.1  elric 	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[int x;]])],[ac_res=yes],[ac_res=no])dnl
     54  1.1  elric 	CLAGS="$save_CFLAGS"
     55  1.1  elric 	if test $ac_res = yes; then
     56  1.1  elric 		# New GCC
     57  1.1  elric 		AC_MSG_ERROR([$CC does not support the $with_mips_abi ABI])
     58  1.1  elric 	fi
     59  1.1  elric 	# Old GCC
     60  1.1  elric 	abi=''
     61  1.1  elric 	abilibdirext=''
     62  1.1  elric 	;;
     63  1.1  elric 	-mabi=n32|-mabi=64)
     64  1.1  elric 		if test $with_mips_abi = yes; then
     65  1.1  elric 			# Old GCC, default to O32
     66  1.1  elric 			abi=''
     67  1.1  elric 			abilibdirext=''
     68  1.1  elric 		else
     69  1.1  elric 			# Some broken GCC
     70  1.1  elric 			AC_MSG_ERROR([$CC does not support the $with_mips_abi ABI])
     71  1.1  elric 		fi
     72  1.1  elric 	;;
     73  1.1  elric esac
     74  1.1  elric fi #if test $ac_res = no; then
     75  1.1  elric fi #if test -n "$abi" ; then
     76  1.1  elric else
     77  1.1  elric case "${with_mips_abi}" in
     78  1.1  elric         32|o32) abi='-32'; abilibdirext=''     ;;
     79  1.1  elric        n32|yes) abi='-n32'; abilibdirext='32'  ;;
     80  1.1  elric         64) abi='-64'; abilibdirext='64'   ;;
     81  1.1  elric 	no) abi=''; abilibdirext='';;
     82  1.1  elric          *) AC_MSG_ERROR("Invalid ABI specified") ;;
     83  1.1  elric esac
     84  1.1  elric fi #if test -n "$GCC"; then
     85  1.1  elric ;;
     86  1.1  elric esac
     87  1.1  elric ])
     88