diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-09-11 11:35:33 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-09-11 11:35:33 +0300 |
commit | 4e9562fd62acf478974fc7e0627381f93101083e (patch) | |
tree | 1fca56c555231f54716a8f84fac6650a0979a814 /m4/arch.m4 | |
parent | 35ba3f02a20d8592d16fb702fae3940d6e12dbfe (diff) | |
download | egawk-4e9562fd62acf478974fc7e0627381f93101083e.tar.gz egawk-4e9562fd62acf478974fc7e0627381f93101083e.tar.bz2 egawk-4e9562fd62acf478974fc7e0627381f93101083e.zip |
Further zOS updates: Wrap C compiler.
Diffstat (limited to 'm4/arch.m4')
-rw-r--r-- | m4/arch.m4 | 101 |
1 files changed, 71 insertions, 30 deletions
@@ -72,32 +72,34 @@ fi 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 -D_XOPEN_SOURCE=600" - dnl If _C89_OPTIONS is set, then assume the user is building with the c89 - dnl compiler frontend, and knows what they are doing. c89 (as well as cc) - dnl pre-dates xlc, and accepts an option syntax that involves parentheses - dnl and cannot be handled in the usual way in C(PP)FLAGS. However, c89 - dnl will also accept options via the aforementioned environment variable, - dnl which gives the user one way around the problem. (If you're wondering - dnl about cc, it is meant for programs written in "Common Usage C" - dnl [a.k.a. K&R C] as opposed to "Standard C" [a.k.a. ANSI], and does not - dnl build gawk correctly.) - if test -n "$_C89_OPTIONS" - then - AC_MSG_NOTICE([_C89_OPTIONS = $_C89_OPTIONS]) - elif test "x$GCC" != "xyes" - then - if echo " $CC " | $EGREP ' (/bin/)?cc ' >/dev/null - then - 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.)]) - fi - if echo " $CC " | $EGREP ' (/bin/)?c89 ' >/dev/null + 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 @@ -106,12 +108,51 @@ To build GNU Awk using "c89", please set 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 This is needed so that xlc considers a missing header file to be an - dnl error and not a warning. (Yes, the latter is in fact the default - dnl behavior on z/OS.) - CPPFLAGS="$CPPFLAGS -qhaltonmsg=CCN3296" - fi -fi + 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 |