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