This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlre: Note a bug's existence
[perl5.git] / hints / openbsd.sh
1 # hints/openbsd.sh
2 #
3 # hints file for OpenBSD; Todd Miller <millert@openbsd.org>
4 # Edited to allow Configure command-line overrides by
5 #  Andy Dougherty <doughera@lafayette.edu>
6 #
7 # To build with distribution paths, use:
8 #       ./Configure -des -Dopenbsd_distribution=defined
9 #
10
11 # In OpenBSD > 3.7, use perl's malloc [perl #75742]
12 case "$osvers" in
13 3.[89]*|[4-9]*)
14     test "$usemymalloc" || usemymalloc=y
15     ;;
16 esac
17
18 # malloc wrap works
19 case "$usemallocwrap" in
20 '') usemallocwrap='define' ;;
21 esac
22
23 # Currently, vfork(2) is not a real win over fork(2).
24 usevfork="$undef"
25
26 # In OpenBSD < 3.3, the setre?[ug]id() are emulated using the
27 # _POSIX_SAVED_IDS functionality which does not have the same
28 # semantics as 4.3BSD.  Starting with OpenBSD 3.3, the original
29 # semantics have been restored.
30 case "$osvers" in
31 [0-2].*|3.[0-2])
32         d_setregid=$undef
33         d_setreuid=$undef
34         d_setrgid=$undef
35         d_setruid=$undef
36 esac
37
38 #
39 # Not all platforms support dynamic loading...
40 # For the case of "$openbsd_distribution", the hints file
41 # needs to know whether we are using dynamic loading so that
42 # it can set the libperl name appropriately.
43 # Allow command line overrides.
44 #
45 ARCH=`arch | sed 's/^OpenBSD.//'`
46 case "${ARCH}-${osvers}" in
47 alpha-2.[0-8]|mips-2.[0-8]|powerpc-2.[0-7]|m88k-*|hppa-*|vax-*)
48         test -z "$usedl" && usedl=$undef
49         ;;
50 *)
51         test -z "$usedl" && usedl=$define
52         # We use -fPIC here because -fpic is *NOT* enough for some of the
53         # extensions like Tk on some OpenBSD platforms (ie: sparc)
54         cccdlflags="-DPIC -fPIC $cccdlflags"
55         case "$osvers" in
56         [01].*|2.[0-7]|2.[0-7].*)
57                 lddlflags="-Bshareable $lddlflags"
58                 ;;
59         2.[8-9]|3.0)
60                 ld=${cc:-cc}
61                 lddlflags="-shared -fPIC $lddlflags"
62                 ;;
63         *) # from 3.1 onwards
64                 ld=${cc:-cc}
65                 lddlflags="-shared -fPIC $lddlflags"
66                 libswanted=`echo $libswanted | sed 's/ dl / /'`
67                 ;;
68         esac
69
70         # We need to force ld to export symbols on ELF platforms.
71         # Without this, dlopen() is crippled.
72         ELF=`${cc:-cc} -dM -E - </dev/null | grep __ELF__`
73         test -n "$ELF" && ldflags="-Wl,-E $ldflags"
74         ;;
75 esac
76
77 #
78 # Tweaks for various versions of OpenBSD
79 #
80 case "$osvers" in
81 2.5)
82         # OpenBSD 2.5 has broken odbm support
83         i_dbm=$undef
84         ;;
85 esac
86
87 # OpenBSD doesn't need libcrypt but many folks keep a stub lib
88 # around for old NetBSD binaries.
89 libswanted=`echo $libswanted | sed 's/ crypt / /'`
90
91 # Configure can't figure this out non-interactively
92 d_suidsafe=$define
93
94 # cc is gcc so we can do better than -O
95 # Allow a command-line override, such as -Doptimize=-g
96 case ${ARCH} in
97 m88k)
98    optimize='-O0'
99    ;;
100 hppa)
101    optimize='-O0'
102    ;;
103 *)
104    test "$optimize" || optimize='-O2'
105    ;;
106 esac
107
108 # This script UU/usethreads.cbu will get 'called-back' by Configure 
109 # after it has prompted the user for whether to use threads.
110 cat > UU/usethreads.cbu <<'EOCBU'
111 case "$usethreads" in
112 $define|true|[yY]*)
113         # any openbsd version dependencies with pthreads?
114         ccflags="-pthread $ccflags"
115         ldflags="-pthread $ldflags"
116         case "$osvers" in
117         [0-2].*|3.[0-2])
118                 # Change from -lc to -lc_r
119                 set `echo "X $libswanted " | sed 's/ c / c_r /'`
120                 shift
121                 libswanted="$*"
122         ;;
123         esac
124         case "$osvers" in
125         [012].*|3.[0-6])
126                 # Broken at least up to OpenBSD 3.6, we'll see about 3.7
127                 d_getservbyname_r=$undef ;;
128         esac
129 esac
130 EOCBU
131
132 # This script UU/use64bitint.cbu will get 'called-back' by Configure 
133 # after it has prompted the user for whether to use 64-bitness.
134 cat > UU/use64bitint.cbu <<'EOCBU'
135 case "$use64bitint" in
136 $define|true|[yY]*)
137         echo " "
138         echo "Checking if your C library has broken 64-bit functions..." >&4
139         $cat >check.c <<EOCP
140 #include <stdio.h>
141 typedef $uquadtype myULL;
142 int main (void)
143 {
144     struct {
145         double d;
146         myULL  u;
147     } *p, test[] = {
148         {4294967303.15, 4294967303ULL},
149         {4294967294.2,  4294967294ULL},
150         {4294967295.7,  4294967295ULL},
151         {0.0, 0ULL}
152     };
153     for (p = test; p->u; p++) {
154         myULL x = (myULL)p->d;
155         if (x != p->u) {
156             printf("buggy\n");
157             return 0;
158         }
159     }
160     printf("ok\n");
161     return 0;
162 }
163 EOCP
164         set check
165         if eval $compile_ok; then
166             libcquad=`./check`
167             echo "Your C library's 64-bit functions are $libcquad."
168         else
169             echo "(I can't seem to compile the test program.)"
170             echo "Assuming that your C library's 64-bit functions are ok."
171             libcquad="ok"
172         fi
173         $rm -f check.c check
174
175         case "$libcquad" in
176             buggy*)
177                 cat >&4 <<EOM
178
179 *** You have a C library with broken 64-bit functions.
180 *** 64-bit support does not work reliably in this configuration.
181 *** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
182 *** Cannot continue, aborting.
183
184 EOM
185                 exit 1
186                 ;;
187         esac
188 esac
189 EOCBU
190
191 # When building in the OpenBSD tree we use different paths
192 # This is only part of the story, the rest comes from config.over
193 case "$openbsd_distribution" in
194 ''|$undef|false) ;;
195 *)
196         # We put things in /usr, not /usr/local
197         prefix='/usr'
198         prefixexp='/usr'
199         sysman='/usr/share/man/man1'
200         libpth='/usr/lib'
201         glibpth='/usr/lib'
202         # Local things, however, do go in /usr/local
203         siteprefix='/usr/local'
204         siteprefixexp='/usr/local'
205         # Ports installs non-std libs in /usr/local/lib so look there too
206         locincpth='/usr/local/include'
207         loclibpth='/usr/local/lib'
208         # Link perl with shared libperl
209         if [ "$usedl" = "$define" -a -r shlib_version ]; then
210                 useshrplib=true
211                 libperl=`. ./shlib_version; echo libperl.so.${major}.${minor}`
212         fi
213         ;;
214 esac
215
216 # end