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