1PERLMACOSX(1) Perl Programmers Reference Guide PERLMACOSX(1)
2
3
4
6 README.macosx - Perl under Mac OS X
7
9 This document briefly describes perl under Mac OS X.
10
12 The latest Perl release (5.8.8 as of this writing) builds without
13 changes under Mac OS X. Under 10.3 "Panther" and newer OS versions, all
14 self-tests pass, and all standard features are supported.
15
16 Earlier Mac OS X releases (10.2 "Jaguar" and older) did not include a
17 completely thread-safe libc, so threading is not fully supported. Also,
18 earlier releases included a buggy libdb, so some of the DB_File tests
19 are known to fail on those releases.
20
21 Installation Prefix
22
23 The default installation location for this release uses the traditional
24 UNIX directory layout under /usr/local. This is the recommended loca‐
25 tion for most users, and will leave the Apple-supplied Perl and its
26 modules undisturbed.
27
28 Using an installation prefix of '/usr' will result in a directory lay‐
29 out that mirrors that of Apple's default Perl, with core modules stored
30 in '/System/Library/Perl/${version}', CPAN modules stored in
31 '/Library/Perl/${version}', and the addition of '/Net‐
32 work/Library/Perl/${version}' to @INC for modules that are stored on a
33 file server and used by many Macs.
34
35 SDK support
36
37 First, export the path to the SDK into the build environment:
38
39 export SDK=/Developer/SDKs/MacOSX10.3.9.sdk
40
41 Use an SDK by exporting some additions to Perl's 'ccflags' and
42 '..flags' config variables:
43
44 ./Configure -Accflags="-nostdinc -B$SDK/usr/include/gcc \
45 -B$SDK/usr/lib/gcc -isystem$SDK/usr/include \
46 -F$SDK/System/Library/Frameworks" \
47 -Aldflags="-Wl,-syslibroot,$SDK" \
48 -de
49
50 Universal Binary support
51
52 To compile perl as a universal binary (built for both ppc and intel),
53 export the SDK variable as above, selecting the 10.4u SDK:
54
55 export SDK=/Developer/SDKs/MacOSX10.4u.sdk
56
57 In addition to the compiler flags used to select the SDK, also add the
58 flags for creating a universal binary:
59
60 ./Configure -Accflags="-arch i686 -arch ppc -nostdinc -B$SDK/usr/include/gcc \
61 -B$SDK/usr/lib/gcc -isystem$SDK/usr/include \
62 -F$SDK/System/Library/Frameworks" \
63 -Aldflags="-arch i686 -arch ppc -Wl,-syslibroot,$SDK" \
64 -de
65
66 Keep in mind that these compiler and linker settings will also be used
67 when building CPAN modules. For XS modules to be compiled as a univer‐
68 sal binary, any libraries it links to must also be universal binaries.
69 The system libraries that Apple includes with the 10.4u SDK are all
70 universal, but user-installed libraries may need to be re-installed as
71 universal binaries.
72
73 libperl and Prebinding
74
75 Mac OS X ships with a dynamically-loaded libperl, but the default for
76 this release is to compile a static libperl. The reason for this is
77 pre-binding. Dynamic libraries can be pre-bound to a specific address
78 in memory in order to decrease load time. To do this, one needs to be
79 aware of the location and size of all previously-loaded libraries.
80 Apple collects this information as part of their overall OS build
81 process, and thus has easy access to it when building Perl, but ordi‐
82 nary users would need to go to a great deal of effort to obtain the
83 information needed for pre-binding.
84
85 You can override the default and build a shared libperl if you wish
86 (Configure ... -Duseshrlib), but the load time on pre-10.4 OS releases
87 will be greater than either the static library, or Apple's pre-bound
88 dynamic library.
89
90 With 10.4 "Tiger" and newer, Apple has all but eliminated the perfor‐
91 mance penalty for non-prebound libraries.
92
93 Updating Apple's Perl
94
95 In a word - don't, at least without a *very* good reason. Your scripts
96 can just as easily begin with "#!/usr/local/bin/perl" as with
97 "#!/usr/bin/perl". Scripts supplied by Apple and other third parties as
98 part of installation packages and such have generally only been tested
99 with the /usr/bin/perl that's installed by Apple.
100
101 If you find that you do need to update the system Perl, one issue worth
102 keeping in mind is the question of static vs. dynamic libraries. If you
103 upgrade using the default static libperl, you will find that the
104 dynamic libperl supplied by Apple will not be deleted. If both
105 libraries are present when an application that links against libperl is
106 built, ld will link against the dynamic library by default. So, if you
107 need to replace Apple's dynamic libperl with a static libperl, you need
108 to be sure to delete the older dynamic library after you've installed
109 the update.
110
111 Known problems
112
113 If you have installed extra libraries such as GDBM through Fink (in
114 other words, you have libraries under /sw/lib), or libdlcompat to
115 /usr/local/lib, you may need to be extra careful when running Configure
116 to not to confuse Configure and Perl about which libraries to use.
117 Being confused will show up for example as "dyld" errors about symbol
118 problems, for example during "make test". The safest bet is to run Con‐
119 figure as
120
121 Configure ... -Uloclibpth -Dlibpth=/usr/lib
122
123 to make Configure look only into the system libraries. If you have
124 some extra library directories that you really want to use (such as
125 newer Berkeley DB libraries in pre-Panther systems), add those to the
126 libpth:
127
128 Configure ... -Uloclibpth -Dlibpth='/usr/lib /opt/lib'
129
130 The default of building Perl statically may cause problems with complex
131 applications like Tk: in that case consider building shared Perl
132
133 Configure ... -Duseshrplib
134
135 but remember that there's a startup cost to pay in that case (see above
136 "libperl and Prebinding").
137
138 Starting with Tiger (Mac OS X 10.4), Apple shipped broken locale files
139 for the eu_ES locale (Basque-Spain). In previous releases of Perl,
140 this resulted in failures in the "lib/locale" test. These failures have
141 been supressed in the current release of Perl by making the test ignore
142 the broken locale. If you need to use the eu_ES locale, you should
143 contact Apple support.
144
145 MacPerl
146
147 Quite a bit has been written about MacPerl, the Perl distribution for
148 "Classic MacOS" - that is, versions 9 and earlier of MacOS. Because it
149 runs in environment that's very different from that of UNIX, many
150 things are done differently in MacPerl. Modules are installed using a
151 different procedure, Perl itself is built differently, path names are
152 different, etc.
153
154 From the perspective of a Perl programmer, Mac OS X is more like a tra‐
155 ditional UNIX than Classic MacOS. If you find documentation that refers
156 to a special procedure that's needed for MacOS that's drastically dif‐
157 ferent from the instructions provided for UNIX, the MacOS instructions
158 are quite often intended for MacPerl on Classic MacOS. In that case,
159 the correct procedure on Mac OS X is usually to follow the UNIX
160 instructions, rather than the MacPerl instructions.
161
162 Carbon
163
164 MacPerl ships with a number of modules that are used to access the
165 classic MacOS toolbox. Many of these modules have been updated to use
166 Mac OS X's newer "Carbon" toolbox, and are available from CPAN in the
167 "Mac::Carbon" module.
168
169 Cocoa
170
171 There are two ways to use Cocoa from Perl. Apple's PerlObjCBridge mod‐
172 ule, included with Mac OS X, can be used by standalone scripts to
173 access Foundation (i.e. non-GUI) classes and objects.
174
175 An alternative is CamelBones, a framework that allows access to both
176 Foundation and AppKit classes and objects, so that full GUI applica‐
177 tions can be built in Perl. CamelBones can be found on SourceForge, at
178 <http://www.sourceforge.net/projects/camelbones/>.
179
181 Unfortunately it is not that difficult somehow manage to break one's
182 Mac OS X Perl rather severely. If all else fails and you want to
183 really, REALLY, start from scratch and remove even your Apple Perl
184 installation (which has become corrupted somehow), the following
185 instructions should do it. Please think twice before following these
186 instructions: they are much like conducting brain surgery to yourself.
187 Without anesthesia. We will not come to fix your system if you do
188 this.
189
190 First, get rid of the libperl.dylib:
191
192 # cd /System/Library/Perl/darwin/CORE
193 # rm libperl.dylib
194
195 Then delete every .bundle file found anywhere in the folders:
196
197 /System/Library/Perl
198 /Library/Perl
199
200 You can find them for example by
201
202 # find /System/Library/Perl /Library/Perl -name '*.bundle' -print
203
204 After this you can either copy Perl from your operating system media
205 (you will need at least the /System/Library/Perl and /usr/bin/perl), or
206 rebuild Perl from the source code with "Configure -Dprefix=/usr -Duser‐
207 shrplib" NOTE: the "-Dprefix=/usr" to replace the system Perl works
208 much better with Perl 5.8.1 and later, in Perl 5.8.0 the settings were
209 not quite right.
210
211 "Pacifist" from CharlesSoft (<http://www.charlessoft.com/>) is a nice
212 way to extract the Perl binaries from the OS media, without having to
213 reinstall the entire OS.
214
216 This README was written by Sherm Pendley <sherm@dot-app.org>, and sub‐
217 sequently updated by Dominic Dunlop <domo@computer.org>. The "Starting
218 From Scratch" recipe was contributed by John Montbriand <mont‐
219 briand@apple.com>.
220
222 Last modified 2005-11-07.
223
224
225
226perl v5.8.8 2006-01-07 PERLMACOSX(1)