Debian Codegraph @

libgcobol/acinclude.m4

raw
1 dnl Copyright (C) 2021-2025 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl This program is distributed in the hope that it will be useful,
7 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
8 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9 dnl PARTICULAR PURPOSE.
10
11 m4_include(../config/acx.m4)
12 m4_include(../config/no-executables.m4)
13 m4_include(../config/enable.m4)
14 m4_include(../config/tls.m4)
15 m4_include(../config/bitfields.m4)
16
17 m4_include(../libtool.m4)
18 dnl The lines below arrange for aclocal not to bring an installed
19 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
20 dnl add a definition of LIBTOOL to Makefile.in.
21 ifelse(yes,no,[
22 AC_DEFUN([AM_PROG_LIBTOOL],)
23 AC_DEFUN([AC_LIBTOOL_DLOPEN],)
24 AC_DEFUN([AC_LIBLTDL_CONVENIENCE],)
25 AC_SUBST(LIBTOOL)
26 ])
27
28 dnl Check whether we have a __float128 and _Float128 type
29 dnl Unashamedly plagiarized from libgfortran.
30
31 AC_DEFUN([LIBGCOBOL_CHECK_FLOAT128], [
32 LIBQUADSPEC=
33 LIBQUADLIB=
34 LIBQUADLIB_DEP=
35 LIBQUADINCLUDE=
36 USE_IEC_60559=no
37
38 if test "x$enable_libquadmath_support" = "xno"; then
39 if test "x$have_iec_60559_libc_support" = "xyes"; then
40 AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
41 fi
42 else
43
44 AC_CACHE_CHECK([whether we have a usable _Float128 type],
45 libgcob_cv_have_float128, [
46 GCC_TRY_COMPILE_OR_LINK([
47 #if __LDBL_MANT_DIG__ == 113 && __LDBL_MIN_EXP__ == -16381
48 #error "long double is IEEE quad, no need for libquadmath"
49 #endif
50
51 _Float128 foo (_Float128 x)
52 {
53 _Complex _Float128 z1, z2;
54
55 z1 = x;
56 z2 = x / 7.F128;
57 z2 /= z1;
58
59 return __real__ z2;
60 }
61
62 _Float128 bar (_Float128 x)
63 {
64 return x * __builtin_huge_valf128 ();
65 }
66
67 __float128 baz (__float128 x)
68 {
69 return x * __builtin_huge_valf128 ();
70 }
71 ],[
72 foo (1.2F128);
73 bar (1.2F128);
74 baz (1.2F128);
75 foo (1.2Q);
76 bar (1.2Q);
77 baz (1.2Q);
78 ],[
79 libgcob_cv_have_float128=yes
80 ],[
81 libgcob_cv_have_float128=no
82 ])])
83
84 if test "x$have_iec_60559_libc_support$enable_libquadmath_support$libgcob_cv_have_float128" = xyesdefaultyes; then
85 USE_IEC_60559=yes
86 fi
87
88 if test "x$libgcob_cv_have_float128" = xyes; then
89
90 if test "x$USE_IEC_60559" = xyes; then
91 AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
92 else
93 AC_DEFINE(USE_QUADMATH, 1, [Define if *q APIs should be used for __float128.])
94 fi
95 AC_DEFINE(HAVE_FLOAT128, 1, [Define if target has usable _Float128 and __float128 types.])
96
97 if test "x$USE_IEC_60559" != xyes; then
98 dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
99 dnl
100 dnl Turn warnings into error to avoid testsuite breakage. So enable
101 dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
102 dnl it off again. As a workaround, save and restore werror flag like
103 dnl AC_PATH_XTRA.
104 dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
105 ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
106 AC_CACHE_CHECK([whether --as-needed/-z ignore works],
107 [libgcob_cv_have_as_needed],
108 [
109 # Test for native Solaris options first.
110 # No whitespace after -z to pass it through -Wl.
111 libgcob_cv_as_needed_option="-zignore"
112 libgcob_cv_no_as_needed_option="-zrecord"
113 save_LDFLAGS="$LDFLAGS"
114 LDFLAGS="$LDFLAGS -Wl,$libgcob_cv_as_needed_option -lm -Wl,$libgcob_cv_no_as_needed_option"
115 libgcob_cv_have_as_needed=no
116 AC_LANG_WERROR
117 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
118 [libgcob_cv_have_as_needed=yes],
119 [libgcob_cv_have_as_needed=no])
120 LDFLAGS="$save_LDFLAGS"
121 if test "x$libgcob_cv_have_as_needed" = xno; then
122 libgcob_cv_as_needed_option="--as-needed"
123 libgcob_cv_no_as_needed_option="--no-as-needed"
124 save_LDFLAGS="$LDFLAGS"
125 LDFLAGS="$LDFLAGS -Wl,$libgcob_cv_as_needed_option -lm -Wl,$libgcob_cv_no_as_needed_option"
126 libgcob_cv_have_as_needed=no
127 AC_LANG_WERROR
128 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
129 [libgcob_cv_have_as_needed=yes],
130 [libgcob_cv_have_as_needed=no])
131 LDFLAGS="$save_LDFLAGS"
132 fi
133 ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
134 ])
135
136 dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran -### stderr.
137 touch conftest1.$ac_objext conftest2.$ac_objext
138 LQUADMATH=-lquadmath
139 $CXX -static-libgcobol -### -o conftest \
140 conftest1.$ac_objext -lgcobol conftest2.$ac_objext 2>&1 >/dev/null \
141 | grep "conftest1.$ac_objext.*conftest2.$ac_objext" > conftest.cmd
142 if grep "conftest1.$ac_objext.* -Bstatic -lgcobol -Bdynamic .*conftest2.$ac_objext" \
143 conftest.cmd >/dev/null 2>&1; then
144 LQUADMATH="%{static-libquadmath:-Bstatic} -lquadmath %{static-libquadmath:-Bdynamic}"
145 elif grep "conftest1.$ac_objext.* -bstatic -lgcobol -bdynamic .*conftest2.$ac_objext" \
146 conftest.cmd >/dev/null 2>&1; then
147 LQUADMATH="%{static-libquadmath:-bstatic} -lquadmath %{static-libquadmath:-bdynamic}"
148 elif grep "conftest1.$ac_objext.* -aarchive_shared -lgcobol -adefault .*conftest2.$ac_objext" \
149 conftest.cmd >/dev/null 2>&1; then
150 LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}"
151 elif grep "conftest1.$ac_objext.*libgcobol.a .*conftest2.$ac_objext" \
152 conftest.cmd >/dev/null 2>&1; then
153 LQUADMATH="%{static-libquadmath:libquadmath.a%s;:-lquadmath}"
154 fi
155 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest conftest.cmd
156
157 if test "x$libgcob_cv_have_as_needed" = xyes; then
158 if test "x$USE_IEC_60559" = xyes; then
159 LIBQUADSPEC="$libgcob_cv_as_needed_option $LQUADMATH $libgcob_cv_no_as_needed_option"
160 else
161 LIBQUADSPEC="%{static-libgcobol:$libgcob_cv_as_needed_option} $LQUADMATH %{static-libgcobol:$libgcob_cv_no_as_needed_option}"
162 fi
163 else
164 LIBQUADSPEC="$LQUADMATH"
165 fi
166 if test -f ../libquadmath/libquadmath.la; then
167 LIBQUADLIB=../libquadmath/libquadmath.la
168 LIBQUADLIB_DEP=../libquadmath/libquadmath.la
169 LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
170 else
171 LIBQUADLIB="-lquadmath"
172 fi
173 fi
174 else
175 if test "x$USE_IEC_60559" = xyes; then
176 AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
177 fi
178 fi
179
180 fi
181
182 dnl For the spec file
183 AC_SUBST(LIBQUADSPEC)
184 AC_SUBST(LIBQUADLIB)
185 AC_SUBST(LIBQUADLIB_DEP)
186 AC_SUBST(LIBQUADINCLUDE)
187 AC_SUBST(USE_IEC_60559)
188 ])