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