This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[patch] -Wall
[perl5.git] / hints / machten.sh
CommitLineData
0f297bd8 1#! /bin/bash
fec02dd3 2# machten.sh
0f297bd8
GS
3# This is for MachTen 4.1.4. It might work on other versions and variants
4# too. If it doesn't, tell me, and I'll try to fix it -- domo@computer.org
db90f03e 5#
a55e790a
DD
6# Users of earlier MachTen versions might need a fixed tr from ftp.tenon.com.
7# This should be described in the MachTen release notes.
db90f03e 8#
9# MachTen 2.x has its own hint file.
10#
0f297bd8 11# The original version of this file was put together by Andy Dougherty
db90f03e 12# <doughera@lafcol.lafayette.edu> based on comments from lots of
13# folks, especially
14# Mark Pease <peasem@primenet.com>
15# Martijn Koster <m.koster@webcrawler.com>
16# Richard Yeh <rcyeh@cco.caltech.edu>
baf67fda 17#
2f4b4800
DD
18# Deny system's false claims to support mmap() and munmap(); note
19# also that Sys V IPC (re)disabled by jhi due to continuing inadequacy
20# -- Dominic Dunlop <domo@computer.org> 001111
0f297bd8
GS
21# Remove dynamic loading libraries from search; enable SysV IPC with
22# MachTen 4.1.4 and above; define SYSTEM_ALIGN_BYTES for old MT versions
23# -- Dominic Dunlop <domo@computer.org> 000224
7ecd88f1
DD
24# Disable shadow password file access: MT 4.1.1 has necessary library
25# functions, but not header file (or documentation)
26# -- Dominic Dunlop <domo@computer.org> 990804
e060872b
DD
27# For now, explicitly disable dynamic loading -- MT 4.1.1 has it,
28# but these hints do not yet support it.
29# Define NOTEDEF_MACHTEN to undo gratuitous Tenon hack to signal.h.
30# -- Dominic Dunlop <domo@computer.org> 9800802
911efb05
DD
31# Completely disable SysV IPC pending more complete support from Tenon
32# -- Dominic Dunlop <domo@computer.org> 980712
38ac2dc8
DD
33# Use vfork and perl's malloc by default
34# -- Dominic Dunlop <domo@computer.org> 980630
83e898de
DD
35# Raise perl's stack size again; cut down reg_infty; document
36# -- Dominic Dunlop <domo@computer.org> 980619
2ff233fa 37# Use of semctl() can crash system: disable -- Dominic Dunlop 980506
da9788ee
DD
38# Raise stack size further; slight tweaks to accomodate MT 4.1
39# -- Dominic Dunlop <domo@computer.org> 980211
a55e790a 40# Raise perl's stack size -- Dominic Dunlop <domo@tcp.ip.lu> 970922
44a8e56a 41# Reinstate sigsetjmp iff version is 4.0.3 or greater; use nm
42# (assumes Configure change); prune libswanted -- Dominic Dunlop 970113
43# Warn about test failure due to old Berkeley db -- Dominic Dunlop 970105
55497cff 44# Do not use perl's malloc; SysV IPC OK -- Neil Cutcliffe, Tenon 961030
45# File::Find's use of link count disabled by Dominic Dunlop 960528
46# Perl's use of sigsetjmp etc. disabled by Dominic Dunlop 960521
db90f03e 47#
fec02dd3
AD
48# Comments, questions, and improvements welcome!
49#
7ecd88f1
DD
50# MachTen 4.1.1's support for shadow password file access is incomplete:
51# disable its use completely.
7ecd88f1 52d_getspnam=${d_getspnam:-undef}
7ecd88f1 53
e060872b 54# MachTen 4.1.1 does support dynamic loading, but perl doesn't
db90f03e 55# know how to use it yet.
e060872b
DD
56usedl=${usedl:-undef}
57
58# MachTen 4.1.1 may have an unhelpful hack in /usr/include/signal.h.
59# Undo it if so.
60if grep NOTDEF_MACHTEN /usr/include/signal.h > /dev/null
61then
62 ccflags="$ccflags -DNOTDEF_MACHTEN"
63fi
55497cff 64
65# Power MachTen is a real memory system and its standard malloc
66# has been optimized for this. Using this malloc instead of Perl's
38ac2dc8
DD
67# malloc may result in significant memory savings. In particular,
68# unlike most UNIX memory allocation subsystems, MachTen's free()
69# really does return unneeded process data memory to the system.
70# However, MachTen's malloc() is woefully slow -- maybe 100 times
71# slower than perl's own, so perl's own is usually the better
72# choice. In order to use perl's malloc(), the sbrk() system call
73# must be simulated using MachTen's malloc(). See malloc.c for
74# precise details of how this is achieved. Recent improvements
75# to perl's malloc() currently crash MachTen, and so are disabled
76# by -DPLAIN_MALLOC and -DNO_FANCY_MALLOC.
77usemymalloc=${usemymalloc:-y}
78
0f297bd8
GS
79# Older versions of MachTen malloc() data on a two-byte boundary, which
80# works, but slows down operations on long, float and double data.
81# Perl's malloc() can compensate if SYSTEM_ALLOC_ALIGNMENT is suitably
82# defined.
83if expr "$osvers" \< "4.1" >/dev/null
84then
85system_alloc_alignment=" -DSYSTEM_ALLOC_ALIGNMENT=2"
86fi
38ac2dc8 87# Do not wrap the following long line
0f297bd8 88malloc_cflags='ccflags="$ccflags -DPLAIN_MALLOC -DNO_FANCY_MALLOC -DUSE_PERL_SBRK$system_alloc_alignment"'
38ac2dc8 89
38ac2dc8
DD
90# When MachTen does a fork(), it immediately copies the whole of
91# the parent process' data space for the child. This can be
92# expensive. Using vfork() where appropriate avoids this cost.
93d_vfork=${d_vfork:-define}
94
95# Specify a high level of optimization (-O3 wouldn't do much more)
96optimize=${optimize:--O2 -fomit-frame-pointer}
c07a80fd 97
44a8e56a 98# Make symbol table listings les voluminous
99nmopts=-gp
c07a80fd 100
83e898de
DD
101# Set reg_infty -- the maximum allowable number of repeats in regular
102# expressions such as /a{1,$max_repeats}/, and the maximum number of
103# times /a*/ will match. Setting this too high without having a stack
104# large enough to accommodate deep recursion in the regular expression
105# engine allows perl to crash your Mac due to stack overrun if it
106# encounters a pathological regular expression. The default is a
107# compromise between capability and required stack size (see below).
108# You may override the default value from the Configure command-line
109# like this:
110#
111# Configure -Dreg_infty=16368 ...
112
113reg_infty=${reg_infty:-2047}
114
115# If you want to have many perl processes active simultaneously --
116# processing CGI forms -- for example, you should opt for a small stack.
117# For safety, you should set reg_infty no larger than the corresponding
118# value given in this table:
119#
120# Stack size reg_infty value supported
121# ---------- -------------------------
122# 128k 2**8-1 (256)
123# 256k 2**9-1 (511)
124# 512k 2**10-1 (1023)
125# 1M 2**11-1 (2047)
126# ...
127# 16M 2**15-1 (32767) (perl's default value)
128
129# This script selects a safe stack size based on the value of reg_infty
130# specified above. However, you may choose to take a risk and set
131# stack size lower: pathological regular expressions are rare in real-world
132# programs. But be aware that, if perl does encounter one, it WILL
133# crash your system. Do not set stack size lower than 96k unless
134# you want perl's installation tests ( make test ) to crash your system.
135#
136# You may override the default value from the Configure command-line
137# by specifying the required size in kilobytes like this:
138#
139# Configure -Dstack_size=96
140
141if [ "X$stack_size" = 'X' ]
142then
143 stack_size=128
144 X=`expr $reg_infty / 256`
145
146 while [ $X -gt 0 ]
147 do
148 X=`expr $X / 2`
149 stack_size=`expr $stack_size \* 2`
150 done
38ac2dc8 151 X=`expr $stack_size \* 1024`
83e898de
DD
152fi
153
83e898de
DD
154ldflags="$ldflags -Xlstack=$X"
155ccflags="$ccflags -DREG_INFTY=$reg_infty"
a55e790a 156
55497cff 157# Install in /usr/local by default
158prefix='/usr/local'
159
db90f03e 160# At least on PowerMac, doubles must be aligned on 8 byte boundaries.
161# I don't know if this is true for all MachTen systems, or how to
162# determine this automatically.
163alignbytes=8
baf67fda 164
44a8e56a 165# 4.0.2 and earlier had a problem with perl's use of sigsetjmp and
baf67fda 166# friends. Use setjmp and friends instead.
44a8e56a 167expr "$osvers" \< "4.0.3" > /dev/null && d_sigsetjmp='undef'
168
0f297bd8 169# System V IPC before MachTen 4.1.4 is incomplete (missing msg function
911efb05 170# prototypes, no ftok()), buggy (semctl(.., .., IPC_STATUS, ..) hangs
0f297bd8
GS
171# system), and undocumented. Claim it's not there at all before 4.1.4.
172if expr "$osvers" \< "4.1.4" >/dev/null
173then
911efb05
DD
174d_msg=${d_msg:-undef}
175d_sem=${d_sem:-undef}
176d_shm=${d_shm:-undef}
0f297bd8 177fi
2ff233fa 178
c6c38f61
GS
179
180# As of MachTen 4.1.4 the msg* and shm* are in libc but unimplemented
181# (an attempt to use them causes a runtime error)
182# XXX Configure probe for really functional msg*() is needed XXX
183# XXX Configure probe for really functional shm*() is needed XXX
184if test "$d_msg" = ""; then
185 d_msgget=${d_msgget:-undef}
186 d_msgctl=${d_msgctl:-undef}
187 d_msgsnd=${d_msgsnd:-undef}
188 d_msgrcv=${d_msgrcv:-undef}
189 case "$d_msgget$d_msgsnd$d_msgctl$d_msgrcv" in
190 *"undef"*) d_msg="$undef" ;;
191 esac
192fi
193if test "$d_shm" = ""; then
194 d_shmat=${d_shmat:-undef}
195 d_shmdt=${d_shmdt:-undef}
196 d_shmget=${d_shmget:-undef}
197 d_shmctl=${d_shmctl:-undef}
198 case "$d_shmat$d_shmctl$d_shmdt$d_shmget" in
199 *"undef"*) d_shm="$undef" ;;
200 esac
201fi
202
2f4b4800
DD
203# MachTen has stubs for mmap and munmap(), but they just result in the
204# caller being killed on the grounds of "Bad system call"
205d_mmap=${d_mmap:-undef}
206d_munmap=${d_munmap:-undef}
207
44a8e56a 208# Get rid of some extra libs which it takes Configure a tediously
0f297bd8 209# long time never to find on MachTen, or which break perl
44a8e56a 210set `echo X "$libswanted "|sed -e 's/ net / /' -e 's/ socket / /' \
211 -e 's/ inet / /' -e 's/ nsl / /' -e 's/ nm / /' -e 's/ malloc / /' \
212 -e 's/ ld / /' -e 's/ sun / /' -e 's/ posix / /' \
0f297bd8 213 -e 's/ cposix / /' -e 's/ crypt / /' -e 's/ dl / /' -e 's/ dld / /' \
44a8e56a 214 -e 's/ ucb / /' -e 's/ bsd / /' -e 's/ BSD / /' -e 's/ PW / /'`
215shift
216libswanted="$*"
baf67fda 217
da9788ee
DD
218# While link counts on MachTen 4.1's fast file systems work correctly,
219# on Macintosh Heirarchical File Systems, (and on HFS+)
baf67fda 220# MachTen always reports ony two links to directories, even if they
221# contain subdirectories. Consequently, we use this variable to stop
222# File::Find using the link count to determine whether there are
223# subdirectories to be searched. This will generate a harmless message:
224# Hmm...You had some extra variables I don't know about...I'll try to keep 'em.
225# Propagating recommended variable dont_use_nlink
226dont_use_nlink=define
227
83e898de 228cat <<EOM >&4
baf67fda 229
2ff233fa
DD
230During Configure, you may see the message
231
232*** WHOA THERE!!! ***
911efb05 233 The recommended value for \$d_msg on this machine was "undef"!
2ff233fa
DD
234 Keep the recommended value? [y]
235
911efb05
DD
236as well as similar messages concerning \$d_sem and \$d_shm. Select the
237default answers: MachTen 4.1 appears to provide System V IPC support,
238but it is incomplete and buggy: perl should be built without it.
2f4b4800
DD
239Similar considerations apply to memory mapping of files, controlled
240by \$d_mmap and \$d_munmap.
baf67fda 241
38ac2dc8
DD
242Similarly, when you see
243
244*** WHOA THERE!!! ***
245 The recommended value for \$d_vfork on this machine was "define"!
246 Keep the recommended value? [y]
247
248select the default answer: vfork() works, and avoids expensive data
249copying.
250
d722968f
JH
251You may also see "WHOA THERE!!!" messages concerning \$d_getspnam.
252Select the default answer: MachTen's support for shadow password
253file access is incomplete, and should not be used.
7ecd88f1 254
baf67fda 255At the end of Configure, you will see a harmless message
256
257Hmm...You had some extra variables I don't know about...I'll try to keep 'em.
258 Propagating recommended variable dont_use_nlink
44a8e56a 259 Propagating recommended variable nmopts
38ac2dc8 260 Propagating recommended variable malloc_cflags...
83e898de 261 Propagating recommended variable reg_infty
0f297bd8 262 Propagating recommended variable system_alloc_alignment
44a8e56a 263Read the File::Find documentation for more information about dont_use_nlink
baf67fda 264
83e898de
DD
265Your perl will be built with a stack size of ${stack_size}k and a regular
266expression repeat count limit of $reg_infty. If you want alternative
267values, see the file hints/machten.sh for advice on how to change them.
268
2ff233fa
DD
269Tests
270 io/fs test 4 and
271 op/stat test 3
272may fail since MachTen may not return a useful nlinks field to stat
273on directories.
274
baf67fda 275EOM
2ff233fa
DD
276expr "$osvers" \< "4.1" >/dev/null && test -r ./broken-db.msg && \
277 . ./broken-db.msg
83e898de
DD
278
279unset stack_size X