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