This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge branch 'core-team-data' into blead
[perl5.git] / hints / netbsd.sh
1 # hints/netbsd.sh
2 #
3 # Please check with packages@netbsd.org before making modifications
4 # to this file.
5
6 case "$archname" in
7 '')
8     archname=`uname -m`-${osname}
9     ;;
10 esac
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 #
17 case "$osvers" in
18 0.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
42 echo 'int f(void) { return 0; }' >try.c
43 if ${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"
46 fi
47 rm try.c try.o try.so 2>/dev/null
48 EOCBU
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         ;;
77 esac
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.
85 case "$osvers" in
86 0.9*|1.[012]*|1.3|1.3.1)
87         d_setregid="$undef"
88         d_setreuid="$undef"
89         ;;
90 esac
91 case "$osvers" in
92 0.8*)
93         ;;
94 *)
95         d_getprotoent_r="$undef"
96         d_getprotobyname_r="$undef"
97         d_getprotobynumber_r="$undef"
98         d_setprotoent_r="$undef"
99         d_endprotoent_r="$undef"
100         d_getservent_r="$undef"
101         d_getservbyname_r="$undef"
102         d_getservbyport_r="$undef"
103         d_setservent_r="$undef"
104         d_endservent_r="$undef"
105         d_gethostbyname_r="$undef"
106         d_gethostbyaddr2_r="$undef"
107         d_gethostbyaddr_r="$undef"
108         d_sethostent_r="$undef"
109         d_gethostent_r="$undef"
110         d_endhostent_r="$undef"
111         d_getprotoent_r_proto="0"
112         d_getprotobyname_r_proto="0"
113         d_getprotobynumber_r_proto="0"
114         d_setprotoent_r_proto="0"
115         d_endprotoent_r_proto="0"
116         d_getservent_r_proto="0"
117         d_getservbyname_r_proto="0"
118         d_getservbyport_r_proto="0"
119         d_setservent_r_proto="0"
120         d_endservent_r_proto="0"
121         d_gethostbyname_r_proto="0"
122         d_gethostbyaddr2_r_proto="0"
123         d_gethostbyaddr_r_proto="0"
124         d_sethostent_r_proto="0"
125         d_endhostent_r_proto="0"
126         d_gethostent_r_proto="0"
127         ;;
128 esac
129
130 # These are obsolete in any netbsd.
131 d_setrgid="$undef"
132 d_setruid="$undef"
133
134 # there's no problem with vfork.
135 usevfork=true
136
137 # This is there but in machine/ieeefp_h.
138 ieeefp_h="define"
139
140 # This script UU/usethreads.cbu will get 'called-back' by Configure
141 # after it has prompted the user for whether to use threads.
142 cat > UU/usethreads.cbu <<'EOCBU'
143 case "$usethreads" in
144 $define|true|[yY]*)
145         lpthread=
146         for xxx in pthread; do
147                 for yyy in $loclibpth $plibpth $glibpth dummy; do
148                         zzz=$yyy/lib$xxx.a
149                         if test -f "$zzz"; then
150                                 lpthread=$xxx
151                                 break;
152                         fi
153                         zzz=$yyy/lib$xxx.so
154                         if test -f "$zzz"; then
155                                 lpthread=$xxx
156                                 break;
157                         fi
158                         zzz=`ls $yyy/lib$xxx.so.* 2>/dev/null`
159                         if test "X$zzz" != X; then
160                                 lpthread=$xxx
161                                 break;
162                         fi
163                 done
164                 if test "X$lpthread" != X; then
165                         break;
166                 fi
167         done
168         if test "X$lpthread" != X; then
169                 # Add -lpthread.
170                 libswanted="$libswanted $lpthread"
171                 # There is no libc_r as of NetBSD 1.5.2, so no c -> c_r.
172                 # This will be revisited when NetBSD gains a native pthreads
173                 # implementation.
174         else
175                 echo "$0: No POSIX threads library (-lpthread) found.  " \
176                      "You may want to install GNU pth.  Aborting." >&4
177                 exit 1
178         fi
179         unset lpthread
180
181         # several reentrant functions are embedded in libc, but haven't
182         # been added to the header files yet.  Let's hold off on using
183         # them until they are a valid part of the API
184         case "$osvers" in
185         [012].*|3.[0-1])
186                 d_getprotobyname_r=$undef
187                 d_getprotobynumber_r=$undef
188                 d_getprotoent_r=$undef
189                 d_getservbyname_r=$undef
190                 d_getservbyport_r=$undef
191                 d_getservent_r=$undef
192                 d_setprotoent_r=$undef
193                 d_setservent_r=$undef
194                 d_endprotoent_r=$undef
195                 d_endservent_r=$undef ;;
196         esac
197         ;;
198
199 esac
200 EOCBU
201
202 # Set sensible defaults for NetBSD: look for local software in
203 # /usr/pkg (NetBSD Packages Collection) and in /usr/local.
204 #
205 loclibpth="/usr/pkg/lib /usr/local/lib"
206 locincpth="/usr/pkg/include /usr/local/include"
207 case "$rpathflag" in
208 '')
209         ldflags=
210         ;;
211 *)
212         ldflags=
213         for yyy in $loclibpth; do
214                 ldflags="$ldflags $rpathflag$yyy"
215         done
216         ;;
217 esac
218
219 case `uname -m` in
220 alpha)
221     echo 'int main() {}' > try.c
222     gcc=`${cc:-cc} -v -c try.c 2>&1|grep 'gcc version egcs-2'`
223     case "$gcc" in
224     '' | "gcc version egcs-2.95."[3-9]*) ;; # 2.95.3 or better okay
225     *)  cat >&4 <<EOF
226 ***
227 *** Your gcc ($gcc) is known to be
228 *** too buggy on netbsd/alpha to compile Perl with optimization.
229 *** It is suggested you install the lang/gcc package which should
230 *** have at least gcc 2.95.3 which should work okay: use for example
231 *** Configure -Dcc=/usr/pkg/gcc-2.95.3/bin/cc.  You could also
232 *** Configure -Doptimize=-O0 to compile Perl without any optimization
233 *** but that is not recommended.
234 ***
235 EOF
236         exit 1
237         ;;
238     esac
239     rm -f try.*
240     ;;
241 esac
242
243 # NetBSD/sparc 1.5.3/1.6.1 dumps core in the semid_ds test of Configure.
244 case `uname -m` in
245 sparc) d_semctl_semid_ds=undef ;;
246 esac
247
248 # malloc wrap works
249 case "$usemallocwrap" in
250 '') usemallocwrap='define' ;;
251 esac
252
253 # don't use perl malloc by default
254 case "$usemymalloc" in
255 '') usemymalloc=n ;;
256 esac
257
258 # NetBSD 6 defines the *at() functions in libc, but either doesn't
259 # implement them, or implements them only for AT_FDCWD
260 case "$osver" in
261 [1-6].*)
262         d_unlinkat="$undef"
263         d_renameat="$undef"
264         d_linkat="$undef"
265         d_fchmodat="$undef"
266         ;;
267 esac
268
269 cat >UU/uselongdouble.cbu <<'EOCBU'
270 # This script UU/uselongdouble.cbu will get 'called-back' by Configure
271 # after it has prompted the user for whether to use long doubles.
272 #
273 # See https://github.com/Perl/perl5/issues/17853 and https://github.com/Perl/perl5/issues/17854
274 case "$uselongdouble" in
275 $define|true|[yY]*)
276     cat >try.c <<\TRY
277 #include <stdio.h>
278 #include <math.h>
279
280 long double x = 1.0;
281
282 int main(int argc, char **argv) {
283     double e1 = exp(1.0);
284     /* as of NetBSD 9.0 expl() just calls exp(),
285        Fail here if they're equal. */
286     return expl(x) == (long double)e1;
287 }
288 TRY
289     if $cc -o try $ccflags $ldflags try.c -lm && $run ./try; then
290         echo "NetBSD seem to have fixed expl (and hopefully more)" >&4
291     else
292         cat <<EOM >&4
293
294 Warning! NetBSD's long double support is limited enough that it will cause
295 test failures, and possibly build failures, and this doesn't appear to have
296 been fixed in the release you're running.
297
298 EOM
299     fi
300 ;;
301 esac
302 EOCBU