xref: /openbsd/gnu/usr.bin/perl/hints/os390.sh (revision 5dea098c)
1# hints/os390.sh <-- keep the # character here
2#
3# OS/390 hints by David J. Fiander <davidf@mks.com>
4#
5# OS/390 OpenEdition Release 3 Mon Sep 22 1997 thanks to:
6#
7#     John Goodyear <johngood@us.ibm.com>
8#     John Pfuntner <pfuntner@vnet.ibm.com>
9#     Len Johnson <lenjay@ibm.net>
10#     Bud Huff  <BAHUFF@us.oracle.com>
11#     Peter Prymmer <pvhp@forte.com>
12#     Andy Dougherty  <doughera@lafayette.edu>
13#     Tim Bunce  <Tim.Bunce@ig.co.uk>
14#
15#  as well as the authors of the aix.sh file
16#
17# z/OS 2.4 Support added thanks to:
18#     Mike Fulton
19#     Karl Williamson
20#
21# The z/OS 'cc' and 'ld' are insufficient for our needs, so we use c99 instead
22# c99 has compiler options specified via standard Unix-style options, but some
23# options need to be specified using -Wc,<compiler-option> or -Wl,<link-option>
24me=$0
25case "$cc" in
26'') cc='c99' ;;
27esac
28case "$ld" in
29'') ld='c99' ;;
30esac
31
32# Prepend your favorites with Configure -Dccflags=your_favorites
33
34# This overrides the name the compiler was called with.  'ext' is required for
35# "unicode literals" to be enabled
36def_os390_cflags='-qlanglvl=extc1x';
37
38# For #ifdefs in code
39def_os390_defs="-DOS390 -DZOS";
40
41# Turn on POSIX compatibility modes
42#  https://www.ibm.com/support/knowledgecenter/SSLTBW_2.4.0/com.ibm.zos.v2r4.bpxbd00/ftms.htm
43def_os390_defs="$def_os390_defs -D_ALL_SOURCE";
44
45# For 31-bit addressing mode, we should use xplink (eXtended Performance linking)
46# For 64-bit addressing mode, the standard linkage works well
47
48case "$use64bitall" in
49'')
50  def_os390_cflags="$def_os390_cflags -qxplink"
51  def_os390_cccdlflags="-qxplink"
52  def_os390_ldflags="-qxplink"
53# defines a BSD-like socket interface for the function prototypes and structures involved (not required with 64-bit)
54  def_os390_defs="$def_os390_defs -D_OE_SOCKETS";
55  ;;
56*)
57  def_os390_cflags="$def_os390_cflags -Wc,lp64"
58  def_os390_cccdlflags="$def_os390_cflags -Wl,lp64"
59  def_os390_ldflags="-Wl,lp64"
60esac
61
62myfirstchar=$(od -A n -N 1 -t x $me | xargs | tr [:lower:] [:upper:] | tr -d 0)
63if [ "${myfirstchar}" = "23" ]; then # 23 is '#' in ASCII
64  unset ebcdic
65  def_os390_cflags="$def_os390_cflags -qascii"
66  # ensure that 'safe' putenv is used and avoid direct environ manipulation
67  def_os390_defs="$def_os390_defs -DPERL_USE_SAFE_PUTENV";
68else
69  ebcdic=true
70fi
71
72# Export all externally defined functions and variables in the compilation
73# unit so that a DLL application can use them.
74def_os390_cflags="$def_os390_cflags -qexportall";
75def_os390_cccdlflags="$def_os390_cccdlflags -qexportall"
76
77# 3296= #include file not found;
78# 4108= The use of keyword &1 is non-portable
79#       We care about this because it
80#       actually means it didn't do what we expected. e.g.,
81#          INFORMATIONAL CCN4108 ./proto.h:4534 The use of keyword '__attribute__' is non-portable.
82# 3159= Bit field type specified for &1 is not valid. Type &2 assumed.
83#       We do not care about this warning - the bit field is 1 bit and is being specified on something smaller than an int
84def_os390_cflags="$def_os390_cflags -qhaltonmsg=3296:4108 -qsuppress=CCN3159 -qfloat=ieee"
85
86def_os390_defs="$def_os390_defs -DMAXSIG=39 -DNSIG=39";     # maximum signal number; not furnished by IBM
87def_os390_defs="$def_os390_defs -DOEMVS";   # is used in place of #ifdef __MVS__
88
89# ensure that the OS/390 yacc generated parser is reentrant.
90def_os390_defs="$def_os390_defs -DYYDYNAMIC";
91
92# LC_MESSAGES only affects the yes/no strings in langinfo; not the things we
93# expect it to
94def_os390_defs="$def_os390_defs -DNO_LOCALE_MESSAGES"
95
96# Set up feature test macros required for features available on supported z/OS systems
97def_os390_defs="$def_os390_defs -D_OPEN_THREADS=3 -D_UNIX03_SOURCE=1 -D_AE_BIMODAL=1 -D_XOPEN_SOURCE_EXTENDED -D_ALL_SOURCE -D_ENHANCED_ASCII_EXT=0xFFFFFFFF -D_OPEN_SYS_FILE_EXT=1 -D_OPEN_SYS_SOCK_IPV6 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED"
98
99# Combine -D with cflags
100case "$ccflags" in
101'') ccflags="$def_os390_cflags $def_os390_defs"  ;;
102*)  ccflags="$ccflags $def_os390_cflags $def_os390_defs" ;;
103esac
104
105# Turning on optimization causes perl to not even compile from miniperl.  You
106# can override this with Configure -Doptimize='-O2' or somesuch.
107case "$optimize" in
108'') optimize=' ' ;;
109esac
110
111# To link via definition side decks we need the dll option
112# You can override this with Configure -Ucccdlflags or somesuch.
113case "$cccdlflags" in
114'') cccdlflags="$def_os390_cccdlflags -Wl,dll";;
115esac
116
117case "$so" in
118'') so='a' ;;
119esac
120
121case "$alignbytes" in
122'') alignbytes=8 ;;
123esac
124
125case "$usemymalloc" in
126'') usemymalloc='n' ;;
127esac
128
129# On OS/390, libc.a doesn't really hold anything at all,
130# so running nm on it is pretty useless.
131# You can override this with Configure -Dusenm.
132case "$usenm" in
133'') usenm='false' ;;
134esac
135
136case "$ldflags" in
137'') ldflags="$def_os390_ldflags";;
138esac
139
140# msf symbol information is now in NOLOAD section and so, while on disk,
141# does not require time to load but is useful in problem determination if required,
142# so it is no longer necessary to link with -Wl,EDIT=NO
143
144# In order to build with dynamic be sure to specify:
145#   Configure -Dusedl
146# Do not forget to add $archlibexp/CORE to your LIBPATH, e.g. blead/perl5
147# You might want to override some of this with things like:
148#  Configure -Dusedl -Ddlext=so -Ddlsrc=dl_dllload.xs.
149case "$usedl" in
150'')
151   usedl='n'
152   case "$dlext" in
153   '') dlext='none' ;;
154   esac
155   ;;
156define)
157   case "$useshrplib" in
158   '') useshrplib='true' ;;
159   esac
160   case "$dlsrc" in
161   '') dlsrc='dl_dllload.xs' ;;
162   esac
163   so='so'
164   case "$dlext" in
165     '') dlext='so' ;;
166   esac
167   libperl="libperl.$so"
168
169   # Allows char **environ to be accessed from a dynamically loaded
170   # module such as a DLL
171   ccflags="$ccflags -D_SHR_ENVIRON"
172
173   cccdlflags="-c $def_os390_cccdlflags"
174   lddlflags="$def_os390_cccdlflags"
175
176   # The following will need to be modified for the installed libperl.x.
177   # The modification to Config.pm is done by the installperl script after the
178   # build and test.  These are written to a CBU so that the libperl.x file
179   # comes after all the dash-options in the flags.  Configure takes the
180   # lddlflags we give it and looks for paths to libraries to append -L options
181   # to lddlflags.  But this causes the file libperl.x to appear in the final
182   # command line after the -L options.  And z/OS doesn't like filenames after
183   # options.  This CBU defers the adding of libperl.x until after any munging
184   # that Configure does.
185   cat >config.arch <<'	EOCBU'
186	case "ccdlflags" in
187	'') ccdlflags="`pwd`/libperl.x" ;;
188	 *) ccdlflags="$ccdlflags `pwd`/libperl.x" ;;
189	esac
190	lddlflags="$lddlflags `pwd`/libperl.x"
191	EOCBU
192   ;;
193esac
194
195# even on static builds using LIBPATH should be OK.
196case "$ldlibpthname" in
197'') ldlibpthname=LIBPATH ;;
198esac
199
200# The following should always be used.  Perhaps newer threads will work, but
201# when khw tried, other things would have had to be changed to get it to work,
202# so left as-is.
203d_oldpthreads='define'
204
205# Header files to include.
206# You can override these with Configure -Ui_time -Ui_systime -Dd_pthread_atfork.
207case "$i_time" in
208'') i_time='define' ;;
209esac
210case "$i_systime" in
211'') i_systime='define' ;;
212esac
213case "$d_pthread_atfork" in
214'') d_pthread_atfork='undef' ;;
215esac
216
217# (from aix.sh)
218# uname -m output is too specific and not appropriate here
219# osname should come from Configure
220# You can override this with Configure -Darchname='s390' but please don't.
221case "$archname" in
222'') archname="$osname" ;;
223esac
224
225# We have our own cppstdin script.  This is not a variable since
226# Configure sees the presence of the script file.
227# We put system header -D definitions in so that Configure
228# can find the shmat() prototype in <sys/shm.h> and various
229# other things.  Unfortunately, cppflags occurs too late to be of
230# value external to the script.  This may need to be revisited
231#
232# khw believes some of this is obsolete.  DOLLARINNAMES allows '$' in variable
233# names, for whatever reason
234# NOLOC says to use the 1047 code page, and no locale
235case "$usedl" in
236define)
237echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_ALL_SOURCE -D_SHR_ENVIRON -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin
238   ;;
239*)
240echo 'cat >.$$.c; '"$cc"' -D_OE_SOCKETS -D_ALL_SOURCE -E -Wc,"LANGLVL(DOLLARINNAMES)",NOLOC ${1+"$@"} .$$.c | fgrep -v "??="; rm .$$.c' > cppstdin
241   ;;
242esac
243
244#
245# Note that Makefile.SH employs a bare yacc command to generate
246# perly.[hc], hence you may wish to:
247#
248#    alias yacc='myyacc'
249#
250# Then if you would like to use myyacc and skip past the
251# following warnings try invoking Configure like so:
252#
253#    sh Configure -Dbyacc=yacc
254#
255# This trick ought to work even if your yacc is byacc.
256#
257# msf - need to check but I think /etc/yyparse.c is always around now
258if test "X$byacc" = "Xbyacc" ; then
259   if test -e /etc/yyparse.c ; then
260       : we should be OK - perhaps do a test -r?
261   else
262       cat <<EOWARN >&4
263
264Warning.  You do not have a copy of yyparse.c, the default
265yacc parser template file, in place in /etc.
266EOWARN
267       if test -e /samples/yyparse.c ; then
268           cat <<EOWARN >&4
269
270There does appear to be a template file in /samples though.
271Please run:
272
273     cp /samples/yyparse.c /etc
274
275before attempting to Configure the build of $package.
276
277EOWARN
278       else
279           cat <<EOWARN >&4
280
281There does not appear to be one in /samples either.
282If you feel you can make use of an alternate yacc-like
283parser generator then please read the comments in the
284hints/os390.sh file carefully.
285
286EOWARN
287       fi
288       exit 1
289   fi
290fi
291
292# These exist, but there is something wrong with either them, or our reentr.[ch],
293# and no one has felt it important enough to investigate/fix.  The
294# non-reentrant versions seem to work, but will have races in threads.
295d_gethostbyaddr_r='undef'
296d_gethostbyname_r='undef'
297d_gethostent_r='undef'
298
299# nan() used to not work as expected: nan("") or nan("0") returned zero, not a
300# nan.  This may have been a C89 issue.
301# http://www-01.ibm.com/support/knowledgecenter/SSLTBW_1.12.0/com.ibm.zos.r12.bpxbd00/nan.htm%23nan?lang=en
302#d_nan='undef'
303
304# Configure says this exists, but it doesn't work properly.  See
305# <54DCE073.4010100@khwilliamson.com>
306d_dir_dd_fd='undef'
307
308############################################################################
309# Thread support
310# use Configure -Dusethreads to enable
311# This script UU/usethreads.cbu will get 'called-back' by Configure
312# after it has prompted the user for whether to use threads.
313# setlocale() returns NULL if a thread has been created, so we can't use it
314# generally.  (It would be possible to have it work for initialization, so that
315# the user could specify a locale for the whole program; but deferring doing
316# that work until someone wants it)  Maybe IBM will support POSIX 2008 at some
317# point.  There are hooks that make it look like they were working on it.
318cat > UU/usethreads.cbu <<'EOCBU'
319case "$usethreads" in
320$define|true|[yY]*)
321   echo "Your system's setlocale() is broken under threads; marking it as unavailable" >&4
322   d_setlocale="undef"
323   d_setlocale_accepts_any_locale_name="undef"
324   d_has_C_UTF8="false"
325esac
326EOCBU
327