Commit | Line | Data |
---|---|---|
a56dbb1c | 1 | If you read this file _as_is_, just ignore the funny characters you |
2 | see. It is written in the POD format (see perlpod manpage) which is | |
3 | specially designed to be readable as is. | |
4 | ||
5 | =head1 NAME | |
6 | ||
72ea3524 | 7 | perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT. |
a56dbb1c | 8 | |
9 | =head1 SYNOPSIS | |
10 | ||
11 | One can read this document in the following formats: | |
12 | ||
13 | man perlos2 | |
14 | view perl perlos2 | |
15 | explorer perlos2.html | |
16 | info perlos2 | |
17 | ||
18 | to list some (not all may be available simultaneously), or it may | |
19 | be read I<as is>: either as F<README.os2>, or F<pod/perlos2.pod>. | |
20 | ||
72ea3524 IZ |
21 | To read the F<.INF> version of documentation (B<very> recommended) |
22 | outside of OS/2, one needs an IBM's reader (may be available on IBM | |
df3ef7a9 IZ |
23 | ftp sites (?) (URL anyone?)) or shipped with PC DOS 7.0 and IBM's |
24 | Visual Age C++ 3.5. | |
25 | ||
26 | A copy of a Win* viewer is contained in the "Just add OS/2 Warp" package | |
27 | ||
28 | ftp://ftp.software.ibm.com/ps/products/os2/tools/jaow/jaow.zip | |
29 | ||
aa689395 | 30 | in F<?:\JUST_ADD\view.exe>. This gives one an access to EMX's |
df3ef7a9 | 31 | F<.INF> docs as well (text form is available in F</emx/doc> in |
aa689395 | 32 | EMX's distribution). |
72ea3524 | 33 | |
d7678ab8 CS |
34 | Note that if you have F<lynx.exe> installed, you can follow WWW links |
35 | from this document in F<.INF> format. If you have EMX docs installed | |
36 | correctly, you can follow library links (you need to have C<view emxbook> | |
37 | working by setting C<EMXBOOK> environment variable as it is described | |
38 | in EMX docs). | |
39 | ||
a56dbb1c | 40 | =cut |
41 | ||
42 | Contents | |
43 | ||
df3ef7a9 | 44 | perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT. |
a56dbb1c | 45 | |
df3ef7a9 IZ |
46 | NAME |
47 | SYNOPSIS | |
48 | DESCRIPTION | |
a56dbb1c | 49 | - Target |
50 | - Other OSes | |
51 | - Prerequisites | |
aa689395 | 52 | - Starting Perl programs under OS/2 (and DOS and...) |
53 | - Starting OS/2 (and DOS) programs under Perl | |
df3ef7a9 | 54 | Frequently asked questions |
72ea3524 | 55 | - I cannot run external programs |
df3ef7a9 IZ |
56 | - I cannot embed perl into my program, or use perl.dll from my program. |
57 | - `` and pipe-open do not work under DOS. | |
aa689395 | 58 | - Cannot start find.exe "pattern" file |
df3ef7a9 | 59 | INSTALLATION |
a56dbb1c | 60 | - Automatic binary installation |
61 | - Manual binary installation | |
62 | - Warning | |
df3ef7a9 | 63 | Accessing documentation |
a56dbb1c | 64 | - OS/2 .INF file |
65 | - Plain text | |
66 | - Manpages | |
67 | - HTML | |
68 | - GNU info files | |
69 | - .PDF files | |
70 | - LaTeX docs | |
df3ef7a9 | 71 | BUILD |
a56dbb1c | 72 | - Prerequisites |
73 | - Getting perl source | |
74 | - Application of the patches | |
75 | - Hand-editing | |
76 | - Making | |
77 | - Testing | |
78 | - Installing the built perl | |
79 | - a.out-style build | |
df3ef7a9 | 80 | Build FAQ |
a56dbb1c | 81 | - Some / became \ in pdksh. |
82 | - 'errno' - unresolved external | |
83 | - Problems with tr | |
84 | - Some problem (forget which ;-) | |
85 | - Library ... not found | |
df3ef7a9 | 86 | - Segfault in make |
aa689395 | 87 | Specific (mis)features of EMX port |
a56dbb1c | 88 | - setpriority, getpriority |
89 | - system() | |
aa689395 | 90 | - extproc on the first line |
a56dbb1c | 91 | - Additional modules: |
92 | - Prebuilt methods: | |
93 | - Misfeatures | |
df3ef7a9 IZ |
94 | - Modifications |
95 | Perl flavors | |
a56dbb1c | 96 | - perl.exe |
97 | - perl_.exe | |
98 | - perl__.exe | |
99 | - perl___.exe | |
100 | - Why strange names? | |
101 | - Why dynamic linking? | |
102 | - Why chimera build? | |
df3ef7a9 | 103 | ENVIRONMENT |
a56dbb1c | 104 | - PERLLIB_PREFIX |
105 | - PERL_BADLANG | |
106 | - PERL_BADFREE | |
107 | - PERL_SH_DIR | |
108 | - TMP or TEMP | |
df3ef7a9 | 109 | Evolution |
a56dbb1c | 110 | - Priorities |
72ea3524 | 111 | - DLL name mangling |
a56dbb1c | 112 | - Threading |
113 | - Calls to external programs | |
df3ef7a9 IZ |
114 | - Memory allocation |
115 | AUTHOR | |
116 | SEE ALSO | |
117 | ||
a56dbb1c | 118 | =head1 DESCRIPTION |
119 | ||
120 | =head2 Target | |
121 | ||
122 | The target is to make OS/2 the best supported platform for | |
72ea3524 | 123 | using/building/developing Perl and I<Perl applications>, as well as |
aa689395 | 124 | make Perl the best language to use under OS/2. The secondary target is |
125 | to try to make this work under DOS and Win* as well (but not B<too> hard). | |
a56dbb1c | 126 | |
127 | The current state is quite close to this target. Known limitations: | |
128 | ||
129 | =over 5 | |
130 | ||
131 | =item * | |
132 | ||
133 | Some *nix programs use fork() a lot, but currently fork() is not | |
134 | supported after I<use>ing dynamically loaded extensions. | |
135 | ||
136 | =item * | |
137 | ||
138 | You need a separate perl executable F<perl__.exe> (see L<perl__.exe>) | |
139 | to use PM code in your application (like the forthcoming Perl/Tk). | |
140 | ||
141 | =item * | |
142 | ||
aa689395 | 143 | There is no simple way to access WPS objects. The only way I know |
a56dbb1c | 144 | is via C<OS2::REXX> extension (see L<OS2::REXX>), and we do not have access to |
aa689395 | 145 | convenience methods of Object-REXX. (Is it possible at all? I know |
146 | of no Object-REXX API.) | |
a56dbb1c | 147 | |
148 | =back | |
149 | ||
150 | Please keep this list up-to-date by informing me about other items. | |
151 | ||
152 | =head2 Other OSes | |
153 | ||
aa689395 | 154 | Since OS/2 port of perl uses a remarkable EMX environment, it can |
a56dbb1c | 155 | run (and build extensions, and - possibly - be build itself) under any |
156 | environment which can run EMX. The current list is DOS, | |
72ea3524 | 157 | DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT. Out of many perl flavors, |
a56dbb1c | 158 | only one works, see L<"perl_.exe">. |
159 | ||
160 | Note that not all features of Perl are available under these | |
161 | environments. This depends on the features the I<extender> - most | |
aa689395 | 162 | probably RSX - decided to implement. |
a56dbb1c | 163 | |
164 | Cf. L<Prerequisites>. | |
165 | ||
166 | =head2 Prerequisites | |
167 | ||
168 | =over 6 | |
169 | ||
aa689395 | 170 | =item EMX |
a56dbb1c | 171 | |
aa689395 | 172 | EMX runtime is required (may be substituted by RSX). Note that |
55497cff | 173 | it is possible to make F<perl_.exe> to run under DOS without any |
72ea3524 | 174 | external support by binding F<emx.exe>/F<rsx.exe> to it, see L<emxbind>. Note |
aa689395 | 175 | that under DOS for best results one should use RSX runtime, which |
55497cff | 176 | has much more functions working (like C<fork>, C<popen> and so on). In |
aa689395 | 177 | fact RSX is required if there is no VCPI present. Note the |
178 | RSX requires DPMI. | |
a56dbb1c | 179 | |
aa689395 | 180 | Only the latest runtime is supported, currently C<0.9c>. Perl may run |
181 | under earlier versions of EMX, but this is not tested. | |
a56dbb1c | 182 | |
aa689395 | 183 | One can get different parts of EMX from, say |
a56dbb1c | 184 | |
d7678ab8 CS |
185 | ftp://ftp.cdrom.com/pub/os2/emx09c/ |
186 | ftp://hobbes.nmsu.edu/os2/unix/emx09c/ | |
a56dbb1c | 187 | |
188 | The runtime component should have the name F<emxrt.zip>. | |
189 | ||
72ea3524 IZ |
190 | B<NOTE>. It is enough to have F<emx.exe>/F<rsx.exe> on your path. One |
191 | does not need to specify them explicitly (though this | |
192 | ||
193 | emx perl_.exe -de 0 | |
194 | ||
195 | will work as well.) | |
196 | ||
aa689395 | 197 | =item RSX |
a56dbb1c | 198 | |
aa689395 | 199 | To run Perl on DPMI platforms one needs RSX runtime. This is |
72ea3524 | 200 | needed under DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT (see |
aa689395 | 201 | L<"Other OSes">). RSX would not work with VCPI |
202 | only, as EMX would, it requires DMPI. | |
55497cff | 203 | |
aa689395 | 204 | Having RSX and the latest F<sh.exe> one gets a fully functional |
55497cff | 205 | B<*nix>-ish environment under DOS, say, C<fork>, C<``> and |
206 | pipe-C<open> work. In fact, MakeMaker works (for static build), so one | |
207 | can have Perl development environment under DOS. | |
a56dbb1c | 208 | |
aa689395 | 209 | One can get RSX from, say |
a56dbb1c | 210 | |
d7678ab8 | 211 | ftp://ftp.cdrom.com/pub/os2/emx09c/contrib |
a56dbb1c | 212 | ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc |
d7678ab8 | 213 | ftp://ftp.leo.org/pub/comp/os/os2/leo/devtools/emx+gcc/contrib |
a56dbb1c | 214 | |
215 | Contact the author on C<rainer@mathematik.uni-bielefeld.de>. | |
216 | ||
55497cff | 217 | The latest F<sh.exe> with DOS hooks is available at |
218 | ||
d7678ab8 | 219 | ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.zip |
55497cff | 220 | |
aa689395 | 221 | =item HPFS |
a56dbb1c | 222 | |
223 | Perl does not care about file systems, but to install the whole perl | |
224 | library intact one needs a file system which supports long file names. | |
225 | ||
226 | Note that if you do not plan to build the perl itself, it may be | |
aa689395 | 227 | possible to fool EMX to truncate file names. This is not supported, |
228 | read EMX docs to see how to do it. | |
229 | ||
230 | =item pdksh | |
231 | ||
232 | To start external programs with complicated command lines (like with | |
233 | pipes in between, and/or quoting of arguments), Perl uses an external | |
234 | shell. With EMX port such shell should be named <sh.exe>, and located | |
235 | either in the wired-in-during-compile locations (usually F<F:/bin>), | |
236 | or in configurable location (see L<"PERL_SH_DIR">). | |
237 | ||
238 | For best results use EMX pdksh. The soon-to-be-available standard | |
239 | binary (5.2.12?) runs under DOS (with L<RSX>) as well, meanwhile use | |
240 | the binary from | |
241 | ||
d7678ab8 | 242 | ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.zip |
a56dbb1c | 243 | |
244 | =back | |
245 | ||
aa689395 | 246 | =head2 Starting Perl programs under OS/2 (and DOS and...) |
a56dbb1c | 247 | |
248 | Start your Perl program F<foo.pl> with arguments C<arg1 arg2 arg3> the | |
249 | same way as on any other platform, by | |
250 | ||
251 | perl foo.pl arg1 arg2 arg3 | |
252 | ||
253 | If you want to specify perl options C<-my_opts> to the perl itself (as | |
254 | opposed to to your program), use | |
255 | ||
256 | perl -my_opts foo.pl arg1 arg2 arg3 | |
257 | ||
aa689395 | 258 | Alternately, if you use OS/2-ish shell, like CMD or 4os2, put |
a56dbb1c | 259 | the following at the start of your perl script: |
260 | ||
aa689395 | 261 | extproc perl -S -my_opts |
a56dbb1c | 262 | |
263 | rename your program to F<foo.cmd>, and start it by typing | |
264 | ||
265 | foo arg1 arg2 arg3 | |
266 | ||
a56dbb1c | 267 | Note that because of stupid OS/2 limitations the full path of the perl |
268 | script is not available when you use C<extproc>, thus you are forced to | |
269 | use C<-S> perl switch, and your script should be on path. As a plus | |
270 | side, if you know a full path to your script, you may still start it | |
271 | with | |
272 | ||
aa689395 | 273 | perl ../../blah/foo.cmd arg1 arg2 arg3 |
a56dbb1c | 274 | |
aa689395 | 275 | (note that the argument C<-my_opts> is taken care of by the C<extproc> line |
276 | in your script, see L<C<extproc> on the first line>). | |
a56dbb1c | 277 | |
278 | To understand what the above I<magic> does, read perl docs about C<-S> | |
aa689395 | 279 | switch - see L<perlrun>, and cmdref about C<extproc>: |
a56dbb1c | 280 | |
281 | view perl perlrun | |
282 | man perlrun | |
283 | view cmdref extproc | |
284 | help extproc | |
285 | ||
286 | or whatever method you prefer. | |
287 | ||
72ea3524 | 288 | There are also endless possibilities to use I<executable extensions> of |
aa689395 | 289 | 4os2, I<associations> of WPS and so on... However, if you use |
a56dbb1c | 290 | *nixish shell (like F<sh.exe> supplied in the binary distribution), |
72ea3524 | 291 | you need to follow the syntax specified in L<perlrun/"Switches">. |
a56dbb1c | 292 | |
aa689395 | 293 | =head2 Starting OS/2 (and DOS) programs under Perl |
a56dbb1c | 294 | |
295 | This is what system() (see L<perlfunc/system>), C<``> (see | |
296 | L<perlop/"I/O Operators">), and I<open pipe> (see L<perlfunc/open>) | |
297 | are for. (Avoid exec() (see L<perlfunc/exec>) unless you know what you | |
298 | do). | |
299 | ||
300 | Note however that to use some of these operators you need to have a | |
aa689395 | 301 | sh-syntax shell installed (see L<"Pdksh">, |
a56dbb1c | 302 | L<"Frequently asked questions">), and perl should be able to find it |
303 | (see L<"PERL_SH_DIR">). | |
304 | ||
305 | The only cases when the shell is not used is the multi-argument | |
306 | system() (see L<perlfunc/system>)/exec() (see L<perlfunc/exec>), and | |
307 | one-argument version thereof without redirection and shell | |
308 | meta-characters. | |
309 | ||
310 | =head1 Frequently asked questions | |
311 | ||
72ea3524 | 312 | =head2 I cannot run external programs |
a56dbb1c | 313 | |
55497cff | 314 | =over 4 |
315 | ||
316 | =item | |
317 | ||
a56dbb1c | 318 | Did you run your programs with C<-w> switch? See |
aa689395 | 319 | L<Starting OS/2 (and DOS) programs under Perl>. |
a56dbb1c | 320 | |
55497cff | 321 | =item |
322 | ||
323 | Do you try to run I<internal> shell commands, like C<`copy a b`> | |
324 | (internal for F<cmd.exe>), or C<`glob a*b`> (internal for ksh)? You | |
72ea3524 | 325 | need to specify your shell explicitly, like C<`cmd /c copy a b`>, |
55497cff | 326 | since Perl cannot deduce which commands are internal to your shell. |
327 | ||
328 | =back | |
329 | ||
a56dbb1c | 330 | =head2 I cannot embed perl into my program, or use F<perl.dll> from my |
331 | program. | |
332 | ||
333 | =over 4 | |
334 | ||
aa689395 | 335 | =item Is your program EMX-compiled with C<-Zmt -Zcrtdll>? |
a56dbb1c | 336 | |
337 | If not, you need to build a stand-alone DLL for perl. Contact me, I | |
338 | did it once. Sockets would not work, as a lot of other stuff. | |
339 | ||
aa689395 | 340 | =item Did you use L<ExtUtils::Embed>? |
a56dbb1c | 341 | |
342 | I had reports it does not work. Somebody would need to fix it. | |
343 | ||
344 | =back | |
345 | ||
55497cff | 346 | =head2 C<``> and pipe-C<open> do not work under DOS. |
347 | ||
72ea3524 | 348 | This may a variant of just L<"I cannot run external programs">, or a |
aa689395 | 349 | deeper problem. Basically: you I<need> RSX (see L<"Prerequisites">) |
72ea3524 | 350 | for these commands to work, and you may need a port of F<sh.exe> which |
55497cff | 351 | understands command arguments. One of such ports is listed in |
aa689395 | 352 | L<"Prerequisites"> under RSX. Do not forget to set variable |
353 | C<L<"PERL_SH_DIR">> as well. | |
354 | ||
355 | DPMI is required for RSX. | |
356 | ||
357 | =head2 Cannot start C<find.exe "pattern" file> | |
55497cff | 358 | |
aa689395 | 359 | Use one of |
360 | ||
361 | system 'cmd', '/c', 'find "pattern" file'; | |
362 | `cmd /c 'find "pattern" file'` | |
363 | ||
364 | This would start F<find.exe> via F<cmd.exe> via C<sh.exe> via | |
365 | C<perl.exe>, but this is a price to pay if you want to use | |
366 | non-conforming program. In fact F<find.exe> cannot be started at all | |
367 | using C library API only. Otherwise the following command-lines were | |
368 | equivalent: | |
369 | ||
370 | find "pattern" file | |
371 | find pattern file | |
55497cff | 372 | |
a56dbb1c | 373 | =head1 INSTALLATION |
374 | ||
375 | =head2 Automatic binary installation | |
376 | ||
72ea3524 | 377 | The most convenient way of installing perl is via perl installer |
a56dbb1c | 378 | F<install.exe>. Just follow the instructions, and 99% of the |
379 | installation blues would go away. | |
380 | ||
381 | Note however, that you need to have F<unzip.exe> on your path, and | |
aa689395 | 382 | EMX environment I<running>. The latter means that if you just |
383 | installed EMX, and made all the needed changes to F<Config.sys>, | |
384 | you may need to reboot in between. Check EMX runtime by running | |
a56dbb1c | 385 | |
386 | emxrev | |
387 | ||
388 | A folder is created on your desktop which contains some useful | |
389 | objects. | |
390 | ||
391 | B<Things not taken care of by automatic binary installation:> | |
392 | ||
393 | =over 15 | |
394 | ||
395 | =item C<PERL_BADLANG> | |
396 | ||
397 | may be needed if you change your codepage I<after> perl installation, | |
aa689395 | 398 | and the new value is not supported by EMX. See L<"PERL_BADLANG">. |
a56dbb1c | 399 | |
400 | =item C<PERL_BADFREE> | |
401 | ||
402 | see L<"PERL_BADFREE">. | |
403 | ||
404 | =item F<Config.pm> | |
405 | ||
406 | This file resides somewhere deep in the location you installed your | |
407 | perl library, find it out by | |
408 | ||
409 | perl -MConfig -le "print $INC{'Config.pm'}" | |
410 | ||
411 | While most important values in this file I<are> updated by the binary | |
412 | installer, some of them may need to be hand-edited. I know no such | |
413 | data, please keep me informed if you find one. | |
414 | ||
415 | =back | |
416 | ||
aa689395 | 417 | B<NOTE>. Because of a typo the binary installer of 5.00305 |
418 | would install a variable C<PERL_SHPATH> into F<Config.sys>. Please | |
419 | remove this variable and put C<L<PERL_SH_DIR>> instead. | |
420 | ||
a56dbb1c | 421 | =head2 Manual binary installation |
422 | ||
72ea3524 | 423 | As of version 5.00305, OS/2 perl binary distribution comes split |
a56dbb1c | 424 | into 11 components. Unfortunately, to enable configurable binary |
aa689395 | 425 | installation, the file paths in the zip files are not absolute, but |
a56dbb1c | 426 | relative to some directory. |
427 | ||
428 | Note that the extraction with the stored paths is still necessary | |
aa689395 | 429 | (default with unzip, specify C<-d> to pkunzip). However, you |
a56dbb1c | 430 | need to know where to extract the files. You need also to manually |
431 | change entries in F<Config.sys> to reflect where did you put the | |
72ea3524 | 432 | files. Note that if you have some primitive unzipper (like |
aa689395 | 433 | pkunzip), you may get a lot of warnings/errors during |
72ea3524 | 434 | unzipping. Upgrade to C<(w)unzip>. |
a56dbb1c | 435 | |
436 | Below is the sample of what to do to reproduce the configuration on my | |
437 | machine: | |
438 | ||
439 | =over 3 | |
440 | ||
441 | =item Perl VIO and PM executables (dynamically linked) | |
442 | ||
443 | unzip perl_exc.zip *.exe *.ico -d f:/emx.add/bin | |
444 | unzip perl_exc.zip *.dll -d f:/emx.add/dll | |
445 | ||
aa689395 | 446 | (have the directories with C<*.exe> on PATH, and C<*.dll> on |
447 | LIBPATH); | |
a56dbb1c | 448 | |
449 | =item Perl_ VIO executable (statically linked) | |
450 | ||
451 | unzip perl_aou.zip -d f:/emx.add/bin | |
452 | ||
aa689395 | 453 | (have the directory on PATH); |
a56dbb1c | 454 | |
455 | =item Executables for Perl utilities | |
456 | ||
457 | unzip perl_utl.zip -d f:/emx.add/bin | |
458 | ||
aa689395 | 459 | (have the directory on PATH); |
a56dbb1c | 460 | |
461 | =item Main Perl library | |
462 | ||
463 | unzip perl_mlb.zip -d f:/perllib/lib | |
464 | ||
465 | If this directory is preserved, you do not need to change | |
466 | anything. However, for perl to find it if it is changed, you need to | |
467 | C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">. | |
468 | ||
469 | =item Additional Perl modules | |
470 | ||
471 | unzip perl_ste.zip -d f:/perllib/lib/site_perl | |
472 | ||
473 | If you do not change this directory, do nothing. Otherwise put this | |
474 | directory and subdirectory F<./os2> in C<PERLLIB> or C<PERL5LIB> | |
475 | variable. Do not use C<PERL5LIB> unless you have it set already. See | |
476 | L<perl/"ENVIRONMENT">. | |
477 | ||
478 | =item Tools to compile Perl modules | |
479 | ||
480 | unzip perl_blb.zip -d f:/perllib/lib | |
481 | ||
482 | If this directory is preserved, you do not need to change | |
483 | anything. However, for perl to find it if it is changed, you need to | |
484 | C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">. | |
485 | ||
486 | =item Manpages for Perl and utilities | |
487 | ||
488 | unzip perl_man.zip -d f:/perllib/man | |
489 | ||
490 | This directory should better be on C<MANPATH>. You need to have a | |
aa689395 | 491 | working man to access these files. |
a56dbb1c | 492 | |
493 | =item Manpages for Perl modules | |
494 | ||
495 | unzip perl_mam.zip -d f:/perllib/man | |
496 | ||
497 | This directory should better be on C<MANPATH>. You need to have a | |
aa689395 | 498 | working man to access these files. |
a56dbb1c | 499 | |
500 | =item Source for Perl documentation | |
501 | ||
502 | unzip perl_pod.zip -d f:/perllib/lib | |
503 | ||
504 | This is used by by C<perldoc> program (see L<perldoc>), and may be used to | |
aa689395 | 505 | generate HTML documentation usable by WWW browsers, and |
a56dbb1c | 506 | documentation in zillions of other formats: C<info>, C<LaTeX>, |
507 | C<Acrobat>, C<FrameMaker> and so on. | |
508 | ||
aa689395 | 509 | =item Perl manual in F<.INF> format |
a56dbb1c | 510 | |
511 | unzip perl_inf.zip -d d:/os2/book | |
512 | ||
513 | This directory should better be on C<BOOKSHELF>. | |
514 | ||
515 | =item Pdksh | |
516 | ||
517 | unzip perl_sh.zip -d f:/bin | |
518 | ||
72ea3524 | 519 | This is used by perl to run external commands which explicitly |
a56dbb1c | 520 | require shell, like the commands using I<redirection> and I<shell |
521 | metacharacters>. It is also used instead of explicit F</bin/sh>. | |
522 | ||
523 | Set C<PERL_SH_DIR> (see L<"PERL_SH_DIR">) if you move F<sh.exe> from | |
524 | the above location. | |
525 | ||
aa689395 | 526 | B<Note.> It may be possible to use some other sh-compatible shell |
a56dbb1c | 527 | (I<not tested>). |
528 | ||
529 | =back | |
530 | ||
531 | After you installed the components you needed and updated the | |
532 | F<Config.sys> correspondingly, you need to hand-edit | |
533 | F<Config.pm>. This file resides somewhere deep in the location you | |
534 | installed your perl library, find it out by | |
535 | ||
536 | perl -MConfig -le "print $INC{'Config.pm'}" | |
537 | ||
538 | You need to correct all the entries which look like file paths (they | |
539 | currently start with C<f:/>). | |
540 | ||
541 | =head2 B<Warning> | |
542 | ||
543 | The automatic and manual perl installation leave precompiled paths | |
544 | inside perl executables. While these paths are overwriteable (see | |
545 | L<"PERLLIB_PREFIX">, L<"PERL_SH_DIR">), one may get better results by | |
546 | binary editing of paths inside the executables/DLLs. | |
547 | ||
548 | =head1 Accessing documentation | |
549 | ||
550 | Depending on how you built/installed perl you may have (otherwise | |
551 | identical) Perl documentation in the following formats: | |
552 | ||
553 | =head2 OS/2 F<.INF> file | |
554 | ||
aa689395 | 555 | Most probably the most convenient form. Under OS/2 view it as |
a56dbb1c | 556 | |
557 | view perl | |
558 | view perl perlfunc | |
559 | view perl less | |
560 | view perl ExtUtils::MakeMaker | |
561 | ||
562 | (currently the last two may hit a wrong location, but this may improve | |
aa689395 | 563 | soon). Under Win* see L<"SYNOPSIS">. |
a56dbb1c | 564 | |
565 | If you want to build the docs yourself, and have I<OS/2 toolkit>, run | |
566 | ||
567 | pod2ipf > perl.ipf | |
568 | ||
569 | in F</perllib/lib/pod> directory, then | |
570 | ||
571 | ipfc /inf perl.ipf | |
572 | ||
573 | (Expect a lot of errors during the both steps.) Now move it on your | |
574 | BOOKSHELF path. | |
575 | ||
576 | =head2 Plain text | |
577 | ||
578 | If you have perl documentation in the source form, perl utilities | |
aa689395 | 579 | installed, and GNU groff installed, you may use |
a56dbb1c | 580 | |
581 | perldoc perlfunc | |
582 | perldoc less | |
583 | perldoc ExtUtils::MakeMaker | |
584 | ||
72ea3524 | 585 | to access the perl documentation in the text form (note that you may get |
a56dbb1c | 586 | better results using perl manpages). |
587 | ||
588 | Alternately, try running pod2text on F<.pod> files. | |
589 | ||
590 | =head2 Manpages | |
591 | ||
aa689395 | 592 | If you have man installed on your system, and you installed perl |
a56dbb1c | 593 | manpages, use something like this: |
5243f9ae | 594 | |
5243f9ae | 595 | man perlfunc |
596 | man 3 less | |
597 | man ExtUtils.MakeMaker | |
5243f9ae | 598 | |
a56dbb1c | 599 | to access documentation for different components of Perl. Start with |
600 | ||
601 | man perl | |
602 | ||
603 | Note that dot (F<.>) is used as a package separator for documentation | |
604 | for packages, and as usual, sometimes you need to give the section - C<3> | |
605 | above - to avoid shadowing by the I<less(1) manpage>. | |
606 | ||
607 | Make sure that the directory B<above> the directory with manpages is | |
608 | on our C<MANPATH>, like this | |
609 | ||
610 | set MANPATH=c:/man;f:/perllib/man | |
611 | ||
aa689395 | 612 | =head2 HTML |
a56dbb1c | 613 | |
614 | If you have some WWW browser available, installed the Perl | |
615 | documentation in the source form, and Perl utilities, you can build | |
aa689395 | 616 | HTML docs. Cd to directory with F<.pod> files, and do like this |
a56dbb1c | 617 | |
618 | cd f:/perllib/lib/pod | |
5243f9ae | 619 | pod2html |
5243f9ae | 620 | |
a56dbb1c | 621 | After this you can direct your browser the file F<perl.html> in this |
622 | directory, and go ahead with reading docs, like this: | |
5243f9ae | 623 | |
a56dbb1c | 624 | explore file:///f:/perllib/lib/pod/perl.html |
5243f9ae | 625 | |
aa689395 | 626 | Alternatively you may be able to get these docs prebuilt from CPAN. |
5243f9ae | 627 | |
aa689395 | 628 | =head2 GNU C<info> files |
bb14ff96 | 629 | |
aa689395 | 630 | Users of Emacs would appreciate it very much, especially with |
a56dbb1c | 631 | C<CPerl> mode loaded. You need to get latest C<pod2info> from C<CPAN>, |
632 | or, alternately, prebuilt info pages. | |
615d1a09 | 633 | |
a56dbb1c | 634 | =head2 F<.PDF> files |
635 | ||
636 | for C<Acrobat> are available on CPAN (for slightly old version of | |
637 | perl). | |
638 | ||
639 | =head2 C<LaTeX> docs | |
640 | ||
641 | can be constructed using C<pod2latex>. | |
642 | ||
643 | =head1 BUILD | |
644 | ||
645 | Here we discuss how to build Perl under OS/2. There is an alternative | |
646 | (but maybe older) view on L<http://www.shadow.net/~troc/os2perl.html>. | |
647 | ||
648 | =head2 Prerequisites | |
649 | ||
aa689395 | 650 | You need to have the latest EMX development environment, the full |
651 | GNU tool suite (gawk renamed to awk, and GNU F<find.exe> | |
a56dbb1c | 652 | earlier on path than the OS/2 F<find.exe>, same with F<sort.exe>, to |
653 | check use | |
654 | ||
655 | find --version | |
656 | sort --version | |
657 | ||
658 | ). You need the latest version of F<pdksh> installed as F<sh.exe>. | |
659 | ||
660 | Possible locations to get this from are | |
661 | ||
d7678ab8 | 662 | ftp://hobbes.nmsu.edu/os2/unix/ |
a56dbb1c | 663 | ftp://ftp.cdrom.com/pub/os2/unix/ |
664 | ftp://ftp.cdrom.com/pub/os2/dev32/ | |
d7678ab8 | 665 | ftp://ftp.cdrom.com/pub/os2/emx09c/ |
a56dbb1c | 666 | |
eb447b86 IZ |
667 | It is reported that the following archives contain enough utils to |
668 | build perl: gnufutil.zip, gnusutil.zip, gnututil.zip, gnused.zip, | |
669 | gnupatch.zip, gnuawk.zip, gnumake.zip and ksh527rt.zip. Note that | |
670 | all these utilities are known to be available from LEO: | |
671 | ||
672 | ftp://ftp.leo.org/pub/comp/os/os2/leo/gnu | |
a56dbb1c | 673 | |
674 | Make sure that no copies or perl are currently running. Later steps | |
675 | of the build may fail since an older version of perl.dll loaded into | |
676 | memory may be found. | |
677 | ||
678 | Also make sure that you have F</tmp> directory on the current drive, | |
679 | and F<.> directory in your C<LIBPATH>. One may try to correct the | |
680 | latter condition by | |
681 | ||
682 | set BEGINLIBPATH . | |
683 | ||
684 | if you use something like F<CMD.EXE> or latest versions of F<4os2.exe>. | |
685 | ||
aa689395 | 686 | Make sure your gcc is good for C<-Zomf> linking: run C<omflibs> |
a56dbb1c | 687 | script in F</emx/lib> directory. |
688 | ||
aa689395 | 689 | Check that you have link386 installed. It comes standard with OS/2, |
a56dbb1c | 690 | but may be not installed due to customization. If typing |
691 | ||
692 | link386 | |
693 | ||
694 | shows you do not have it, do I<Selective install>, and choose C<Link | |
72ea3524 | 695 | object modules> in I<Optional system utilities/More>. If you get into |
aa689395 | 696 | link386, press C<Ctrl-C>. |
a56dbb1c | 697 | |
698 | =head2 Getting perl source | |
699 | ||
72ea3524 | 700 | You need to fetch the latest perl source (including developers |
a56dbb1c | 701 | releases). With some probability it is located in |
702 | ||
703 | http://www.perl.com/CPAN/src/5.0 | |
704 | http://www.perl.com/CPAN/src/5.0/unsupported | |
705 | ||
706 | If not, you may need to dig in the indices to find it in the directory | |
707 | of the current maintainer. | |
708 | ||
72ea3524 | 709 | Quick cycle of developers release may break the OS/2 build time to |
a56dbb1c | 710 | time, looking into |
711 | ||
712 | http://www.perl.com/CPAN/ports/os2/ilyaz/ | |
713 | ||
714 | may indicate the latest release which was publicly released by the | |
715 | maintainer. Note that the release may include some additional patches | |
716 | to apply to the current source of perl. | |
717 | ||
718 | Extract it like this | |
719 | ||
720 | tar vzxf perl5.00409.tar.gz | |
721 | ||
722 | You may see a message about errors while extracting F<Configure>. This is | |
723 | because there is a conflict with a similarly-named file F<configure>. | |
724 | ||
a56dbb1c | 725 | Change to the directory of extraction. |
726 | ||
727 | =head2 Application of the patches | |
728 | ||
729 | You need to apply the patches in F<./os2/diff.*> and | |
730 | F<./os2/POSIX.mkfifo> like this: | |
731 | ||
732 | gnupatch -p0 < os2\POSIX.mkfifo | |
df3ef7a9 | 733 | gnupatch -p0 < os2\diff.configure |
a56dbb1c | 734 | |
735 | You may also need to apply the patches supplied with the binary | |
736 | distribution of perl. | |
737 | ||
aa689395 | 738 | Note also that the F<db.lib> and F<db.a> from the EMX distribution |
a56dbb1c | 739 | are not suitable for multi-threaded compile (note that currently perl |
aa689395 | 740 | is not multithread-safe, but is compiled as multithreaded for |
741 | compatibility with XFree86-OS/2). Get a corrected one from | |
a56dbb1c | 742 | |
743 | ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/db_mt.zip | |
744 | ||
745 | =head2 Hand-editing | |
746 | ||
747 | You may look into the file F<./hints/os2.sh> and correct anything | |
748 | wrong you find there. I do not expect it is needed anywhere. | |
615d1a09 | 749 | |
a56dbb1c | 750 | =head2 Making |
615d1a09 | 751 | |
a56dbb1c | 752 | sh Configure -des -D prefix=f:/perllib |
615d1a09 | 753 | |
aa689395 | 754 | C<prefix> means: where to install the resulting perl library. Giving |
a56dbb1c | 755 | correct prefix you may avoid the need to specify C<PERLLIB_PREFIX>, |
756 | see L<"PERLLIB_PREFIX">. | |
5243f9ae | 757 | |
a56dbb1c | 758 | I<Ignore the message about missing C<ln>, and about C<-c> option to |
aa689395 | 759 | tr>. In fact if you can trace where the latter spurious warning |
a56dbb1c | 760 | comes from, please inform me. |
615d1a09 | 761 | |
a56dbb1c | 762 | Now |
5243f9ae | 763 | |
a56dbb1c | 764 | make |
5243f9ae | 765 | |
a56dbb1c | 766 | At some moment the built may die, reporting a I<version mismatch> or |
767 | I<unable to run F<perl>>. This means that most of the build has been | |
768 | finished, and it is the time to move the constructed F<perl.dll> to | |
aa689395 | 769 | some I<absolute> location in LIBPATH. After this is done the build |
770 | should finish without a lot of fuss. I<One can avoid the interruption | |
771 | if one has the correct prebuilt version of F<perl.dll> on LIBPATH, but | |
772 | probably this is not needed anymore, since F<miniperl.exe> is linked | |
773 | statically now.> | |
615d1a09 | 774 | |
a56dbb1c | 775 | Warnings which are safe to ignore: I<mkfifo() redefined> inside |
776 | F<POSIX.c>. | |
615d1a09 | 777 | |
a56dbb1c | 778 | =head2 Testing |
779 | ||
780 | Now run | |
781 | ||
782 | make test | |
783 | ||
72ea3524 | 784 | Some tests (4..6) should fail. Some perl invocations should end in a |
a56dbb1c | 785 | segfault (system error C<SYS3175>). To get finer error reports, |
786 | ||
787 | cd t | |
aa689395 | 788 | perl harness |
a56dbb1c | 789 | |
790 | The report you get may look like | |
791 | ||
792 | Failed Test Status Wstat Total Fail Failed List of failed | |
793 | --------------------------------------------------------------- | |
794 | io/fs.t 26 11 42.31% 2-5, 7-11, 18, 25 | |
795 | lib/io_pipe.t 3 768 6 ?? % ?? | |
796 | lib/io_sock.t 3 768 5 ?? % ?? | |
797 | op/stat.t 56 5 8.93% 3-4, 20, 35, 39 | |
72ea3524 | 798 | Failed 4/140 test scripts, 97.14% okay. 27/2937 subtests failed, 99.08% okay. |
a56dbb1c | 799 | |
800 | Note that using `make test' target two more tests may fail: C<op/exec:1> | |
aa689395 | 801 | because of (mis)feature of pdksh, and C<lib/posix:15>, which checks |
55497cff | 802 | that the buffers are not flushed on C<_exit> (this is a bug in the test |
803 | which assumes that tty output is buffered). | |
a56dbb1c | 804 | |
aa689395 | 805 | I submitted a patch to EMX which makes it possible to fork() with EMX |
72ea3524 IZ |
806 | dynamic libraries loaded, which makes F<lib/io*> tests pass. This means |
807 | that soon the number of failing tests may decrease yet more. | |
808 | ||
df3ef7a9 IZ |
809 | However, the test F<lib/io_udp.t> is disabled, since it never terminates, I |
810 | do not know why. Comments/fixes welcome. | |
72ea3524 | 811 | |
a56dbb1c | 812 | The reasons for failed tests are: |
813 | ||
814 | =over 8 | |
815 | ||
816 | =item F<io/fs.t> | |
817 | ||
818 | Checks I<file system> operations. Tests: | |
819 | ||
820 | =over 10 | |
821 | ||
822 | =item 2-5, 7-11 | |
823 | ||
824 | Check C<link()> and C<inode count> - nonesuch under OS/2. | |
825 | ||
826 | =item 18 | |
827 | ||
828 | Checks C<atime> and C<mtime> of C<stat()> - I could not understand this test. | |
829 | ||
830 | =item 25 | |
831 | ||
832 | Checks C<truncate()> on a filehandle just opened for write - I do not | |
833 | know why this should or should not work. | |
834 | ||
835 | =back | |
836 | ||
837 | =item F<lib/io_pipe.t> | |
838 | ||
aa689395 | 839 | Checks C<IO::Pipe> module. Some feature of EMX - test fork()s with |
a56dbb1c | 840 | dynamic extension loaded - unsupported now. |
841 | ||
842 | =item F<lib/io_sock.t> | |
843 | ||
aa689395 | 844 | Checks C<IO::Socket> module. Some feature of EMX - test fork()s |
a56dbb1c | 845 | with dynamic extension loaded - unsupported now. |
846 | ||
847 | =item F<op/stat.t> | |
848 | ||
849 | Checks C<stat()>. Tests: | |
850 | ||
851 | =over 4 | |
852 | ||
853 | =item 3 | |
854 | ||
855 | Checks C<inode count> - nonesuch under OS/2. | |
856 | ||
857 | =item 4 | |
858 | ||
859 | Checks C<mtime> and C<ctime> of C<stat()> - I could not understand this test. | |
860 | ||
861 | =item 20 | |
862 | ||
863 | Checks C<-x> - determined by the file extension only under OS/2. | |
864 | ||
865 | =item 35 | |
866 | ||
867 | Needs F</usr/bin>. | |
868 | ||
869 | =item 39 | |
870 | ||
871 | Checks C<-t> of F</dev/null>. Should not fail! | |
872 | ||
873 | =back | |
874 | ||
875 | =back | |
876 | ||
877 | In addition to errors, you should get a lot of warnings. | |
878 | ||
879 | =over 4 | |
880 | ||
881 | =item A lot of `bad free' | |
882 | ||
883 | in databases related to Berkeley DB. This is a confirmed bug of | |
884 | DB. You may disable this warnings, see L<"PERL_BADFREE">. | |
885 | ||
886 | =item Process terminated by SIGTERM/SIGINT | |
887 | ||
888 | This is a standard message issued by OS/2 applications. *nix | |
889 | applications die in silence. It is considered a feature. One can | |
890 | easily disable this by appropriate sighandlers. | |
891 | ||
892 | However the test engine bleeds these message to screen in unexpected | |
893 | moments. Two messages of this kind I<should> be present during | |
894 | testing. | |
895 | ||
896 | =item F<*/sh.exe>: ln: not found | |
897 | ||
898 | =item C<ls>: /dev: No such file or directory | |
899 | ||
900 | The last two should be self-explanatory. The test suite discovers that | |
901 | the system it runs on is not I<that much> *nixish. | |
902 | ||
903 | =back | |
615d1a09 | 904 | |
905 | A lot of `bad free'... in databases, bug in DB confirmed on other | |
5243f9ae | 906 | platforms. You may disable it by setting PERL_BADFREE environment variable |
a56dbb1c | 907 | to 1. |
615d1a09 | 908 | |
a56dbb1c | 909 | =head2 Installing the built perl |
615d1a09 | 910 | |
a56dbb1c | 911 | Run |
615d1a09 | 912 | |
a56dbb1c | 913 | make install |
615d1a09 | 914 | |
a56dbb1c | 915 | It would put the generated files into needed locations. Manually put |
916 | F<perl.exe>, F<perl__.exe> and F<perl___.exe> to a location on your | |
aa689395 | 917 | PATH, F<perl.dll> to a location on your LIBPATH. |
615d1a09 | 918 | |
a56dbb1c | 919 | Run |
615d1a09 | 920 | |
a56dbb1c | 921 | make cmdscripts INSTALLCMDDIR=d:/ir/on/path |
615d1a09 | 922 | |
a56dbb1c | 923 | to convert perl utilities to F<.cmd> files and put them on |
aa689395 | 924 | PATH. You need to put F<.EXE>-utilities on path manually. They are |
a56dbb1c | 925 | installed in C<$prefix/bin>, here C<$prefix> is what you gave to |
926 | F<Configure>, see L<Making>. | |
927 | ||
928 | =head2 C<a.out>-style build | |
929 | ||
930 | Proceed as above, but make F<perl_.exe> (see L<"perl_.exe">) by | |
931 | ||
932 | make perl_ | |
933 | ||
934 | test and install by | |
935 | ||
936 | make aout_test | |
937 | make aout_install | |
938 | ||
aa689395 | 939 | Manually put F<perl_.exe> to a location on your PATH. |
a56dbb1c | 940 | |
941 | Since C<perl_> has the extensions prebuilt, it does not suffer from | |
72ea3524 | 942 | the I<dynamic extensions + fork()> syndrome, thus the failing tests |
a56dbb1c | 943 | look like |
944 | ||
945 | Failed Test Status Wstat Total Fail Failed List of failed | |
946 | --------------------------------------------------------------- | |
947 | io/fs.t 26 11 42.31% 2-5, 7-11, 18, 25 | |
948 | op/stat.t 56 5 8.93% 3-4, 20, 35, 39 | |
949 | Failed 2/118 test scripts, 98.31% okay. 16/2445 subtests failed, 99.35% okay. | |
950 | ||
951 | B<Note.> The build process for C<perl_> I<does not know> about all the | |
952 | dependencies, so you should make sure that anything is up-to-date, | |
953 | say, by doing | |
954 | ||
955 | make perl.dll | |
956 | ||
957 | first. | |
958 | ||
959 | =head1 Build FAQ | |
960 | ||
961 | =head2 Some C</> became C<\> in pdksh. | |
962 | ||
963 | You have a very old pdksh. See L<Prerequisites>. | |
964 | ||
965 | =head2 C<'errno'> - unresolved external | |
966 | ||
967 | You do not have MT-safe F<db.lib>. See L<Prerequisites>. | |
968 | ||
aa689395 | 969 | =head2 Problems with tr |
a56dbb1c | 970 | |
aa689395 | 971 | reported with very old version of tr. |
a56dbb1c | 972 | |
973 | =head2 Some problem (forget which ;-) | |
974 | ||
aa689395 | 975 | You have an older version of F<perl.dll> on your LIBPATH, which |
a56dbb1c | 976 | broke the build of extensions. |
977 | ||
978 | =head2 Library ... not found | |
979 | ||
980 | You did not run C<omflibs>. See L<Prerequisites>. | |
981 | ||
982 | =head2 Segfault in make | |
983 | ||
aa689395 | 984 | You use an old version of GNU make. See L<Prerequisites>. |
a56dbb1c | 985 | |
986 | =head1 Specific (mis)features of OS/2 port | |
987 | ||
988 | =head2 C<setpriority>, C<getpriority> | |
989 | ||
990 | Note that these functions are compatible with *nix, not with the older | |
991 | ports of '94 - 95. The priorities are absolute, go from 32 to -95, | |
72ea3524 | 992 | lower is quicker. 0 is the default priority. |
a56dbb1c | 993 | |
994 | =head2 C<system()> | |
995 | ||
996 | Multi-argument form of C<system()> allows an additional numeric | |
997 | argument. The meaning of this argument is described in | |
998 | L<OS2::Process>. | |
999 | ||
aa689395 | 1000 | =head2 C<extproc> on the first line |
1001 | ||
1002 | If the first chars of a script are C<"extproc ">, this line is treated | |
1003 | as C<#!>-line, thus all the switches on this line are processed (twice | |
1004 | if script was started via cmd.exe). | |
1005 | ||
a56dbb1c | 1006 | =head2 Additional modules: |
615d1a09 | 1007 | |
a56dbb1c | 1008 | L<OS2::Process>, L<OS2::REXX>, L<OS2::PrfDB>, L<OS2::ExtAttr>. This |
1009 | modules provide access to additional numeric argument for C<system>, | |
1010 | to DLLs having functions with REXX signature and to REXX runtime, to | |
1011 | OS/2 databases in the F<.INI> format, and to Extended Attributes. | |
615d1a09 | 1012 | |
72ea3524 | 1013 | Two additional extensions by Andreas Kaiser, C<OS2::UPM>, and |
a56dbb1c | 1014 | C<OS2::FTP>, are included into my ftp directory, mirrored on CPAN. |
615d1a09 | 1015 | |
a56dbb1c | 1016 | =head2 Prebuilt methods: |
615d1a09 | 1017 | |
a56dbb1c | 1018 | =over 4 |
615d1a09 | 1019 | |
a56dbb1c | 1020 | =item C<File::Copy::syscopy> |
615d1a09 | 1021 | |
d7678ab8 | 1022 | used by C<File::Copy::copy>, see L<File::Copy>. |
615d1a09 | 1023 | |
a56dbb1c | 1024 | =item C<DynaLoader::mod2fname> |
615d1a09 | 1025 | |
72ea3524 | 1026 | used by C<DynaLoader> for DLL name mangling. |
615d1a09 | 1027 | |
a56dbb1c | 1028 | =item C<Cwd::current_drive()> |
615d1a09 | 1029 | |
a56dbb1c | 1030 | Self explanatory. |
615d1a09 | 1031 | |
a56dbb1c | 1032 | =item C<Cwd::sys_chdir(name)> |
615d1a09 | 1033 | |
a56dbb1c | 1034 | leaves drive as it is. |
615d1a09 | 1035 | |
a56dbb1c | 1036 | =item C<Cwd::change_drive(name)> |
615d1a09 | 1037 | |
615d1a09 | 1038 | |
a56dbb1c | 1039 | =item C<Cwd::sys_is_absolute(name)> |
615d1a09 | 1040 | |
a56dbb1c | 1041 | means has drive letter and is_rooted. |
615d1a09 | 1042 | |
a56dbb1c | 1043 | =item C<Cwd::sys_is_rooted(name)> |
615d1a09 | 1044 | |
a56dbb1c | 1045 | means has leading C<[/\\]> (maybe after a drive-letter:). |
615d1a09 | 1046 | |
a56dbb1c | 1047 | =item C<Cwd::sys_is_relative(name)> |
615d1a09 | 1048 | |
a56dbb1c | 1049 | means changes with current dir. |
615d1a09 | 1050 | |
a56dbb1c | 1051 | =item C<Cwd::sys_cwd(name)> |
615d1a09 | 1052 | |
aa689395 | 1053 | Interface to cwd from EMX. Used by C<Cwd::cwd>. |
615d1a09 | 1054 | |
a56dbb1c | 1055 | =item C<Cwd::sys_abspath(name, dir)> |
615d1a09 | 1056 | |
a56dbb1c | 1057 | Really really odious function to implement. Returns absolute name of |
1058 | file which would have C<name> if CWD were C<dir>. C<Dir> defaults to the | |
1059 | current dir. | |
615d1a09 | 1060 | |
a56dbb1c | 1061 | =item C<Cwd::extLibpath([type]) |
615d1a09 | 1062 | |
a56dbb1c | 1063 | Get current value of extended library search path. If C<type> is |
1064 | present and I<true>, works with END_LIBPATH, otherwise with | |
1065 | C<BEGIN_LIBPATH>. | |
615d1a09 | 1066 | |
a56dbb1c | 1067 | =item C<Cwd::extLibpath_set( path [, type ] )> |
615d1a09 | 1068 | |
a56dbb1c | 1069 | Set current value of extended library search path. If C<type> is |
1070 | present and I<true>, works with END_LIBPATH, otherwise with | |
1071 | C<BEGIN_LIBPATH>. | |
615d1a09 | 1072 | |
a56dbb1c | 1073 | =back |
615d1a09 | 1074 | |
a56dbb1c | 1075 | (Note that some of these may be moved to different libraries - |
1076 | eventually). | |
615d1a09 | 1077 | |
615d1a09 | 1078 | |
a56dbb1c | 1079 | =head2 Misfeatures |
615d1a09 | 1080 | |
a56dbb1c | 1081 | =over 4 |
615d1a09 | 1082 | |
a56dbb1c | 1083 | =item |
615d1a09 | 1084 | |
d7678ab8 | 1085 | Since L<flock(3)> is present in EMX, but is not functional, the same is |
55497cff | 1086 | true for perl. Here is the list of things which may be "broken" on |
1087 | EMX (from EMX docs): | |
1088 | ||
d7678ab8 CS |
1089 | =over |
1090 | ||
1091 | =item * | |
1092 | ||
1093 | The functions L<recvmsg(3)>, L<sendmsg(3)>, and L<socketpair(3)> are not | |
1094 | implemented. | |
1095 | ||
1096 | =item * | |
1097 | ||
1098 | L<sock_init(3)> is not required and not implemented. | |
1099 | ||
1100 | =item * | |
1101 | ||
1102 | L<flock(3)> is not yet implemented (dummy function). | |
1103 | ||
1104 | =item * | |
1105 | ||
1106 | L<kill(3)>: Special treatment of PID=0, PID=1 and PID=-1 is not implemented. | |
1107 | ||
1108 | =item * | |
1109 | ||
1110 | L<waitpid(3)>: | |
1111 | ||
55497cff | 1112 | WUNTRACED |
1113 | Not implemented. | |
1114 | waitpid() is not implemented for negative values of PID. | |
1115 | ||
d7678ab8 CS |
1116 | =back |
1117 | ||
55497cff | 1118 | Note that C<kill -9> does not work with the current version of EMX. |
615d1a09 | 1119 | |
a56dbb1c | 1120 | =item |
615d1a09 | 1121 | |
72ea3524 | 1122 | Since F<sh.exe> is used for globing (see L<perlfunc/glob>), the bugs |
a56dbb1c | 1123 | of F<sh.exe> plague perl as well. |
615d1a09 | 1124 | |
a56dbb1c | 1125 | In particular, uppercase letters do not work in C<[...]>-patterns with |
aa689395 | 1126 | the current pdksh. |
615d1a09 | 1127 | |
a56dbb1c | 1128 | =back |
615d1a09 | 1129 | |
55497cff | 1130 | =head2 Modifications |
1131 | ||
1132 | Perl modifies some standard C library calls in the following ways: | |
1133 | ||
1134 | =over 9 | |
1135 | ||
1136 | =item C<popen> | |
1137 | ||
72ea3524 | 1138 | C<my_popen> uses F<sh.exe> if shell is required, cf. L<"PERL_SH_DIR">. |
55497cff | 1139 | |
1140 | =item C<tmpnam> | |
1141 | ||
1142 | is created using C<TMP> or C<TEMP> environment variable, via | |
1143 | C<tempnam>. | |
1144 | ||
1145 | =item C<tmpfile> | |
1146 | ||
72ea3524 | 1147 | If the current directory is not writable, file is created using modified |
55497cff | 1148 | C<tmpnam>, so there may be a race condition. |
1149 | ||
1150 | =item C<ctermid> | |
1151 | ||
1152 | a dummy implementation. | |
1153 | ||
1154 | =item C<stat> | |
1155 | ||
1156 | C<os2_stat> special-cases F</dev/tty> and F</dev/con>. | |
1157 | ||
1158 | =back | |
1159 | ||
a56dbb1c | 1160 | =head1 Perl flavors |
615d1a09 | 1161 | |
72ea3524 | 1162 | Because of idiosyncrasies of OS/2 one cannot have all the eggs in the |
aa689395 | 1163 | same basket (though EMX environment tries hard to overcome this |
a56dbb1c | 1164 | limitations, so the situation may somehow improve). There are 4 |
1165 | executables for Perl provided by the distribution: | |
615d1a09 | 1166 | |
a56dbb1c | 1167 | =head2 F<perl.exe> |
615d1a09 | 1168 | |
a56dbb1c | 1169 | The main workhorse. This is a chimera executable: it is compiled as an |
1170 | C<a.out>-style executable, but is linked with C<omf>-style dynamic | |
aa689395 | 1171 | library F<perl.dll>, and with dynamic CRT DLL. This executable is a |
1172 | VIO application. | |
a56dbb1c | 1173 | |
1174 | It can load perl dynamic extensions, and it can fork(). Unfortunately, | |
aa689395 | 1175 | with the current version of EMX it cannot fork() with dynamic |
1176 | extensions loaded (may be fixed by patches to EMX). | |
a56dbb1c | 1177 | |
1178 | B<Note.> Keep in mind that fork() is needed to open a pipe to yourself. | |
1179 | ||
1180 | =head2 F<perl_.exe> | |
1181 | ||
1182 | This is a statically linked C<a.out>-style executable. It can fork(), | |
1183 | but cannot load dynamic Perl extensions. The supplied executable has a | |
1184 | lot of extensions prebuilt, thus there are situations when it can | |
1185 | perform tasks not possible using F<perl.exe>, like fork()ing when | |
aa689395 | 1186 | having some standard extension loaded. This executable is a VIO |
a56dbb1c | 1187 | application. |
1188 | ||
1189 | B<Note.> A better behaviour could be obtained from C<perl.exe> if it | |
1190 | were statically linked with standard I<Perl extensions>, but | |
aa689395 | 1191 | dynamically linked with the I<Perl DLL> and CRT DLL. Then it would |
a56dbb1c | 1192 | be able to fork() with standard extensions, I<and> would be able to |
1193 | dynamically load arbitrary extensions. Some changes to Makefiles and | |
1194 | hint files should be necessary to achieve this. | |
1195 | ||
1196 | I<This is also the only executable with does not require OS/2.> The | |
1197 | friends locked into C<M$> world would appreciate the fact that this | |
72ea3524 | 1198 | executable runs under DOS, Win0.3*, Win0.95 and WinNT with an |
a56dbb1c | 1199 | appropriate extender. See L<"Other OSes">. |
1200 | ||
1201 | =head2 F<perl__.exe> | |
1202 | ||
aa689395 | 1203 | This is the same executable as F<perl___.exe>, but it is a PM |
a56dbb1c | 1204 | application. |
1205 | ||
aa689395 | 1206 | B<Note.> Usually STDIN, STDERR, and STDOUT of a PM |
a56dbb1c | 1207 | application are redirected to C<nul>. However, it is possible to see |
1208 | them if you start C<perl__.exe> from a PM program which emulates a | |
aa689395 | 1209 | console window, like I<Shell mode> of Emacs or EPM. Thus it I<is |
a56dbb1c | 1210 | possible> to use Perl debugger (see L<perldebug>) to debug your PM |
1211 | application. | |
1212 | ||
aa689395 | 1213 | This flavor is required if you load extensions which use PM, like |
a56dbb1c | 1214 | the forthcoming C<Perl/Tk>. |
1215 | ||
1216 | =head2 F<perl___.exe> | |
1217 | ||
1218 | This is an C<omf>-style executable which is dynamically linked to | |
aa689395 | 1219 | F<perl.dll> and CRT DLL. I know no advantages of this executable |
a56dbb1c | 1220 | over C<perl.exe>, but it cannot fork() at all. Well, one advantage is |
1221 | that the build process is not so convoluted as with C<perl.exe>. | |
1222 | ||
aa689395 | 1223 | It is a VIO application. |
a56dbb1c | 1224 | |
1225 | =head2 Why strange names? | |
1226 | ||
1227 | Since Perl processes the C<#!>-line (cf. | |
1228 | L<perlrun/DESCRIPTION>, L<perlrun/Switches>, | |
1229 | L<perldiag/"Not a perl script">, | |
1230 | L<perldiag/"No Perl script found in input">), it should know when a | |
1231 | program I<is a Perl>. There is some naming convention which allows | |
1232 | Perl to distinguish correct lines from wrong ones. The above names are | |
72ea3524 | 1233 | almost the only names allowed by this convention which do not contain |
a56dbb1c | 1234 | digits (which have absolutely different semantics). |
1235 | ||
1236 | =head2 Why dynamic linking? | |
1237 | ||
1238 | Well, having several executables dynamically linked to the same huge | |
1239 | library has its advantages, but this would not substantiate the | |
1240 | additional work to make it compile. The reason is stupid-but-quick | |
1241 | "hard" dynamic linking used by OS/2. | |
1242 | ||
72ea3524 IZ |
1243 | The address tables of DLLs are patched only once, when they are |
1244 | loaded. The addresses of entry points into DLLs are guaranteed to be | |
a56dbb1c | 1245 | the same for all programs which use the same DLL, which reduces the |
1246 | amount of runtime patching - once DLL is loaded, its code is | |
1247 | read-only. | |
1248 | ||
1249 | While this allows some performance advantages, this makes life | |
72ea3524 | 1250 | terrible for developers, since the above scheme makes it impossible |
a56dbb1c | 1251 | for a DLL to be resolved to a symbol in the .EXE file, since this |
1252 | would need a DLL to have different relocations tables for the | |
1253 | executables which use it. | |
1254 | ||
1255 | However, a Perl extension is forced to use some symbols from the perl | |
1256 | executable, say to know how to find the arguments provided on the perl | |
1257 | internal evaluation stack. The solution is that the main code of | |
1258 | interpreter should be contained in a DLL, and the F<.EXE> file just loads | |
1259 | this DLL into memory and supplies command-arguments. | |
1260 | ||
72ea3524 | 1261 | This I<greatly> increases the load time for the application (as well as |
a56dbb1c | 1262 | the number of problems during compilation). Since interpreter is in a DLL, |
aa689395 | 1263 | the CRT is basically forced to reside in a DLL as well (otherwise |
1264 | extensions would not be able to use CRT). | |
a56dbb1c | 1265 | |
1266 | =head2 Why chimera build? | |
1267 | ||
aa689395 | 1268 | Current EMX environment does not allow DLLs compiled using Unixish |
a56dbb1c | 1269 | C<a.out> format to export symbols for data. This forces C<omf>-style |
1270 | compile of F<perl.dll>. | |
1271 | ||
aa689395 | 1272 | Current EMX environment does not allow F<.EXE> files compiled in |
a56dbb1c | 1273 | C<omf> format to fork(). fork() is needed for exactly three Perl |
1274 | operations: | |
1275 | ||
1276 | =over 4 | |
1277 | ||
1278 | =item explicit fork() | |
1279 | ||
1280 | in the script, and | |
1281 | ||
1282 | =item open FH, "|-" | |
1283 | ||
1284 | =item open FH, "-|" | |
1285 | ||
1286 | opening pipes to itself. | |
1287 | ||
1288 | =back | |
1289 | ||
1290 | While these operations are not questions of life and death, a lot of | |
1291 | useful scripts use them. This forces C<a.out>-style compile of | |
1292 | F<perl.exe>. | |
1293 | ||
1294 | ||
1295 | =head1 ENVIRONMENT | |
1296 | ||
aa689395 | 1297 | Here we list environment variables with are either OS/2- and DOS- and |
1298 | Win*-specific, or are more important under OS/2 than under other OSes. | |
a56dbb1c | 1299 | |
1300 | =head2 C<PERLLIB_PREFIX> | |
1301 | ||
aa689395 | 1302 | Specific for EMX port. Should have the form |
a56dbb1c | 1303 | |
1304 | path1;path2 | |
1305 | ||
1306 | or | |
1307 | ||
1308 | path1 path2 | |
1309 | ||
1310 | If the beginning of some prebuilt path matches F<path1>, it is | |
1311 | substituted with F<path2>. | |
1312 | ||
1313 | Should be used if the perl library is moved from the default | |
1314 | location in preference to C<PERL(5)LIB>, since this would not leave wrong | |
eb447b86 IZ |
1315 | entries in @INC. Say, if the compiled version of perl looks for @INC |
1316 | in F<f:/perllib/lib>, and you want to install the library in | |
1317 | F<h:/opt/gnu>, do | |
1318 | ||
1319 | set PERLLIB_PREFIX=f:/perllib/lib;h:/opt/gnu | |
a56dbb1c | 1320 | |
1321 | =head2 C<PERL_BADLANG> | |
1322 | ||
1323 | If 1, perl ignores setlocale() failing. May be useful with some | |
1324 | strange I<locale>s. | |
1325 | ||
1326 | =head2 C<PERL_BADFREE> | |
1327 | ||
1328 | If 1, perl would not warn of in case of unwarranted free(). May be | |
1329 | useful in conjunction with the module DB_File, since Berkeley DB | |
1330 | memory handling code is buggy. | |
1331 | ||
1332 | =head2 C<PERL_SH_DIR> | |
1333 | ||
aa689395 | 1334 | Specific for EMX port. Gives the directory part of the location for |
a56dbb1c | 1335 | F<sh.exe>. |
1336 | ||
1337 | =head2 C<TMP> or C<TEMP> | |
1338 | ||
aa689395 | 1339 | Specific for EMX port. Used as storage place for temporary files, most |
a56dbb1c | 1340 | notably C<-e> scripts. |
1341 | ||
1342 | =head1 Evolution | |
1343 | ||
1344 | Here we list major changes which could make you by surprise. | |
1345 | ||
1346 | =head2 Priorities | |
1347 | ||
1348 | C<setpriority> and C<getpriority> are not compatible with earlier | |
1349 | ports by Andreas Kaiser. See C<"setpriority, getpriority">. | |
1350 | ||
72ea3524 | 1351 | =head2 DLL name mangling |
a56dbb1c | 1352 | |
1353 | With the release 5.003_01 the dynamically loadable libraries | |
1354 | should be rebuilt. In particular, DLLs are now created with the names | |
1355 | which contain a checksum, thus allowing workaround for OS/2 scheme of | |
1356 | caching DLLs. | |
1357 | ||
1358 | =head2 Threading | |
1359 | ||
aa689395 | 1360 | As of release 5.003_01 perl is linked to multithreaded CRT |
a56dbb1c | 1361 | DLL. Perl itself is not multithread-safe, as is not perl |
1362 | malloc(). However, extensions may use multiple thread on their own | |
1363 | risk. | |
1364 | ||
aa689395 | 1365 | Needed to compile C<Perl/Tk> for XFree86-OS/2 out-of-the-box. |
a56dbb1c | 1366 | |
1367 | =head2 Calls to external programs | |
1368 | ||
1369 | Due to a popular demand the perl external program calling has been | |
72ea3524 | 1370 | changed wrt Andreas Kaiser's port. I<If> perl needs to call an |
a56dbb1c | 1371 | external program I<via shell>, the F<f:/bin/sh.exe> will be called, or |
1372 | whatever is the override, see L<"PERL_SH_DIR">. | |
1373 | ||
1374 | Thus means that you need to get some copy of a F<sh.exe> as well (I | |
1375 | use one from pdksh). The drive F: above is set up automatically during | |
1376 | the build to a correct value on the builder machine, but is | |
1377 | overridable at runtime, | |
1378 | ||
1379 | B<Reasons:> a consensus on C<perl5-porters> was that perl should use | |
1380 | one non-overridable shell per platform. The obvious choices for OS/2 | |
1381 | are F<cmd.exe> and F<sh.exe>. Having perl build itself would be impossible | |
1382 | with F<cmd.exe> as a shell, thus I picked up C<sh.exe>. Thus assures almost | |
aa689395 | 1383 | 100% compatibility with the scripts coming from *nix. As an added benefit |
1384 | this works as well under DOS if you use DOS-enabled port of pdksh | |
1385 | (see L<"Prerequisites">). | |
a56dbb1c | 1386 | |
aa689395 | 1387 | B<Disadvantages:> currently F<sh.exe> of pdksh calls external programs |
a56dbb1c | 1388 | via fork()/exec(), and there is I<no> functioning exec() on |
1389 | OS/2. exec() is emulated by EMX by asyncroneous call while the caller | |
72ea3524 | 1390 | waits for child completion (to pretend that the C<pid> did not change). This |
a56dbb1c | 1391 | means that 1 I<extra> copy of F<sh.exe> is made active via fork()/exec(), |
1392 | which may lead to some resources taken from the system (even if we do | |
1393 | not count extra work needed for fork()ing). | |
1394 | ||
72ea3524 IZ |
1395 | Note that this a lesser issue now when we do not spawn F<sh.exe> |
1396 | unless needed (metachars found). | |
1397 | ||
1398 | One can always start F<cmd.exe> explicitly via | |
a56dbb1c | 1399 | |
1400 | system 'cmd', '/c', 'mycmd', 'arg1', 'arg2', ... | |
1401 | ||
72ea3524 | 1402 | If you need to use F<cmd.exe>, and do not want to hand-edit thousands of your |
a56dbb1c | 1403 | scripts, the long-term solution proposed on p5-p is to have a directive |
1404 | ||
1405 | use OS2::Cmd; | |
1406 | ||
1407 | which will override system(), exec(), C<``>, and | |
1408 | C<open(,'...|')>. With current perl you may override only system(), | |
1409 | readpipe() - the explicit version of C<``>, and maybe exec(). The code | |
1410 | will substitute the one-argument call to system() by | |
1411 | C<CORE::system('cmd.exe', '/c', shift)>. | |
1412 | ||
1413 | If you have some working code for C<OS2::Cmd>, please send it to me, | |
1414 | I will include it into distribution. I have no need for such a module, so | |
1415 | cannot test it. | |
1416 | ||
df3ef7a9 IZ |
1417 | =head2 Memory allocation |
1418 | ||
1419 | Perl uses its own malloc() under OS/2 - interpreters are usually malloc-bound | |
1420 | for speed, but perl is not, since its malloc is lightning-fast. | |
1421 | Unfortunately, it is also quite frivolous with memory usage as well. | |
1422 | ||
1423 | Since kitchen-top machines are usually low on memory, perl is compiled with | |
1424 | all the possible memory-saving options. This probably makes perl's | |
1425 | malloc() as greedy with memory as the neighbor's malloc(), but still | |
1426 | much quickier. Note that this is true only for a "typical" usage, | |
1427 | it is possible that the perl malloc will be worse for some very special usage. | |
1428 | ||
1429 | Combination of perl's malloc() and rigid DLL name resolution creates | |
1430 | a special problem with library functions which expect their return value to | |
1431 | be free()d by system's free(). To facilitate extensions which need to call | |
1432 | such functions, system memory-allocation functions are still available with | |
1433 | the prefix C<emx_> added. (Currently only DLL perl has this, it should | |
1434 | propagate to F<perl_.exe> shortly.) | |
1435 | ||
a56dbb1c | 1436 | =cut |
1437 | ||
1438 | OS/2 extensions | |
1439 | ~~~~~~~~~~~~~~~ | |
72ea3524 | 1440 | I include 3 extensions by Andreas Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP, |
a56dbb1c | 1441 | into my ftp directory, mirrored on CPAN. I made |
1442 | some minor changes needed to compile them by standard tools. I cannot | |
1443 | test UPM and FTP, so I will appreciate your feedback. Other extensions | |
1444 | there are OS2::ExtAttr, OS2::PrfDB for tied access to EAs and .INI | |
1445 | files - and maybe some other extensions at the time you read it. | |
1446 | ||
1447 | Note that OS2 perl defines 2 pseudo-extension functions | |
aa689395 | 1448 | OS2::Copy::copy and DynaLoader::mod2fname (many more now, see |
1449 | L<Prebuilt methods>). | |
a56dbb1c | 1450 | |
1451 | The -R switch of older perl is deprecated. If you need to call a REXX code | |
1452 | which needs access to variables, include the call into a REXX compartment | |
1453 | created by | |
1454 | REXX_call {...block...}; | |
1455 | ||
1456 | Two new functions are supported by REXX code, | |
1457 | REXX_eval 'string'; | |
1458 | REXX_eval_with 'string', REXX_function_name => \&perl_sub_reference; | |
1459 | ||
1460 | If you have some other extensions you want to share, send the code to | |
1461 | me. At least two are available: tied access to EA's, and tied access | |
1462 | to system databases. | |
615d1a09 | 1463 | |
a56dbb1c | 1464 | =head1 AUTHOR |
615d1a09 | 1465 | |
a56dbb1c | 1466 | Ilya Zakharevich, ilya@math.ohio-state.edu |
615d1a09 | 1467 | |
a56dbb1c | 1468 | =head1 SEE ALSO |
615d1a09 | 1469 | |
a56dbb1c | 1470 | perl(1). |
615d1a09 | 1471 | |
a56dbb1c | 1472 | =cut |
615d1a09 | 1473 |