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