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