FreeBSD: if someone *really* wants to use the system malloc.
[p5sagit/p5-mst-13.2.git] / hints / freebsd.sh
1 # Original based on info from
2 # Carl M. Fongheiser <cmf@ins.infonet.net>
3 # Date: Thu, 28 Jul 1994 19:17:05 -0500 (CDT)
4 #
5 # Additional 1.1.5 defines from 
6 # Ollivier Robert <Ollivier.Robert@keltia.frmug.fr.net>
7 # Date: Wed, 28 Sep 1994 00:37:46 +0100 (MET)
8 #
9 # Additional 2.* defines from
10 # Ollivier Robert <Ollivier.Robert@keltia.frmug.fr.net>
11 # Date: Sat, 8 Apr 1995 20:53:41 +0200 (MET DST)
12 #
13 # Additional 2.0.5 and 2.1 defined from
14 # Ollivier Robert <Ollivier.Robert@keltia.frmug.fr.net>
15 # Date: Fri, 12 May 1995 14:30:38 +0200 (MET DST)
16 #
17 # Additional 2.2 defines from
18 # Mark Murray <mark@grondar.za>
19 # Date: Wed, 6 Nov 1996 09:44:58 +0200 (MET)
20 #
21 # Modified to ensure we replace -lc with -lc_r, and
22 # to put in place-holders for various specific hints.
23 # Andy Dougherty <doughera@lafayette.edu>
24 # Date: Tue Mar 10 16:07:00 EST 1998
25 #
26 # Support for FreeBSD/ELF
27 # Ollivier Robert <roberto@keltia.freenix.fr>
28 # Date: Wed Sep  2 16:22:12 CEST 1998
29 #
30 # The two flags "-fpic -DPIC" are used to indicate a
31 # will-be-shared object.  Configure will guess the -fpic, (and the
32 # -DPIC is not used by perl proper) but the full define is included to 
33 # be consistent with the FreeBSD general shared libs building process.
34 #
35 # setreuid and friends are inherently broken in all versions of FreeBSD
36 # before 2.1-current (before approx date 4/15/95). It is fixed in 2.0.5
37 # and what-will-be-2.1
38 #
39
40 case "$osvers" in
41 0.*|1.0*)
42         usedl="$undef"
43         ;;
44 1.1*)
45         malloctype='void *'
46         groupstype='int'
47         d_setregid='undef'
48         d_setreuid='undef'
49         d_setrgid='undef'
50         d_setruid='undef'
51         ;;
52 2.0-release*)
53         d_setregid='undef'
54         d_setreuid='undef'
55         d_setrgid='undef'
56         d_setruid='undef'
57         ;;
58 #
59 # Trying to cover 2.0.5, 2.1-current and future 2.1/2.2
60 # It does not covert all 2.1-current versions as the output of uname
61 # changed a few times.
62 #
63 # Even though seteuid/setegid are available, they've been turned off
64 # because perl isn't coded with saved set[ug]id variables in mind.
65 # In addition, a small patch is requried to suidperl to avoid a security
66 # problem with FreeBSD.
67 #
68 2.0.5*|2.0-built*|2.1*)
69         usevfork='true'
70         case "$usemymalloc" in
71             "") usemymalloc='n'
72                 ;;
73         esac
74         d_setregid='define'
75         d_setreuid='define'
76         d_setegid='undef'
77         d_seteuid='undef'
78         test -r ./broken-db.msg && . ./broken-db.msg
79         ;;
80 #
81 # 2.2 and above have phkmalloc(3).
82 # don't use -lmalloc (maybe there's an old one from 1.1.5.1 floating around)
83 2.2*)
84         usevfork='true'
85         case "$usemymalloc" in
86             "") usemymalloc='n'
87                 ;;
88         esac
89         libswanted=`echo $libswanted | sed 's/ malloc / /'`
90         d_setregid='define'
91         d_setreuid='define'
92         d_setegid='undef'
93         d_seteuid='undef'
94         ;;
95 4.*)    # In FreeBSD 4 and 5 the system malloc is performance-wise
96         # VERY bad for Perl-- we are talking of differences of not
97         # one, but TWO magnitudes.
98         case "$usemymalloc" in
99         "") usemymalloc='y'
100             ;;
101         esac
102         ;;
103 5.*)    case "$usemymalloc" in
104         "") usemymalloc='y'
105             ;;
106         esac
107         ;;
108 *)      usevfork='true'
109         case "$usemymalloc" in
110         "") usemymalloc='y'
111             ;;
112         esac
113         libswanted=`echo $libswanted | sed 's/ malloc / /'`
114         ;;
115 esac
116
117 # Dynamic Loading flags have not changed much, so they are separated
118 # out here to avoid duplicating them everywhere.
119 case "$osvers" in
120 0.*|1.0*) ;;
121
122 1*|2*)  cccdlflags='-DPIC -fpic'
123         lddlflags="-Bshareable $lddlflags"
124         ;;
125
126 *)
127         objformat=`/usr/bin/objformat`
128         if [ x$objformat = xelf ]; then
129             libpth="/usr/lib /usr/local/lib"
130             glibpth="/usr/lib /usr/local/lib"
131             ldflags="-Wl,-E "
132             lddlflags="-shared "
133         else
134             if [ -e /usr/lib/aout ]; then
135                 libpth="/usr/lib/aout /usr/local/lib /usr/lib"
136                 glibpth="/usr/lib/aout /usr/local/lib /usr/lib"
137             fi
138             lddlflags='-Bshareable'
139         fi
140         cccdlflags='-DPIC -fpic'
141         ;;
142 esac
143
144 case "$osvers" in
145 0*|1*|2*|3*) ;;
146
147 *)
148         ccflags="${ccflags} -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H"
149         if /usr/bin/file -L /usr/lib/libc.so | /usr/bin/grep -vq "not stripped" ; then
150             usenm=false
151         fi
152         ;;
153 esac
154
155 cat <<'EOM' >&4
156
157 Some users have reported that Configure halts when testing for
158 the O_NONBLOCK symbol with a syntax error.  This is apparently a
159 sh error.  Rerunning Configure with ksh apparently fixes the
160 problem.  Try
161         ksh Configure [your options]
162
163 EOM
164
165 # From: Anton Berezin <tobez@plab.ku.dk>
166 # To: perl5-porters@perl.org
167 # Subject: [PATCH 5.005_54] Configure - hints/freebsd.sh signal handler type
168 # Date: 30 Nov 1998 19:46:24 +0100
169 # Message-ID: <864srhhvcv.fsf@lion.plab.ku.dk>
170
171 signal_t='void'
172 d_voidsig='define'
173
174 # set libperl.so.X.X for 2.2.X
175 case "$osvers" in
176 2.2*)
177     # unfortunately this code gets executed before
178     # the equivalent in the main Configure so we copy a little
179     # from Configure XXX Configure should be fixed.
180     if $test -r $src/patchlevel.h;then
181        patchlevel=`awk '/define[        ]+PERL_VERSION/ {print $3}' $src/patchlevel.h`
182        subversion=`awk '/define[        ]+PERL_SUBVERSION/ {print $3}' $src/patchlevel.h`
183     else
184        patchlevel=0
185        subversion=0
186     fi
187     libperl="libperl.so.$patchlevel.$subversion"
188     unset patchlevel
189     unset subversion
190     ;;
191 esac
192
193 # This script UU/usethreads.cbu will get 'called-back' by Configure 
194 # after it has prompted the user for whether to use threads.
195 cat > UU/usethreads.cbu <<'EOCBU'
196 case "$usethreads" in
197 $define|true|[yY]*)
198         lc_r=`/sbin/ldconfig -r|grep ':-lc_r'|awk '{print $NF}'|sed -n '$p'`
199         case "$osvers" in  
200         0*|1*|2.0*|2.1*)   cat <<EOM >&4
201 I did not know that FreeBSD $osvers supports POSIX threads.
202
203 Feel free to tell perlbug@perl.org otherwise.
204 EOM
205               exit 1
206               ;;
207
208         2.2.[0-7]*)
209               cat <<EOM >&4
210 POSIX threads are not supported well by FreeBSD $osvers.
211
212 Please consider upgrading to at least FreeBSD 2.2.8,
213 or preferably to the most recent -RELEASE or -STABLE
214 version (see http://www.freebsd.org/releases/).
215
216 (While 2.2.7 does have pthreads, it has some problems
217  with the combination of threads and pipes and therefore
218  many Perl tests will either hang or fail.)
219 EOM
220               exit 1
221               ;;
222
223         *)
224               if [ ! -r "$lc_r" ]; then
225               cat <<EOM >&4
226 POSIX threads should be supported by FreeBSD $osvers --
227 but your system is missing the shared libc_r.
228 (/sbin/ldconfig -r doesn't find any).
229
230 Consider using the latest STABLE release.
231 EOM
232                  exit 1
233               fi
234               ldflags="-pthread $ldflags"
235               case "$osvers" in
236               4.*|5.0-release*) 
237                         # 4.x and 5.0-release have gethostbyaddr_r but it is
238                         # "Temporary function, not threadsafe"...
239                         d_gethostbyaddr_r="undef"
240                         d_gethostbyaddr_r_proto="0"
241                         ;;
242               esac
243               ;;
244
245         esac
246
247         set `echo X "$libswanted "| sed -e 's/ c / c_r /'`
248         shift
249         libswanted="$*"
250         # Configure will probably pick the wrong libc to use for nm scan.
251         # The safest quick-fix is just to not use nm at all...
252         usenm=false
253
254         case "$osvers" in
255         2.2.8*)
256             # ... but this does not apply for 2.2.8 - we know it's safe
257             libc="$lc_r"
258             usenm=true
259            ;;
260         esac
261
262         unset lc_r
263
264         # Even with the malloc mutexes the Perl malloc does not
265         # seem to be threadsafe in FreeBSD?
266         usemymalloc=y
267
268 esac
269 EOCBU
270