--- /dev/null 2018-12-25 09:53:35.540064662 +0100 +++ new/make/autoconf/lib-softfloat.m4 2018-12-25 16:06:30.391182169 +0100 @@ -0,0 +1,161 @@ +# +# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# Setup softfloat library +################################################################################ +AC_DEFUN_ONCE([LIB_SETUP_SOFTFLOAT], +[ + # define options + AC_ARG_WITH(sflt, [AS_HELP_STRING([--with-sflt], + [specify prefix directory for the SoftFloat-3 prefix + (expecting PATH/lib/softfloat.a, PATH/include/softfloat.h and PATH/share/softfloat/softfloat.md)])]) + + AC_ARG_WITH(sflt-lib, [AS_HELP_STRING([--with-sflt-lib], + [specify the path to SoftFloat-3 static library])]) + + AC_ARG_WITH(sflt-include, [AS_HELP_STRING([--with-sflt-include], + [specify the path to SoftFloat-3 include directory])]) + + AC_ARG_WITH(sflt-license, [AS_HELP_STRING([--with-sflt-license], + [specify the path to SoftFloat-3 license file])]) + + # check if softfloat can be used and if the user enabled it + AC_MSG_CHECKING([if softfloat library should be used]) + if test "x$USES_LIB_SOFTFLOAT" = "xtrue"; then + SOFTFLOAT_SPECIFIED=no + + if test "x${with_sflt}" != x; then + if test "x${with_sflt}" = "xyes" || test "x${with_sflt}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt must have a value]) + fi + SOFTFLOAT_CFLAGS="-I${with_sflt}/include -DSOFTFLOAT_EXTERNAL" + SOFTFLOAT_LIBS="${with_sflt}/lib/softfloat.a" + SOFTFLOAT_SPECIFIED=yes + fi + if test "x${with_sflt_include}" != x; then + if test "x${with_sflt_include}" = "xyes" || test "x${with_sflt_include}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-include must have a value]) + fi + SOFTFLOAT_CFLAGS="-I${with_sflt_include} -DSOFTFLOAT_EXTERNAL" + SOFTFLOAT_SPECIFIED=yes + fi + if test "x${with_sflt_lib}" != x; then + if test "x${with_sflt_lib}" = "xyes" || test "x${with_sflt_lib}" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-lib must have a value]) + fi + SOFTFLOAT_LIBS="${with_sflt_lib}" + SOFTFLOAT_SPECIFIED=yes + fi + + if test "x$SOFTFLOAT_SPECIFIED" = xno; then + AC_MSG_RESULT([no, system softfp used]) + AC_MSG_NOTICE([Floating point operations may be less precise by a very small amount]) + SOFTFLOAT_LICENSE= + SOFTFLOAT_CFLAGS= + SOFTFLOAT_LIBS= + else + AC_MSG_RESULT([yes]) + + AC_MSG_CHECKING([for softfloat preprocessor flags]) + AC_MSG_RESULT([$SOFTFLOAT_CFLAGS]) + + AC_MSG_CHECKING([for softfloat linker flags]) + AC_MSG_RESULT([$SOFTFLOAT_LIBS]) + + AC_MSG_CHECKING([if softfloat works]) + AC_LANG_PUSH(C) + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $SOFTFLOAT_CFLAGS" + OLD_LIBS="$LIBS" + LIBS="$LIBS $SOFTFLOAT_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [ + return f32_to_i32(f32_sub(i32_to_f32(1), i32_to_f32(1)), softfloat_round_near_even, false); + ])], + [SOFTFLOAT_WORKS=yes], + [SOFTFLOAT_WORKS=no] + ) + CFLAGS="$OLD_CFLAGS" + LIBS="$OLD_LIBS" + AC_LANG_POP(C) + AC_MSG_RESULT([$SOFTFLOAT_WORKS]) + + if test "x$SOFTFLOAT_WORKS" = xno; then + HELP_MSG_MISSING_DEPENDENCY([softfloat]) + AC_MSG_ERROR([Found softfloat but could not link and compile with it. $HELP_MSG]) + fi + + SOFTFLOAT_LICENSE="" + AC_MSG_CHECKING([for softfloat license]) + + if test "x$with_sflt_license" = "xyes" || test "x$with_sflt_license" = "xno"; then + AC_MSG_RESULT([error]) + AC_MSG_ERROR([--with-sflt-license must have a value]) + elif test "x$with_sflt_license" != "x"; then + AC_MSG_RESULT([$with_sflt_license]) + SOFTFLOAT_LICENSE="$with_sflt_license" + BASIC_FIXUP_PATH(SOFTFLOAT_LICENSE) + if test ! -f "$SOFTFLOAT_LICENSE"; then + AC_MSG_ERROR([$SOFTFLOAT_LICENSE cannot be found]) + fi + else + if test "x$with_sflt" != "x" && test -f "$with_sflt/share/softfloat/softfloat.md"; then + SOFTFLOAT_LICENSE="$with_sflt/share/softfloat/softfloat.md" + AC_MSG_RESULT([$SOFTFLOAT_LICENSE]) + BASIC_FIXUP_PATH(SOFTFLOAT_LICENSE) + else + AC_MSG_RESULT([error]) + AC_MSG_ERROR([softfloat license file cannot be found]) + fi + fi + + fi + else + AC_MSG_RESULT([no, not needed]) + if test "x${with_sflt}" != x && test "x${with_sflt}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt is ignored]]) + fi + if test "x${with_sflt_lib}" != x && test "x${with_sflt_lib}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-lib is ignored]]) + fi + if test "x${with_sflt_include}" != x && test "x${with_sflt_include}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-include is ignored]]) + fi + if test "x${with_sflt_license}" != x && test "x${with_sflt_license}" != xno; then + AC_MSG_WARN([[not building for sflt, so --with-sflt-license is ignored]]) + fi + SOFTFLOAT_CFLAGS= + SOFTFLOAT_LIBS= + SOFTFLOAT_LICENSE= + fi + + AC_SUBST(SOFTFLOAT_LIBS) + AC_SUBST(SOFTFLOAT_CFLAGS) + AC_SUBST(SOFTFLOAT_LICENSE) +])