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