1db43655a1adfe9a1dc85228625bbd47e54eb2fe
[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 # Since Perl 5.8.1: No more special prefix games, no special handling of /usr.
10 #
11
12 ##
13 # Tool chain settings
14 ##
15
16 # Since we can build fat, the archname doesn't need the processor type
17 archname='darwin';
18
19 # nm works.
20 usenm='true';
21
22 case "$optimize" in
23 '')
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.
29 if [ -z "${optimize}" ]; then
30   case "`${cc:-gcc} -v 2>&1`" in
31     *"gcc version 3."*) optimize='-Os' ;;
32     *) optimize='-O3' ;;
33   esac
34 else
35   optimize='-O3'
36 fi
37 ;;
38 esac
39
40 # -pipe: makes compilation go faster.
41 # -fno-common because common symbols are not allowed in MH_DYLIB
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.)
45 ccflags="${ccflags} -pipe -fno-common -DDARWIN"
46
47 # At least on Darwin 1.3.x:
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 #
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 #
68 case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
69   *-2147483648) ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" ;;
70 esac
71
72 # Avoid Apple's cpp precompiler, better for extensions
73 cppflags="${cppflags} -no-cpp-precomp"
74
75 # This is necessary because perl's build system doesn't
76 # apply cppflags to cc compile lines as it should.
77 ccflags="${ccflags} ${cppflags}"
78
79 # Known optimizer problems.
80 case "`cc -v 2>&1`" in
81   *"3.1 20020105"*) toke_cflags='optimize=""' ;;
82 esac
83
84 # Shared library extension is .dylib.
85 # Bundle extension is .bundle.
86 ld='cc';
87 so='dylib';
88 dlext='bundle';
89 dlsrc='dl_dyld.xs'; usedl='define';
90 cccdlflags=' '; # space, not empty, because otherwise we get -fpic
91 # Perl bundles do not expect two-level namespace, added in Darwin 1.4.
92 # But starting from perl 5.8.1/Darwin 7 the default is the two-level.
93 case "$osvers" in
94 1.[0-3].*)
95    lddlflags="${ldflags} -bundle -undefined suppress"
96    ;;
97 1.*)
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    ;;
111 esac
112 ldlibpthname='DYLD_LIBRARY_PATH';
113
114 # useshrplib=true results in much slower startup times.
115 # 'false' is the default value.  Use Configure -Duseshrplib to override.
116
117 cat > 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.
120 case "$ldflags" in
121 *"-flat_namespace"*) ;; # Backward compat, be flat.
122 # If we are using two-level namespace, we will munge the archname to show it.
123 *) archname="${archname}-2level" ;;
124 esac
125 EOCBU
126
127 ##
128 # System libraries
129 ##
130
131 # vfork works
132 usevfork='true';
133
134 # malloc works
135 usemymalloc='n';
136
137 # Locales aren't feeling well.
138 LC_ALL=C; export LC_ALL;
139 LANG=C; export LANG;
140
141 #
142 # The libraries are not threadsafe as of OS X 10.1.
143 #
144 # Fix when Apple fixes libc.
145 #
146 case "$usethreads$useithreads" in
147   *define*)
148   case "$osvers" in
149     [12345].*)     cat <<EOM >&4
150
151
152
153 *** Warning, there might be problems with your libraries with
154 *** regards to threading.  The test ext/threads/t/libc.t is likely
155 *** to fail.
156
157 EOM
158     ;;
159     *) usereentrant='define';;
160   esac
161
162 esac
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.
171 firstmakefile=GNUmakefile;