summaryrefslogtreecommitdiff
path: root/m4/arch.m4
blob: 441602cdb777225b269be11e95d8e2da0aa33912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
dnl
dnl arch.m4 --- autoconf input file for gawk
dnl
dnl Copyright (C) 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2015
dnl the Free Software Foundation, Inc.
dnl
dnl This file is part of GAWK, the GNU implementation of the
dnl AWK Progamming Language.
dnl
dnl GAWK is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl GAWK is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
dnl

dnl Check for AIX and add _XOPEN_SOURCE_EXTENDED
AC_DEFUN([GAWK_AC_AIX_TWEAK], [
AC_MSG_CHECKING([for AIX compilation hacks])
AC_CACHE_VAL(gawk_cv_aix_hack, [
if test -d /lpp
then
	CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED=1 -DGAWK_AIX=1"
	gawk_cv_aix_hack=yes
else
	gawk_cv_aix_hack=no
fi
])dnl
AC_MSG_RESULT([${gawk_cv_aix_hack}])
])dnl

dnl Check for Alpha Linux systems
AC_DEFUN([GAWK_AC_LINUX_ALPHA], [
AC_MSG_CHECKING([for Linux/Alpha compilation hacks])
AC_CACHE_VAL(gawk_cv_linux_alpha_hack, [
if test "Linux" = "`uname`" && test "alpha" = "`uname -m`"
then
	# this isn't necessarily always true,
	# the vendor's compiler is also often found
	if test "$GCC" = yes
	then
		CFLAGS="$CFLAGS -mieee"
		gawk_cv_linux_alpha_hack=yes
	else
		gawk_cv_linux_alpha_hack=no
	fi
else
	gawk_cv_linux_alpha_hack=no
fi
])dnl
AC_MSG_RESULT([${gawk_cv_linux_alpha_hack}])
])dnl

dnl Check for z/OS Unix Systems Services
AC_DEFUN([AC_ZOS_USS], [
AC_MSG_CHECKING([for z/OS USS compilation])
AC_CACHE_VAL(ac_cv_zos_uss, [
if test "OS/390" = "`uname`"
then
  ac_cv_zos_uss=yes
else
  ac_cv_zos_uss=no
fi
])dnl
AC_MSG_RESULT([${ac_cv_zos_uss}])
if test "x$ac_cv_zos_uss" = "xyes"
then
  dnl Identify the compiler.
  ac_zos_uss_cc_id=unknown
  echo " $CC " | $EGREP ' (/bin/)?c89[ |_]' >/dev/null && ac_zos_uss_cc_id=c89
  echo " $CC " | $EGREP ' (/bin/)?c99[ |_]' >/dev/null && ac_zos_uss_cc_id=xlc
  echo " $CC " | $EGREP ' (/bin/)?cc[ |_]'  >/dev/null && ac_zos_uss_cc_id=cc
  echo " $CC " | $EGREP ' (/bin/)?xlc[ |_]' >/dev/null && ac_zos_uss_cc_id=xlc
  echo " $CC " | $EGREP ' (/bin/)?xlC[ |_]' >/dev/null && ac_zos_uss_cc_id=xlc++
  echo " $CC " | $EGREP ' (/bin/)?xlc\+\+[ |_]' >/dev/null && ac_zos_uss_cc_id=xlc++
  test "x$GCC" = "xyes" && ac_zos_uss_cc_id=gcc
  dnl These feature test macros are needed on z/OS.
  CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
  test "$ac_zos_uss_cc_id" != xlc++ && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600"
  case "$ac_zos_uss_cc_id" in
  c89)
    dnl If the user has set CC=c89 and _C89_OPTIONS, then don't get in
    dnl their way.  c89 (as well as cc) pre-dates xlc, and accepts an
    dnl option syntax that involves parentheses and cannot be handled
    dnl in the usual way in C(PP)FLAGS.  However, c89 will also accept
    dnl options via the aforementioned environment variable, which
    dnl gives the user one way around the problem.  (If you're
    dnl wondering about cc, it is meant for programs written in
    dnl "Common Usage C" [a.k.a. K&R C] as opposed to "Standard C"
    dnl [a.k.a. ANSI], and does not build gawk correctly.)
    if test -n "$_C89_OPTIONS"
    then
      AC_MSG_NOTICE([CC = $CC])
      AC_MSG_NOTICE([_C89_OPTIONS = $_C89_OPTIONS])
    else
      AC_MSG_ERROR([c89-setup-required
To build GNU Awk using "c89", please set

    _C89_OPTIONS="-W c,langlvl(stdc99,libext),haltonmsg(CCN3296)"

in your environment, and reconfigure. (The above flags cannot be specified
in CFLAGS/CPPFLAGS, due to the parentheses.)])
    fi
    ;;
  gcc)
    dnl GCC has not yet been ported to z/OS as of this writing
    ;;
  cc)
    AC_MSG_ERROR([cc-invalid
The z/OS "cc" compiler does not build GNU Awk correctly.

If the "xlc" or "c89" compiler is available, please set CC accordingly
and reconfigure. ("xlc" is the recommended compiler on z/OS.)])
    ;;
  xlc*)
    dnl This enables C99, and on z/OS 1.11, the setenv() prototype.
    CFLAGS="$CFLAGS -qlanglvl=stdc99:libext"
    dnl Use a compiler wrapper script to address some annoyances.
    cat >zos-cc <<EOF
#!/bin/sh
#
# This wrapper script addresses two annoying peculiarities of the IBM
# xlc/c99 compiler on z/OS:
#
# 1. Missing header files are considered warnings by default rather
#    than fatal errors;
#
# 2. Include directories specified with -I are searched _after_ the
#    system include directories (for #include<> directives) rather
#    than before.
#
# This script allows the code and the build system to assume standard
# compiler behavior.
#

PS4='zos-cc: '
REAL_CC="$CC"

set -x
\$REAL_CC -qhaltonmsg=CCN3296 -qnosearch "\$[]@" -qsearch=/usr/include
EOF
    chmod +x zos-cc
    AC_MSG_NOTICE([wrapping $CC with zos-cc to obtain standard behavior])
    CC="`pwd`/zos-cc"
    ;;
  *)
    AC_MSG_WARN([unrecognized compiler environment])
    ;;
  esac
fi # ac_cv_zos_uss = yes
])dnl