This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c, regexec.c: Move common code to a function
[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 # When building in the OpenBSD tree we use different paths
133 # This is only part of the story, the rest comes from config.over
134 case "$openbsd_distribution" in
135 ''|$undef|false) ;;
136 *)
137         # We put things in /usr, not /usr/local
138         prefix='/usr'
139         prefixexp='/usr'
140         sysman='/usr/share/man/man1'
141         libpth='/usr/lib'
142         glibpth='/usr/lib'
143         # Local things, however, do go in /usr/local
144         siteprefix='/usr/local'
145         siteprefixexp='/usr/local'
146         # Ports installs non-std libs in /usr/local/lib so look there too
147         locincpth='/usr/local/include'
148         loclibpth='/usr/local/lib'
149         # Link perl with shared libperl
150         if [ "$usedl" = "$define" -a -r shlib_version ]; then
151                 useshrplib=true
152                 libperl=`. ./shlib_version; echo libperl.so.${major}.${minor}`
153         fi
154         ;;
155 esac
156
157 # end