This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mac OS X hints dance continues. Now drop any special
[perl5.git] / hints / darwin.sh
CommitLineData
f556e5b9
JH
1##
2# Darwin (Mac OS) hints
835bc3f3 3# Wilfredo Sanchez <wsanchez@wsanchez.net>
f556e5b9
JH
4##
5
6##
7# Paths
1fe2610c
JH
8#
9# Since Perl 5.8.1: No more special prefix games, no special handling of /usr.
10#
f556e5b9
JH
11
12##
13# Tool chain settings
14##
15
16# Since we can build fat, the archname doesn't need the processor type
17archname='darwin';
18
19# nm works.
20usenm='true';
21
318c098a
JH
22case "$optimize" in
23'')
14c26028
MS
24# Optimizing for size also mean less resident memory usage on the part
25# of Perl. Apple asserts that this is a more important optimization than
26# saving on CPU cycles. Given that memory speed has not increased at
27# pace with CPU speed over time (on any platform), this is probably a
28# reasonable assertion.
21328108 29if [ -z "${optimize}" ]; then
c8037037
MS
30 case "`${cc:-gcc} -v 2>&1`" in
31 *"gcc version 3."*) optimize='-Os' ;;
32 *) optimize='-O3' ;;
21328108 33 esac
c8037037
MS
34else
35 optimize='-O3'
23131aa4 36fi
318c098a
JH
37;;
38esac
f556e5b9 39
faf52077 40# -pipe: makes compilation go faster.
21328108 41# -fno-common because common symbols are not allowed in MH_DYLIB
f72d1791
JH
42# -DDARWIN: apparently the __APPLE__ is not sanctioned by Apple
43# as the way to differentiate Mac OS X. (The official line is that
44# *no* cpp symbol does differentiate Mac OS X.)
45ccflags="${ccflags} -pipe -fno-common -DDARWIN"
f556e5b9 46
4e644a1e 47# At least on Darwin 1.3.x:
ccf87481
JH
48#
49# # define INT32_MIN -2147483648
50# int main () {
51# double a = INT32_MIN;
52# printf ("INT32_MIN=%g\n", a);
53# return 0;
54# }
55# will output:
56# INT32_MIN=2.14748e+09
57# Note that the INT32_MIN has become positive.
58# INT32_MIN is set in /usr/include/stdint.h by:
59# #define INT32_MIN -2147483648
60# which seems to break the gcc. Defining INT32_MIN as (-2147483647-1)
61# seems to work. INT64_MIN seems to be similarly broken.
62# -- Nicholas Clark, Ken Williams, and Edward Moy
63#
65fe0b2a
JH
64# This seems to have been fixed since at least Mac OS X 10.1.3,
65# stdint.h defining INT32_MIN as (-INT32_MAX-1)
66# -- Edward Moy
67#
21328108
HS
68case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
69 *-2147483648) ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" ;;
65fe0b2a 70esac
ccf87481 71
21328108 72# Avoid Apple's cpp precompiler, better for extensions
8f4f83ba 73cppflags="${cppflags} -no-cpp-precomp"
835bc3f3
RGS
74
75# This is necessary because perl's build system doesn't
76# apply cppflags to cc compile lines as it should.
77ccflags="${ccflags} ${cppflags}"
4f8ddd77 78
00371ed5 79# Known optimizer problems.
f5520784 80case "`cc -v 2>&1`" in
21328108 81 *"3.1 20020105"*) toke_cflags='optimize=""' ;;
00371ed5 82esac
2ece6c11 83
f556e5b9
JH
84# Shared library extension is .dylib.
85# Bundle extension is .bundle.
86ld='cc';
87so='dylib';
88dlext='bundle';
89dlsrc='dl_dyld.xs'; usedl='define';
c374061b 90cccdlflags=' '; # space, not empty, because otherwise we get -fpic
21328108 91# Perl bundles do not expect two-level namespace, added in Darwin 1.4.
986530ea 92# But starting from perl 5.8.1/Darwin 7 the default is the two-level.
f29f446b 93case "$osvers" in
cb3fc426 941.[0-3].*)
986530ea
JH
95 lddlflags="${ldflags} -bundle -undefined suppress"
96 ;;
971.*)
98 ldflags="${ldflags} -flat_namespace"
99 lddlflags="${ldflags} -bundle -undefined suppress"
100 ;;
101[2-6].*)
102 ldflags="${ldflags} -flat_namespace"
103 lddlflags="${ldflags} -bundle -undefined suppress"
104 ;;
105*) lddlflags="${ldflags} -bundle -undefined dynamic_lookup"
106 case "$ld" in
107 *MACOSX_DEVELOPMENT_TARGET*) ;;
108 *) ld="MACOSX_DEPLOYMENT_TARGET=10.3 ${ld}" ;;
109 esac
110 ;;
f29f446b 111esac
f556e5b9 112ldlibpthname='DYLD_LIBRARY_PATH';
39225f5c
DK
113
114# useshrplib=true results in much slower startup times.
763754f3 115# 'false' is the default value. Use Configure -Duseshrplib to override.
f556e5b9 116
cb3fc426
JH
117cat > UU/archname.cbu <<'EOCBU'
118# This script UU/archname.cbu will get 'called-back' by Configure
119# after it has otherwise determined the architecture name.
120case "$ldflags" in
986530ea 121*"-flat_namespace"*) ;; # Backward compat, be flat.
cb3fc426
JH
122# If we are using two-level namespace, we will munge the archname to show it.
123*) archname="${archname}-2level" ;;
124esac
125EOCBU
126
f556e5b9
JH
127##
128# System libraries
129##
130
131# vfork works
132usevfork='true';
133
134# malloc works
135usemymalloc='n';
2ece6c11 136
d235852b
PP
137# Locales aren't feeling well.
138LC_ALL=C; export LC_ALL;
14c11978 139LANG=C; export LANG;
d235852b 140
2590a1d7 141#
14c11978 142# The libraries are not threadsafe as of OS X 10.1.
2590a1d7
JH
143#
144# Fix when Apple fixes libc.
145#
3db8f154 146case "$usethreads$useithreads" in
21328108 147 *define*)
9bff986a
AB
148 case "$osvers" in
149 [12345].*) cat <<EOM >&4
150
151
2590a1d7 152
4f8ddd77 153*** Warning, there might be problems with your libraries with
00371ed5
JH
154*** regards to threading. The test ext/threads/t/libc.t is likely
155*** to fail.
4f8ddd77 156
2590a1d7 157EOM
21328108 158 ;;
9bff986a
AB
159 *) usereentrant='define';;
160 esac
161
2590a1d7 162esac
835bc3f3
RGS
163
164##
165# Build process
166##
167
168# Case-insensitive filesystems don't get along with Makefile and
169# makefile in the same place. Since Darwin uses GNU make, this dodges
170# the problem.
171firstmakefile=GNUmakefile;