0d41d7300254d8cdc9162153f73e1a90f21f3ff5
[p5sagit/p5-mst-13.2.git] / hints / darwin.sh
1 ##
2 # Darwin (Mac OS) hints
3 # Wilfredo Sanchez <wsanchez@wsanchez.net>
4 ##
5
6 ##
7 # Paths
8 ##
9
10 # Configure hasn't figured out the version number yet.  Bummer.
11 perl_revision=`awk '/define[    ]+PERL_REVISION/ {print $3}' $src/patchlevel.h`
12 perl_version=`awk '/define[     ]+PERL_VERSION/ {print $3}' $src/patchlevel.h`
13 perl_subversion=`awk '/define[  ]+PERL_SUBVERSION/ {print $3}' $src/patchlevel.h`
14 version="${perl_revision}.${perl_version}.${perl_subversion}"
15
16 # BSD paths
17 case "$prefix" in
18   '')
19     # Default install; use non-system directories
20     prefix='/usr/local'; # Built-in perl uses /usr
21     siteprefix='/usr/local';
22     vendorprefix='/usr'; usevendorprefix='define';
23
24     # Where to put modules.
25     sitelib="/Library/Perl/${version}"; # FIXME: Want "/Network/Perl/${version}" also
26     vendorlib="/System/Library/Perl/${version}"; # Apple-supplied modules
27     ;;
28
29   '/usr')
30     # We are building/replacing the built-in perl
31     siteprefix='/usr/local';
32     vendorprefix='/usr/local'; usevendorprefix='define';
33
34     # Where to put modules.
35     sitelib="/Library/Perl/${version}"; # FIXME: Want "/Network/Perl/${version}" also
36     vendorlib="/System/Library/Perl/${version}"; # Apple-supplied modules
37     ;;
38
39   *)
40     # Anything else; use non-system directories
41     # prefix=$prefix; # Built-in perl uses /usr
42     siteprefix=$prefix;
43     vendorprefix='/usr'; usevendorprefix='define';
44
45     # Where to put modules.
46     sitelib=$prefix/lib/perl5/site_perl/${version}
47     # Use -Uvendorlib to not to get /System/Library.
48     case "$vendorlib" in
49     '') vendorlib="/System/Library/Perl/${version}"; # Apple-supplied modules
50     esac
51     ;;
52
53 esac
54
55 # 4BSD uses ${prefix}/share/man, not ${prefix}/man.
56 man1dir="${prefix}/share/man/man1";
57 man3dir="${prefix}/share/man/man3";
58
59 ##
60 # Tool chain settings
61 ##
62
63 # Since we can build fat, the archname doesn't need the processor type
64 archname='darwin';
65
66 # nm works.
67 usenm='true';
68
69 case "$optimize" in
70 '')
71 #    Optimizing for size also mean less resident memory usage on the part
72 # of Perl.  Apple asserts that this is a more important optimization than
73 # saving on CPU cycles.  Given that memory speed has not increased at
74 # pace with CPU speed over time (on any platform), this is probably a
75 # reasonable assertion.
76 if [ -z "${optimize}" ]; then
77   case "`${cc:-gcc} -v 2>&1`" in
78     *"gcc version 3."*) optimize='-Os' ;;
79     *) optimize='-O3' ;;
80   esac
81 else
82   optimize='-O3'
83 fi
84 ;;
85 esac
86
87 # -pipe: makes compilation go faster.
88 # -fno-common because common symbols are not allowed in MH_DYLIB
89 # -DDARWIN: apparently the __APPLE__ is not sanctioned by Apple
90 # as the way to differentiate Mac OS X.  (The official line is that
91 # *no* cpp symbol does differentiate Mac OS X.)
92 ccflags="${ccflags} -pipe -fno-common -DDARWIN"
93
94 # At least on Darwin 1.3.x:
95 #
96 # # define INT32_MIN -2147483648
97 # int main () {
98 #  double a = INT32_MIN;
99 #  printf ("INT32_MIN=%g\n", a);
100 #  return 0;
101 # }
102 # will output:
103 # INT32_MIN=2.14748e+09
104 # Note that the INT32_MIN has become positive.
105 # INT32_MIN is set in /usr/include/stdint.h by:
106 # #define INT32_MIN        -2147483648
107 # which seems to break the gcc.  Defining INT32_MIN as (-2147483647-1)
108 # seems to work.  INT64_MIN seems to be similarly broken.
109 # -- Nicholas Clark, Ken Williams, and Edward Moy
110 #
111 # This seems to have been fixed since at least Mac OS X 10.1.3,
112 # stdint.h defining INT32_MIN as (-INT32_MAX-1)
113 # -- Edward Moy
114 #
115 case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
116   *-2147483648) ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" ;;
117 esac
118
119 # Avoid Apple's cpp precompiler, better for extensions
120 cppflags="${cppflags} -no-cpp-precomp"
121
122 # This is necessary because perl's build system doesn't
123 # apply cppflags to cc compile lines as it should.
124 ccflags="${ccflags} ${cppflags}"
125
126 # Known optimizer problems.
127 case "`cc -v 2>&1`" in
128   *"3.1 20020105"*) toke_cflags='optimize=""' ;;
129 esac
130
131 # Shared library extension is .dylib.
132 # Bundle extension is .bundle.
133 ld='cc';
134 so='dylib';
135 dlext='bundle';
136 dlsrc='dl_dyld.xs'; usedl='define';
137 cccdlflags=' '; # space, not empty, because otherwise we get -fpic
138 # Perl bundles do not expect two-level namespace, added in Darwin 1.4.
139 # But starting from perl 5.8.1/Darwin 7 the default is the two-level.
140 case "$osvers" in
141 1.[0-3].*)
142    lddlflags="${ldflags} -bundle -undefined suppress"
143    ;;
144 1.*)
145    ldflags="${ldflags} -flat_namespace"
146    lddlflags="${ldflags} -bundle -undefined suppress"
147    ;;
148 [2-6].*)
149    ldflags="${ldflags} -flat_namespace"
150    lddlflags="${ldflags} -bundle -undefined suppress"
151    ;;
152 *) lddlflags="${ldflags} -bundle -undefined dynamic_lookup"
153    case "$ld" in
154    *MACOSX_DEVELOPMENT_TARGET*) ;;
155    *) ld="MACOSX_DEPLOYMENT_TARGET=10.3 ${ld}" ;;
156    esac
157    ;;
158 esac
159 ldlibpthname='DYLD_LIBRARY_PATH';
160
161 # useshrplib=true results in much slower startup times.
162 # 'false' is the default value.  Use Configure -Duseshrplib to override.
163
164 cat > UU/archname.cbu <<'EOCBU'
165 # This script UU/archname.cbu will get 'called-back' by Configure 
166 # after it has otherwise determined the architecture name.
167 case "$ldflags" in
168 *"-flat_namespace"*) ;; # Backward compat, be flat.
169 # If we are using two-level namespace, we will munge the archname to show it.
170 *) archname="${archname}-2level" ;;
171 esac
172 EOCBU
173
174 ##
175 # System libraries
176 ##
177
178 # vfork works
179 usevfork='true';
180
181 # malloc works
182 usemymalloc='n';
183
184 # Locales aren't feeling well.
185 LC_ALL=C; export LC_ALL;
186 LANG=C; export LANG;
187
188 #
189 # The libraries are not threadsafe as of OS X 10.1.
190 #
191 # Fix when Apple fixes libc.
192 #
193 case "$usethreads$useithreads" in
194   *define*)
195   case "$osvers" in
196     [12345].*)     cat <<EOM >&4
197
198
199
200 *** Warning, there might be problems with your libraries with
201 *** regards to threading.  The test ext/threads/t/libc.t is likely
202 *** to fail.
203
204 EOM
205     ;;
206     *) usereentrant='define';;
207   esac
208
209 esac
210
211 ##
212 # Build process
213 ##
214
215 # Case-insensitive filesystems don't get along with Makefile and
216 # makefile in the same place.  Since Darwin uses GNU make, this dodges
217 # the problem.
218 firstmakefile=GNUmakefile;