Commit | Line | Data |
---|---|---|
9ff7b177 JH |
1 | If you read this file _as_is_, just ignore the funny characters you see. |
2 | It is written in the POD format (see pod/perlpod.pod) which is specially | |
3 | designed to be readable as is. | |
4 | ||
5 | =head1 NAME | |
6 | ||
de2902a6 | 7 | perlmacosx - Perl under Mac OS X |
9ff7b177 JH |
8 | |
9 | =head1 SYNOPSIS | |
10 | ||
0947f90e | 11 | This document briefly describes Perl under Mac OS X. |
9ff7b177 | 12 | |
bab3f9d4 PM |
13 | curl -O http://www.cpan.org/src/perl-5.21.4.tar.gz |
14 | tar -xzf perl-5.21.4.tar.gz | |
15 | cd perl-5.21.4 | |
0947f90e LL |
16 | ./Configure -des -Dprefix=/usr/local/ |
17 | make | |
18 | make test | |
19 | sudo make install | |
9ff7b177 JH |
20 | |
21 | =head1 DESCRIPTION | |
22 | ||
bab3f9d4 | 23 | The latest Perl release (5.21.4 as of this writing) builds without changes |
0947f90e | 24 | under all versions of Mac OS X from 10.3 "Panther" onwards. |
9ff7b177 | 25 | |
f97f22a3 BO |
26 | In order to build your own version of Perl you will need 'make', |
27 | which is part of Apple's developer tools - also known as Xcode. From | |
28 | Mac OS X 10.7 "Lion" onwards, it can be downloaded separately as the | |
29 | 'Command Line Tools' bundle directly from L<https://developer.apple.com/downloads/> | |
30 | (you will need a free account to log in), or as a part of the Xcode suite, | |
31 | freely available at the App Store. Xcode is a pretty big app, so | |
32 | unless you already have it or really want it, you are advised to get the | |
33 | 'Command Line Tools' bundle separately from the link above. If you want | |
34 | to do it from within Xcode, go to Xcode -> Preferences -> Downloads and | |
35 | select the 'Command Line Tools' option. | |
36 | ||
37 | Between Mac OS X 10.3 "Panther" and 10.6 "Snow Leopard", the 'Command | |
38 | Line Tools' bundle was called 'unix tools', and was usually supplied | |
39 | with Mac OS install DVDs. | |
b9f41ca8 | 40 | |
e30a8c0c SP |
41 | Earlier Mac OS X releases (10.2 "Jaguar" and older) did not include a |
42 | completely thread-safe libc, so threading is not fully supported. Also, | |
43 | earlier releases included a buggy libdb, so some of the DB_File tests | |
44 | are known to fail on those releases. | |
9ff7b177 JH |
45 | |
46 | ||
f7451e23 | 47 | =head2 Installation Prefix |
9ff7b177 JH |
48 | |
49 | The default installation location for this release uses the traditional | |
50 | UNIX directory layout under /usr/local. This is the recommended location | |
51 | for most users, and will leave the Apple-supplied Perl and its modules | |
52 | undisturbed. | |
53 | ||
54 | Using an installation prefix of '/usr' will result in a directory layout | |
55 | that mirrors that of Apple's default Perl, with core modules stored in | |
56 | '/System/Library/Perl/${version}', CPAN modules stored in | |
57 | '/Library/Perl/${version}', and the addition of | |
58 | '/Network/Library/Perl/${version}' to @INC for modules that are stored | |
59 | on a file server and used by many Macs. | |
60 | ||
61 | ||
e30a8c0c SP |
62 | =head2 SDK support |
63 | ||
64 | First, export the path to the SDK into the build environment: | |
65 | ||
f97f22a3 | 66 | export SDK=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk |
e30a8c0c | 67 | |
f97f22a3 BO |
68 | Please make sure the SDK version (i.e. the numbers right before '.sdk') |
69 | matches your system's (in this case, Mac OS X 10.8 "Mountain Lion"), as it is | |
70 | possible to have more than one SDK installed. Also make sure the path exists | |
71 | in your system, and if it doesn't please make sure the SDK is properly | |
72 | installed, as it should come with the 'Command Line Tools' bundle mentioned | |
73 | above. Finally, if you have an older Mac OS X (10.6 "Snow Leopard" and below) | |
74 | running Xcode 4.2 or lower, the SDK path might be something like | |
75 | C<'/Developer/SDKs/MacOSX10.3.9.sdk'>. | |
76 | ||
77 | You can use the SDK by exporting some additions to Perl's 'ccflags' and '..flags' | |
e30a8c0c SP |
78 | config variables: |
79 | ||
80 | ./Configure -Accflags="-nostdinc -B$SDK/usr/include/gcc \ | |
81 | -B$SDK/usr/lib/gcc -isystem$SDK/usr/include \ | |
82 | -F$SDK/System/Library/Frameworks" \ | |
83 | -Aldflags="-Wl,-syslibroot,$SDK" \ | |
84 | -de | |
85 | ||
86 | =head2 Universal Binary support | |
87 | ||
f97f22a3 BO |
88 | Note: From Mac OS X 10.6 "Snow Leopard" onwards, Apple only supports |
89 | Intel-based hardware. This means you can safely skip this section unless | |
90 | you have an older Apple computer running on ppc or wish to create a perl | |
91 | binary with backwards compatibility. | |
92 | ||
93 | You can compile perl as a universal binary (built for both ppc and intel). | |
94 | In Mac OS X 10.4 "Tiger", you must export the 'u' variant of the SDK: | |
e30a8c0c SP |
95 | |
96 | export SDK=/Developer/SDKs/MacOSX10.4u.sdk | |
97 | ||
f97f22a3 BO |
98 | Mac OS X 10.5 "Leopard" and above do not require the 'u' variant. |
99 | ||
e30a8c0c SP |
100 | In addition to the compiler flags used to select the SDK, also add the flags |
101 | for creating a universal binary: | |
102 | ||
103 | ./Configure -Accflags="-arch i686 -arch ppc -nostdinc -B$SDK/usr/include/gcc \ | |
104 | -B$SDK/usr/lib/gcc -isystem$SDK/usr/include \ | |
105 | -F$SDK/System/Library/Frameworks" \ | |
106 | -Aldflags="-arch i686 -arch ppc -Wl,-syslibroot,$SDK" \ | |
107 | -de | |
108 | ||
109 | Keep in mind that these compiler and linker settings will also be used when | |
110 | building CPAN modules. For XS modules to be compiled as a universal binary, any | |
111 | libraries it links to must also be universal binaries. The system libraries that | |
112 | Apple includes with the 10.4u SDK are all universal, but user-installed libraries | |
113 | may need to be re-installed as universal binaries. | |
114 | ||
ee94f810 DD |
115 | =head2 64-bit PPC support |
116 | ||
117 | Follow the instructions in F<INSTALL> to build perl with support for 64-bit | |
118 | integers (C<use64bitint>) or both 64-bit integers and 64-bit addressing | |
119 | (C<use64bitall>). In the latter case, the resulting binary will run only | |
120 | on G5-based hosts. | |
121 | ||
122 | Support for 64-bit addressing is experimental: some aspects of Perl may be | |
123 | omitted or buggy. Note the messages output by F<Configure> for further | |
124 | information. Please use C<perlbug> to submit a problem report in the | |
125 | event that you encounter difficulties. | |
126 | ||
f858446f | 127 | When building 64-bit modules, it is your responsibility to ensure that linked |
ee94f810 DD |
128 | external libraries and frameworks provide 64-bit support: if they do not, |
129 | module building may appear to succeed, but attempts to use the module will | |
130 | result in run-time dynamic linking errors, and subsequent test failures. | |
131 | You can use C<file> to discover the architectures supported by a library: | |
132 | ||
133 | $ file libgdbm.3.0.0.dylib | |
134 | libgdbm.3.0.0.dylib: Mach-O fat file with 2 architectures | |
135 | libgdbm.3.0.0.dylib (for architecture ppc): Mach-O dynamically linked shared library ppc | |
136 | libgdbm.3.0.0.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64 | |
137 | ||
138 | Note that this issue precludes the building of many Macintosh-specific CPAN | |
139 | modules (C<Mac::*>), as the required Apple frameworks do not provide PPC64 | |
140 | support. Similarly, downloads from Fink or Darwinports are unlikely to provide | |
141 | 64-bit support; the libraries must be rebuilt from source with the appropriate | |
142 | compiler and linker flags. For further information, see Apple's | |
143 | I<64-Bit Transition Guide> at | |
144 | L<http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/index.html>. | |
145 | ||
f7451e23 | 146 | =head2 libperl and Prebinding |
9ff7b177 JH |
147 | |
148 | Mac OS X ships with a dynamically-loaded libperl, but the default for | |
149 | this release is to compile a static libperl. The reason for this is | |
150 | pre-binding. Dynamic libraries can be pre-bound to a specific address in | |
151 | memory in order to decrease load time. To do this, one needs to be aware | |
152 | of the location and size of all previously-loaded libraries. Apple | |
153 | collects this information as part of their overall OS build process, and | |
154 | thus has easy access to it when building Perl, but ordinary users would | |
155 | need to go to a great deal of effort to obtain the information needed | |
156 | for pre-binding. | |
157 | ||
f7451e23 | 158 | You can override the default and build a shared libperl if you wish |
f97f22a3 | 159 | (S<Configure ... -Duseshrplib>). |
9ff7b177 | 160 | |
f97f22a3 BO |
161 | With Mac OS X 10.4 "Tiger" and newer, there is almost no performance |
162 | penalty for non-prebound libraries. Earlier releases will suffer a greater | |
163 | load time than either the static library, or Apple's pre-bound dynamic library. | |
9ff7b177 | 164 | |
e30a8c0c | 165 | =head2 Updating Apple's Perl |
ffb8d87a | 166 | |
f97f22a3 | 167 | In a word - don't, at least not without a *very* good reason. Your scripts |
e30a8c0c SP |
168 | can just as easily begin with "#!/usr/local/bin/perl" as with |
169 | "#!/usr/bin/perl". Scripts supplied by Apple and other third parties as | |
170 | part of installation packages and such have generally only been tested | |
171 | with the /usr/bin/perl that's installed by Apple. | |
ffb8d87a | 172 | |
e30a8c0c SP |
173 | If you find that you do need to update the system Perl, one issue worth |
174 | keeping in mind is the question of static vs. dynamic libraries. If you | |
175 | upgrade using the default static libperl, you will find that the dynamic | |
176 | libperl supplied by Apple will not be deleted. If both libraries are | |
177 | present when an application that links against libperl is built, ld will | |
178 | link against the dynamic library by default. So, if you need to replace | |
179 | Apple's dynamic libperl with a static libperl, you need to be sure to | |
180 | delete the older dynamic library after you've installed the update. | |
ffb8d87a | 181 | |
9ff7b177 | 182 | |
f7451e23 JH |
183 | =head2 Known problems |
184 | ||
185 | If you have installed extra libraries such as GDBM through Fink | |
186 | (in other words, you have libraries under F</sw/lib>), or libdlcompat | |
187 | to F</usr/local/lib>, you may need to be extra careful when running | |
188 | Configure to not to confuse Configure and Perl about which libraries | |
189 | to use. Being confused will show up for example as "dyld" errors about | |
190 | symbol problems, for example during "make test". The safest bet is to run | |
191 | Configure as | |
192 | ||
193 | Configure ... -Uloclibpth -Dlibpth=/usr/lib | |
194 | ||
195 | to make Configure look only into the system libraries. If you have some | |
196 | extra library directories that you really want to use (such as newer | |
197 | Berkeley DB libraries in pre-Panther systems), add those to the libpth: | |
198 | ||
199 | Configure ... -Uloclibpth -Dlibpth='/usr/lib /opt/lib' | |
200 | ||
201 | The default of building Perl statically may cause problems with complex | |
202 | applications like Tk: in that case consider building shared Perl | |
203 | ||
204 | Configure ... -Duseshrplib | |
205 | ||
206 | but remember that there's a startup cost to pay in that case (see above | |
207 | "libperl and Prebinding"). | |
208 | ||
80626d0c | 209 | Starting with Tiger (Mac OS X 10.4), Apple shipped broken locale files for |
ffb8d87a | 210 | the eu_ES locale (Basque-Spain). In previous releases of Perl, this resulted in |
2fdfa3ee | 211 | failures in the F<lib/locale> test. These failures have been suppressed |
ffb8d87a DD |
212 | in the current release of Perl by making the test ignore the broken locale. |
213 | If you need to use the eu_ES locale, you should contact Apple support. | |
f7451e23 | 214 | |
9ff7b177 | 215 | |
f7451e23 | 216 | =head2 Cocoa |
9ff7b177 JH |
217 | |
218 | There are two ways to use Cocoa from Perl. Apple's PerlObjCBridge | |
219 | module, included with Mac OS X, can be used by standalone scripts to | |
220 | access Foundation (i.e. non-GUI) classes and objects. | |
221 | ||
222 | An alternative is CamelBones, a framework that allows access to both | |
223 | Foundation and AppKit classes and objects, so that full GUI applications | |
224 | can be built in Perl. CamelBones can be found on SourceForge, at | |
225 | L<http://www.sourceforge.net/projects/camelbones/>. | |
226 | ||
227 | ||
6c8f3f7c JH |
228 | =head1 Starting From Scratch |
229 | ||
230 | Unfortunately it is not that difficult somehow manage to break one's | |
231 | Mac OS X Perl rather severely. If all else fails and you want to | |
232 | really, B<REALLY>, start from scratch and remove even your Apple Perl | |
233 | installation (which has become corrupted somehow), the following | |
234 | instructions should do it. B<Please think twice before following | |
235 | these instructions: they are much like conducting brain surgery to | |
236 | yourself. Without anesthesia.> We will B<not> come to fix your system | |
237 | if you do this. | |
238 | ||
239 | First, get rid of the libperl.dylib: | |
240 | ||
241 | # cd /System/Library/Perl/darwin/CORE | |
242 | # rm libperl.dylib | |
243 | ||
244 | Then delete every .bundle file found anywhere in the folders: | |
245 | ||
246 | /System/Library/Perl | |
247 | /Library/Perl | |
248 | ||
249 | You can find them for example by | |
250 | ||
251 | # find /System/Library/Perl /Library/Perl -name '*.bundle' -print | |
252 | ||
e30a8c0c | 253 | After this you can either copy Perl from your operating system media |
6c8f3f7c JH |
254 | (you will need at least the /System/Library/Perl and /usr/bin/perl), |
255 | or rebuild Perl from the source code with C<Configure -Dprefix=/usr | |
a4702d83 | 256 | -Duseshrplib> NOTE: the C<-Dprefix=/usr> to replace the system Perl |
6c8f3f7c JH |
257 | works much better with Perl 5.8.1 and later, in Perl 5.8.0 the |
258 | settings were not quite right. | |
259 | ||
e30a8c0c SP |
260 | "Pacifist" from CharlesSoft (L<http://www.charlessoft.com/>) is a nice |
261 | way to extract the Perl binaries from the OS media, without having to | |
262 | reinstall the entire OS. | |
263 | ||
6c8f3f7c | 264 | |
9ff7b177 JH |
265 | =head1 AUTHOR |
266 | ||
ffb8d87a | 267 | This README was written by Sherm Pendley E<lt>sherm@dot-app.orgE<gt>, |
f97f22a3 BO |
268 | and subsequently updated by Dominic Dunlop E<lt>domo@computer.orgE<gt> |
269 | and Breno G. de Oliveira E<lt>garu@cpan.orgE<gt>. The "Starting From Scratch" | |
270 | recipe was contributed by John Montbriand E<lt>montbriand@apple.comE<gt>. | |
9ff7b177 JH |
271 | |
272 | =head1 DATE | |
273 | ||
f97f22a3 | 274 | Last modified 2013-04-29. |