1# hints/netbsd.sh 2# 3# Please check with packages@netbsd.org before making modifications 4# to this file. 5 6case "$archname" in 7'') 8 archname=`uname -m`-${osname} 9 ;; 10esac 11 12# NetBSD keeps dynamic loading dl*() functions in /usr/lib/crt0.o, 13# so Configure doesn't find them (unless you abandon the nm scan). 14# Also, NetBSD 0.9a was the first release to introduce shared 15# libraries. 16# 17case "$osvers" in 180.9|0.8*) 19 usedl="$undef" 20 ;; 21*) 22 case `uname -m` in 23 pmax) 24 # NetBSD 1.3 and 1.3.1 on pmax shipped an `old' ld.so, 25 # which will not work. 26 case "$osvers" in 27 1.3|1.3.1) 28 d_dlopen=$undef 29 ;; 30 esac 31 ;; 32 esac 33 if test -f /usr/libexec/ld.elf_so; then 34 # ELF 35 d_dlopen=$define 36 d_dlerror=$define 37 cccdlflags="-DPIC -fPIC $cccdlflags" 38 lddlflags="-shared $lddlflags" 39 cat >UU/cc.cbu <<'EOCBU' 40# gcc 4.6 doesn't support --whole-archive, but it's required for the 41# system gcc to build correctly, so check for it 42echo 'int f(void) { return 0; }' >try.c 43if ${cc:-cc} $cccdlflags -c try.c -otry.o 2>&1 && 44 ${cc:-cc} --whole-archive $lddlflags try.o -otry.so 2>&1 ; then 45 lddlflags="--whole-archive $lddlflags" 46fi 47rm try.c try.o try.so 2>/dev/null 48EOCBU 49 rpathflag="-Wl,-rpath," 50 case "$osvers" in 51 1.[0-5]*) 52 # 53 # Include the whole libgcc.a into the perl executable 54 # so that certain symbols needed by loadable modules 55 # built as C++ objects (__eh_alloc, __pure_virtual, 56 # etc.) will always be defined. 57 # 58 ccdlflags="-Wl,-whole-archive -lgcc \ 59 -Wl,-no-whole-archive -Wl,-E $ccdlflags" 60 ;; 61 *) 62 ccdlflags="-Wl,-E $ccdlflags" 63 ;; 64 esac 65 elif test -f /usr/libexec/ld.so; then 66 # a.out 67 d_dlopen=$define 68 d_dlerror=$define 69 cccdlflags="-DPIC -fPIC $cccdlflags" 70 lddlflags="-Bshareable $lddlflags" 71 rpathflag="-R" 72 else 73 d_dlopen=$undef 74 rpathflag= 75 fi 76 ;; 77esac 78 79# netbsd had these but they don't really work as advertised, in the 80# versions listed below. if they are defined, then there isn't a 81# way to make perl call setuid() or setgid(). if they aren't, then 82# ($<, $>) = ($u, $u); will work (same for $(/$)). this is because 83# you can not change the real userid of a process under 4.4BSD. 84# netbsd fixed this in 1.3.2. 85case "$osvers" in 860.9*|1.[012]*|1.3|1.3.1) 87 d_setregid="$undef" 88 d_setreuid="$undef" 89 ;; 90esac 91case "$osvers" in 920.9*|1.*|2.*|3.*|4.*|5.*|6.*) 93 d_getprotoent_r="$undef" 94 d_getprotobyname_r="$undef" 95 d_getprotobynumber_r="$undef" 96 d_setprotoent_r="$undef" 97 d_endprotoent_r="$undef" 98 d_getservent_r="$undef" 99 d_getservbyname_r="$undef" 100 d_getservbyport_r="$undef" 101 d_setservent_r="$undef" 102 d_endservent_r="$undef" 103 d_getprotoent_r_proto="0" 104 d_getprotobyname_r_proto="0" 105 d_getprotobynumber_r_proto="0" 106 d_setprotoent_r_proto="0" 107 d_endprotoent_r_proto="0" 108 d_getservent_r_proto="0" 109 d_getservbyname_r_proto="0" 110 d_getservbyport_r_proto="0" 111 d_setservent_r_proto="0" 112 d_endservent_r_proto="0" 113 ;; 114esac 115 116# These are obsolete in any netbsd. 117d_setrgid="$undef" 118d_setruid="$undef" 119 120# there's no problem with vfork. 121usevfork=true 122 123# This is there but in machine/ieeefp_h. 124ieeefp_h="define" 125 126# This script UU/usethreads.cbu will get 'called-back' by Configure 127# after it has prompted the user for whether to use threads. 128cat > UU/usethreads.cbu <<'EOCBU' 129case "$usethreads" in 130$define|true|[yY]*) 131 lpthread= 132 for xxx in pthread; do 133 for yyy in $loclibpth $plibpth $glibpth dummy; do 134 zzz=$yyy/lib$xxx.a 135 if test -f "$zzz"; then 136 lpthread=$xxx 137 break; 138 fi 139 zzz=$yyy/lib$xxx.so 140 if test -f "$zzz"; then 141 lpthread=$xxx 142 break; 143 fi 144 zzz=`ls $yyy/lib$xxx.so.* 2>/dev/null` 145 if test "X$zzz" != X; then 146 lpthread=$xxx 147 break; 148 fi 149 done 150 if test "X$lpthread" != X; then 151 break; 152 fi 153 done 154 if test "X$lpthread" != X; then 155 # Add -lpthread. 156 libswanted="$libswanted $lpthread" 157 # There is no libc_r as of NetBSD 1.5.2, so no c -> c_r. 158 # This will be revisited when NetBSD gains a native pthreads 159 # implementation. 160 else 161 echo "$0: No POSIX threads library (-lpthread) found. " \ 162 "You may want to install GNU pth. Aborting." >&4 163 exit 1 164 fi 165 unset lpthread 166 167 # several reentrant functions are embedded in libc, but haven't 168 # been added to the header files yet. Let's hold off on using 169 # them until they are a valid part of the API 170 case "$osvers" in 171 [012].*|3.[0-1]) 172 d_getprotobyname_r=$undef 173 d_getprotobynumber_r=$undef 174 d_getprotoent_r=$undef 175 d_getservbyname_r=$undef 176 d_getservbyport_r=$undef 177 d_getservent_r=$undef 178 d_setprotoent_r=$undef 179 d_setservent_r=$undef 180 d_endprotoent_r=$undef 181 d_endservent_r=$undef ;; 182 esac 183 ;; 184 185esac 186EOCBU 187 188# Set sensible defaults for NetBSD: look for local software in 189# /usr/pkg (NetBSD Packages Collection) and in /usr/local. 190# 191loclibpth="/usr/pkg/lib /usr/local/lib" 192locincpth="/usr/pkg/include /usr/local/include" 193case "$rpathflag" in 194'') 195 ldflags= 196 ;; 197*) 198 ldflags= 199 for yyy in $loclibpth; do 200 ldflags="$ldflags $rpathflag$yyy" 201 done 202 ;; 203esac 204 205case `uname -m` in 206alpha) 207 echo 'int main() {}' > try.c 208 gcc=`${cc:-cc} -v -c try.c 2>&1|grep 'gcc version egcs-2'` 209 case "$gcc" in 210 '' | "gcc version egcs-2.95."[3-9]*) ;; # 2.95.3 or better okay 211 *) cat >&4 <<EOF 212*** 213*** Your gcc ($gcc) is known to be 214*** too buggy on netbsd/alpha to compile Perl with optimization. 215*** It is suggested you install the lang/gcc package which should 216*** have at least gcc 2.95.3 which should work okay: use for example 217*** Configure -Dcc=/usr/pkg/gcc-2.95.3/bin/cc. You could also 218*** Configure -Doptimize=-O0 to compile Perl without any optimization 219*** but that is not recommended. 220*** 221EOF 222 exit 1 223 ;; 224 esac 225 rm -f try.* 226 ;; 227esac 228 229# NetBSD/sparc 1.5.3/1.6.1 dumps core in the semid_ds test of Configure. 230case `uname -m` in 231sparc) d_semctl_semid_ds=undef ;; 232esac 233 234# malloc wrap works 235case "$usemallocwrap" in 236'') usemallocwrap='define' ;; 237esac 238 239# don't use perl malloc by default 240case "$usemymalloc" in 241'') usemymalloc=n ;; 242esac 243