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