This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

autoconf macro for IEEE compiler flags


Hello,

I recently discovered that another project I'm involved with doesn't
compile properly on Alpha using GCC unless option -mieee is used
[http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=368263].  I thought
to fix it by writing an autoconf macro, below, that I plan to place in
the autoconf macro archive http://autoconf-archive.cryp.to/

The reason for posting here is to get some feedback from the gsl
developers because (a) gsl developers are more aware of IEEE
arithmetic issues than most, and (b) I cribbed the main part of the
macro from GSL's configure script.  ;-)

The main differences between GSL's current configure and the new macro
are: (1) I chose to modify CC rather than CFLAGS, following the model
of the standard automake macro AM_PROG_CC_STDC; and (2) I added the SH
cpu to the case switch because it, too, supports option -mieee.

Comments? 

-Steve


dnl @synopsis AX_PROG_CC_IEEE
dnl
dnl Ensure that the compiler is emitting IEEE floating point arithmetic.
dnl This macro modifies the variable CC, adding any options required.
dnl
dnl @category C
dnl @author Steve Robbins <smr@debian.org>
dnl @version 2006-07-19
dnl @license AllPermissive

AC_DEFUN([AX_PROG_CC_IEEE],
[
    AC_REQUIRE([AC_PROG_CC])
    AC_REQUIRE([AC_CANONICAL_HOST])

    AC_CACHE_CHECK([for ${CC-cc} option to enable IEEE floating point],
                   ax_cv_prog_cc_ieee,
    [
	case "$host_cpu" in
	    alpha*)
	        if test X"$GCC" = Xyes ; then
        	    ax_cv_prog_cc_ieee='-mieee -mfp-rounding-mode=d'
	        else
	            # This assumes Compaq's C compiler.
	            ax_cv_prog_cc_ieee='-ieee -fprm d'
	        fi
	        ;;
	    sh*)
	        if test X"$GCC" = Xyes ; then
        	    ax_cv_prog_cc_ieee='-mieee'
		fi
		;;
	esac

	if test X"$ax_cv_prog_cc_ieee" == X ; then
	    ax_cv_prog_cc_ieee="none"
	else
	    ac_save_CC="$CC"
	    AC_LANG_PUSH(C)
	    CC="$CC $ax_cv_prog_cc_ieee"
	    AC_COMPILE_IFELSE([int foo;],
                              [],
                              [ax_cv_prog_cc_ieee="none"])
	    CC="$ac_save_CC"
	    AC_LANG_POP
	fi
    ])

    case "x$ax_cv_prog_cc_ieee" in
	x|xnone) ;;
	*) CC="$CC $ax_cv_prog_cc_ieee" ;;
    esac
])


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]