1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see perlpod manpage) which is
3 specially designed to be readable as is.
7 perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
11 One can read this document in the following formats:
18 to list some (not all may be available simultaneously), or it may
19 be read I<as is>: either as F<README.os2>, or F<pod/perlos2.pod>.
21 To read the F<.INF> version of documentation (B<very> recommended)
22 outside of OS/2, one needs an IBM's reader (may be available on IBM
23 ftp sites (?) (URL anyone?)) or shipped with PC DOS 7.0 and IBM's
26 A copy of a Win* viewer is contained in the "Just add OS/2 Warp" package
28 ftp://ftp.software.ibm.com/ps/products/os2/tools/jaow/jaow.zip
30 in F<?:\JUST_ADD\view.exe>. This gives one an access to EMX's
31 F<.INF> docs as well (text form is available in F</emx/doc> in
34 Note that if you have F<lynx.exe> installed, you can follow WWW links
35 from this document in F<.INF> format. If you have EMX docs installed
36 correctly, you can follow library links (you need to have C<view emxbook>
37 working by setting C<EMXBOOK> environment variable as it is described
44 perlos2 - Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
52 - Starting Perl programs under OS/2 (and DOS and...)
53 - Starting OS/2 (and DOS) programs under Perl
54 Frequently asked questions
55 - I cannot run external programs
56 - I cannot embed perl into my program, or use perl.dll from my program.
57 - `` and pipe-open do not work under DOS.
58 - Cannot start find.exe "pattern" file
60 - Automatic binary installation
61 - Manual binary installation
63 Accessing documentation
74 - Application of the patches
78 - Installing the built perl
81 - Some / became \ in pdksh.
82 - 'errno' - unresolved external
84 - Some problem (forget which ;-)
85 - Library ... not found
87 Specific (mis)features of EMX port
88 - setpriority, getpriority
90 - extproc on the first line
101 - Why dynamic linking?
113 - Calls to external programs
123 The target is to make OS/2 the best supported platform for
124 using/building/developing Perl and I<Perl applications>, as well as
125 make Perl the best language to use under OS/2. The secondary target is
126 to try to make this work under DOS and Win* as well (but not B<too> hard).
128 The current state is quite close to this target. Known limitations:
134 Some *nix programs use fork() a lot, but currently fork() is not
135 supported after I<use>ing dynamically loaded extensions.
139 You need a separate perl executable F<perl__.exe> (see L<perl__.exe>)
140 to use PM code in your application (like the forthcoming Perl/Tk).
144 There is no simple way to access WPS objects. The only way I know
145 is via C<OS2::REXX> extension (see L<OS2::REXX>), and we do not have access to
146 convenience methods of Object-REXX. (Is it possible at all? I know
147 of no Object-REXX API.)
151 Please keep this list up-to-date by informing me about other items.
155 Since OS/2 port of perl uses a remarkable EMX environment, it can
156 run (and build extensions, and - possibly - be build itself) under any
157 environment which can run EMX. The current list is DOS,
158 DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT. Out of many perl flavors,
159 only one works, see L<"perl_.exe">.
161 Note that not all features of Perl are available under these
162 environments. This depends on the features the I<extender> - most
163 probably RSX - decided to implement.
165 Cf. L<Prerequisites>.
173 EMX runtime is required (may be substituted by RSX). Note that
174 it is possible to make F<perl_.exe> to run under DOS without any
175 external support by binding F<emx.exe>/F<rsx.exe> to it, see L<emxbind>. Note
176 that under DOS for best results one should use RSX runtime, which
177 has much more functions working (like C<fork>, C<popen> and so on). In
178 fact RSX is required if there is no VCPI present. Note the
181 Only the latest runtime is supported, currently C<0.9d fix 03>. Perl may run
182 under earlier versions of EMX, but this is not tested.
184 One can get different parts of EMX from, say
186 http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/
187 http://powerusersbbs.com/pub/os2/dev/ [EMX+GCC Development]
188 http://hobbes.nmsu.edu/pub/os2/dev/emx/v0.9d/
190 The runtime component should have the name F<emxrt.zip>.
192 B<NOTE>. It is enough to have F<emx.exe>/F<rsx.exe> on your path. One
193 does not need to specify them explicitly (though this
201 To run Perl on DPMI platforms one needs RSX runtime. This is
202 needed under DOS-inside-OS/2, Win0.3*, Win0.95 and WinNT (see
203 L<"Other OSes">). RSX would not work with VCPI
204 only, as EMX would, it requires DMPI.
206 Having RSX and the latest F<sh.exe> one gets a fully functional
207 B<*nix>-ish environment under DOS, say, C<fork>, C<``> and
208 pipe-C<open> work. In fact, MakeMaker works (for static build), so one
209 can have Perl development environment under DOS.
211 One can get RSX from, say
213 ftp://ftp.cdrom.com/pub/os2/emx09c/contrib
214 ftp://ftp.uni-bielefeld.de/pub/systems/msdos/misc
215 ftp://ftp.leo.org/pub/comp/os/os2/leo/devtools/emx+gcc/contrib
217 Contact the author on C<rainer@mathematik.uni-bielefeld.de>.
219 The latest F<sh.exe> with DOS hooks is available at
221 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.zip
225 Perl does not care about file systems, but to install the whole perl
226 library intact one needs a file system which supports long file names.
228 Note that if you do not plan to build the perl itself, it may be
229 possible to fool EMX to truncate file names. This is not supported,
230 read EMX docs to see how to do it.
234 To start external programs with complicated command lines (like with
235 pipes in between, and/or quoting of arguments), Perl uses an external
236 shell. With EMX port such shell should be named <sh.exe>, and located
237 either in the wired-in-during-compile locations (usually F<F:/bin>),
238 or in configurable location (see L<"PERL_SH_DIR">).
240 For best results use EMX pdksh. The soon-to-be-available standard
241 binary (5.2.12?) runs under DOS (with L<RSX>) as well, meanwhile use
244 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.zip
248 =head2 Starting Perl programs under OS/2 (and DOS and...)
250 Start your Perl program F<foo.pl> with arguments C<arg1 arg2 arg3> the
251 same way as on any other platform, by
253 perl foo.pl arg1 arg2 arg3
255 If you want to specify perl options C<-my_opts> to the perl itself (as
256 opposed to to your program), use
258 perl -my_opts foo.pl arg1 arg2 arg3
260 Alternately, if you use OS/2-ish shell, like CMD or 4os2, put
261 the following at the start of your perl script:
263 extproc perl -S -my_opts
265 rename your program to F<foo.cmd>, and start it by typing
269 Note that because of stupid OS/2 limitations the full path of the perl
270 script is not available when you use C<extproc>, thus you are forced to
271 use C<-S> perl switch, and your script should be on path. As a plus
272 side, if you know a full path to your script, you may still start it
275 perl ../../blah/foo.cmd arg1 arg2 arg3
277 (note that the argument C<-my_opts> is taken care of by the C<extproc> line
278 in your script, see L<C<extproc> on the first line>).
280 To understand what the above I<magic> does, read perl docs about C<-S>
281 switch - see L<perlrun>, and cmdref about C<extproc>:
288 or whatever method you prefer.
290 There are also endless possibilities to use I<executable extensions> of
291 4os2, I<associations> of WPS and so on... However, if you use
292 *nixish shell (like F<sh.exe> supplied in the binary distribution),
293 you need to follow the syntax specified in L<perlrun/"Switches">.
295 Note that B<-S> switch enables a search with additional extensions
296 F<.cmd>, F<.btm>, F<.bat>, F<.pl> as well.
298 =head2 Starting OS/2 (and DOS) programs under Perl
300 This is what system() (see L<perlfunc/system>), C<``> (see
301 L<perlop/"I/O Operators">), and I<open pipe> (see L<perlfunc/open>)
302 are for. (Avoid exec() (see L<perlfunc/exec>) unless you know what you
305 Note however that to use some of these operators you need to have a
306 sh-syntax shell installed (see L<"Pdksh">,
307 L<"Frequently asked questions">), and perl should be able to find it
308 (see L<"PERL_SH_DIR">).
310 The cases when the shell is used are:
316 One-argument system() (see L<perlfunc/system>), exec() (see L<perlfunc/exec>)
317 with redirection or shell meta-characters;
321 Pipe-open (see L<perlfunc/open>) with the command which contains redirection
322 or shell meta-characters;
326 Backticks C<``> (see L<perlop/"I/O Operators">) with the command which contains
327 redirection or shell meta-characters;
331 If the executable called by system()/exec()/pipe-open()/C<``> is a script
332 with the "magic" C<#!> line or C<extproc> line which specifies shell;
336 If the executable called by system()/exec()/pipe-open()/C<``> is a script
337 without "magic" line, and C<$ENV{EXECSHELL}> is set to shell;
341 If the executable called by system()/exec()/pipe-open()/C<``> is not
346 For globbing (see L<perlfunc/glob>, L<perlop/"I/O Operators">).
350 For the sake of speed for a common case, in the above algorithms
351 backslashes in the command name are not considered as shell metacharacters.
353 Perl starts scripts which begin with cookies
354 C<extproc> or C<#!> directly, without an intervention of shell. Perl uses the
355 same algorithm to find the executable as F<pdksh>: if the path
356 on C<#!> line does not work, and contains C</>, then the executable
357 is searched in F<.> and on C<PATH>. To find arguments for these scripts
358 Perl uses a different algorithm than F<pdksh>: up to 3 arguments are
359 recognized, and trailing whitespace is stripped.
362 does not contain such a cooky, then to avoid calling F<sh.exe>, Perl uses
363 the same algorithm as F<pdksh>: if C<$ENV{EXECSHELL}> is set, the
364 script is given as the first argument to this command, if not set, then
365 C<$ENV{COMSPEC} /c> is used (or a hardwired guess if C<$ENV{COMSPEC}> is
368 If starting scripts directly, Perl will use exactly the same algorithm as for
369 the search of script given by B<-S> command-line option: it will look in
370 the current directory, then on components of C<$ENV{PATH}> using the
371 following order of appended extensions: no extension, F<.cmd>, F<.btm>,
374 Note that Perl will start to look for scripts only if OS/2 cannot start the
375 specified application, thus C<system 'blah'> will not look for a script if
376 there is an executable file F<blah.exe> I<anywhere> on C<PATH>.
378 Note also that executable files on OS/2 can have an arbitrary extension,
379 but F<.exe> will be automatically appended if no dot is present in the name.
380 The workaround as as simple as that: since F<blah.> and F<blah> denote the
381 same file, to start an executable residing in file F<n:/bin/blah> (no
382 extension) give an argument C<n:/bin/blah.> to system().
384 The last note is that currently it is not straightforward to start PM
385 programs from VIO (=text-mode) Perl process and visa versa. Either ensure
386 that shell will be used, as in C<system 'cmd /c epm'>, or start it using
387 optional arguments to system() documented in C<OS2::Process> module. This
388 is considered a bug and should be fixed soon.
391 =head1 Frequently asked questions
393 =head2 I cannot run external programs
399 Did you run your programs with C<-w> switch? See
400 L<Starting OS/2 (and DOS) programs under Perl>.
404 Do you try to run I<internal> shell commands, like C<`copy a b`>
405 (internal for F<cmd.exe>), or C<`glob a*b`> (internal for ksh)? You
406 need to specify your shell explicitly, like C<`cmd /c copy a b`>,
407 since Perl cannot deduce which commands are internal to your shell.
411 =head2 I cannot embed perl into my program, or use F<perl.dll> from my
416 =item Is your program EMX-compiled with C<-Zmt -Zcrtdll>?
418 If not, you need to build a stand-alone DLL for perl. Contact me, I
419 did it once. Sockets would not work, as a lot of other stuff.
421 =item Did you use L<ExtUtils::Embed>?
423 I had reports it does not work. Somebody would need to fix it.
427 =head2 C<``> and pipe-C<open> do not work under DOS.
429 This may a variant of just L<"I cannot run external programs">, or a
430 deeper problem. Basically: you I<need> RSX (see L<"Prerequisites">)
431 for these commands to work, and you may need a port of F<sh.exe> which
432 understands command arguments. One of such ports is listed in
433 L<"Prerequisites"> under RSX. Do not forget to set variable
434 C<L<"PERL_SH_DIR">> as well.
436 DPMI is required for RSX.
438 =head2 Cannot start C<find.exe "pattern" file>
442 system 'cmd', '/c', 'find "pattern" file';
443 `cmd /c 'find "pattern" file'`
445 This would start F<find.exe> via F<cmd.exe> via C<sh.exe> via
446 C<perl.exe>, but this is a price to pay if you want to use
447 non-conforming program. In fact F<find.exe> cannot be started at all
448 using C library API only. Otherwise the following command-lines were
456 =head2 Automatic binary installation
458 The most convenient way of installing perl is via perl installer
459 F<install.exe>. Just follow the instructions, and 99% of the
460 installation blues would go away.
462 Note however, that you need to have F<unzip.exe> on your path, and
463 EMX environment I<running>. The latter means that if you just
464 installed EMX, and made all the needed changes to F<Config.sys>,
465 you may need to reboot in between. Check EMX runtime by running
469 A folder is created on your desktop which contains some useful
472 B<Things not taken care of by automatic binary installation:>
476 =item C<PERL_BADLANG>
478 may be needed if you change your codepage I<after> perl installation,
479 and the new value is not supported by EMX. See L<"PERL_BADLANG">.
481 =item C<PERL_BADFREE>
483 see L<"PERL_BADFREE">.
487 This file resides somewhere deep in the location you installed your
488 perl library, find it out by
490 perl -MConfig -le "print $INC{'Config.pm'}"
492 While most important values in this file I<are> updated by the binary
493 installer, some of them may need to be hand-edited. I know no such
494 data, please keep me informed if you find one.
498 B<NOTE>. Because of a typo the binary installer of 5.00305
499 would install a variable C<PERL_SHPATH> into F<Config.sys>. Please
500 remove this variable and put C<L<PERL_SH_DIR>> instead.
502 =head2 Manual binary installation
504 As of version 5.00305, OS/2 perl binary distribution comes split
505 into 11 components. Unfortunately, to enable configurable binary
506 installation, the file paths in the zip files are not absolute, but
507 relative to some directory.
509 Note that the extraction with the stored paths is still necessary
510 (default with unzip, specify C<-d> to pkunzip). However, you
511 need to know where to extract the files. You need also to manually
512 change entries in F<Config.sys> to reflect where did you put the
513 files. Note that if you have some primitive unzipper (like
514 pkunzip), you may get a lot of warnings/errors during
515 unzipping. Upgrade to C<(w)unzip>.
517 Below is the sample of what to do to reproduce the configuration on my
522 =item Perl VIO and PM executables (dynamically linked)
524 unzip perl_exc.zip *.exe *.ico -d f:/emx.add/bin
525 unzip perl_exc.zip *.dll -d f:/emx.add/dll
527 (have the directories with C<*.exe> on PATH, and C<*.dll> on
530 =item Perl_ VIO executable (statically linked)
532 unzip perl_aou.zip -d f:/emx.add/bin
534 (have the directory on PATH);
536 =item Executables for Perl utilities
538 unzip perl_utl.zip -d f:/emx.add/bin
540 (have the directory on PATH);
542 =item Main Perl library
544 unzip perl_mlb.zip -d f:/perllib/lib
546 If this directory is preserved, you do not need to change
547 anything. However, for perl to find it if it is changed, you need to
548 C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">.
550 =item Additional Perl modules
552 unzip perl_ste.zip -d f:/perllib/lib/site_perl
554 If you do not change this directory, do nothing. Otherwise put this
555 directory and subdirectory F<./os2> in C<PERLLIB> or C<PERL5LIB>
556 variable. Do not use C<PERL5LIB> unless you have it set already. See
557 L<perl/"ENVIRONMENT">.
559 =item Tools to compile Perl modules
561 unzip perl_blb.zip -d f:/perllib/lib
563 If this directory is preserved, you do not need to change
564 anything. However, for perl to find it if it is changed, you need to
565 C<set PERLLIB_PREFIX> in F<Config.sys>, see L<"PERLLIB_PREFIX">.
567 =item Manpages for Perl and utilities
569 unzip perl_man.zip -d f:/perllib/man
571 This directory should better be on C<MANPATH>. You need to have a
572 working man to access these files.
574 =item Manpages for Perl modules
576 unzip perl_mam.zip -d f:/perllib/man
578 This directory should better be on C<MANPATH>. You need to have a
579 working man to access these files.
581 =item Source for Perl documentation
583 unzip perl_pod.zip -d f:/perllib/lib
585 This is used by by C<perldoc> program (see L<perldoc>), and may be used to
586 generate HTML documentation usable by WWW browsers, and
587 documentation in zillions of other formats: C<info>, C<LaTeX>,
588 C<Acrobat>, C<FrameMaker> and so on.
590 =item Perl manual in F<.INF> format
592 unzip perl_inf.zip -d d:/os2/book
594 This directory should better be on C<BOOKSHELF>.
598 unzip perl_sh.zip -d f:/bin
600 This is used by perl to run external commands which explicitly
601 require shell, like the commands using I<redirection> and I<shell
602 metacharacters>. It is also used instead of explicit F</bin/sh>.
604 Set C<PERL_SH_DIR> (see L<"PERL_SH_DIR">) if you move F<sh.exe> from
607 B<Note.> It may be possible to use some other sh-compatible shell
612 After you installed the components you needed and updated the
613 F<Config.sys> correspondingly, you need to hand-edit
614 F<Config.pm>. This file resides somewhere deep in the location you
615 installed your perl library, find it out by
617 perl -MConfig -le "print $INC{'Config.pm'}"
619 You need to correct all the entries which look like file paths (they
620 currently start with C<f:/>).
624 The automatic and manual perl installation leave precompiled paths
625 inside perl executables. While these paths are overwriteable (see
626 L<"PERLLIB_PREFIX">, L<"PERL_SH_DIR">), one may get better results by
627 binary editing of paths inside the executables/DLLs.
629 =head1 Accessing documentation
631 Depending on how you built/installed perl you may have (otherwise
632 identical) Perl documentation in the following formats:
634 =head2 OS/2 F<.INF> file
636 Most probably the most convenient form. Under OS/2 view it as
641 view perl ExtUtils::MakeMaker
643 (currently the last two may hit a wrong location, but this may improve
644 soon). Under Win* see L<"SYNOPSIS">.
646 If you want to build the docs yourself, and have I<OS/2 toolkit>, run
650 in F</perllib/lib/pod> directory, then
654 (Expect a lot of errors during the both steps.) Now move it on your
659 If you have perl documentation in the source form, perl utilities
660 installed, and GNU groff installed, you may use
664 perldoc ExtUtils::MakeMaker
666 to access the perl documentation in the text form (note that you may get
667 better results using perl manpages).
669 Alternately, try running pod2text on F<.pod> files.
673 If you have man installed on your system, and you installed perl
674 manpages, use something like this:
678 man ExtUtils.MakeMaker
680 to access documentation for different components of Perl. Start with
684 Note that dot (F<.>) is used as a package separator for documentation
685 for packages, and as usual, sometimes you need to give the section - C<3>
686 above - to avoid shadowing by the I<less(1) manpage>.
688 Make sure that the directory B<above> the directory with manpages is
689 on our C<MANPATH>, like this
691 set MANPATH=c:/man;f:/perllib/man
695 If you have some WWW browser available, installed the Perl
696 documentation in the source form, and Perl utilities, you can build
697 HTML docs. Cd to directory with F<.pod> files, and do like this
699 cd f:/perllib/lib/pod
702 After this you can direct your browser the file F<perl.html> in this
703 directory, and go ahead with reading docs, like this:
705 explore file:///f:/perllib/lib/pod/perl.html
707 Alternatively you may be able to get these docs prebuilt from CPAN.
709 =head2 GNU C<info> files
711 Users of Emacs would appreciate it very much, especially with
712 C<CPerl> mode loaded. You need to get latest C<pod2info> from C<CPAN>,
713 or, alternately, prebuilt info pages.
717 for C<Acrobat> are available on CPAN (for slightly old version of
722 can be constructed using C<pod2latex>.
726 Here we discuss how to build Perl under OS/2. There is an alternative
727 (but maybe older) view on
728 L<http://www.shadow.net/~troc/os2perl.html|http://www.shadow.net/~troc/os2perl.html>.
732 You need to have the latest EMX development environment, the full
733 GNU tool suite (gawk renamed to awk, and GNU F<find.exe>
734 earlier on path than the OS/2 F<find.exe>, same with F<sort.exe>, to
740 ). You need the latest version of F<pdksh> installed as F<sh.exe>.
742 Check that you have B<BSD> libraries and headers installed, and -
743 optionally - Berkeley DB headers and libraries, and crypt.
745 Possible locations to get this from are
747 ftp://hobbes.nmsu.edu/os2/unix/
748 ftp://ftp.cdrom.com/pub/os2/unix/
749 ftp://ftp.cdrom.com/pub/os2/dev32/
750 ftp://ftp.cdrom.com/pub/os2/emx09c/
752 It is reported that the following archives contain enough utils to
753 build perl: gnufutil.zip, gnusutil.zip, gnututil.zip, gnused.zip,
754 gnupatch.zip, gnuawk.zip, gnumake.zip and ksh527rt.zip. Note that
755 all these utilities are known to be available from LEO:
757 ftp://ftp.leo.org/pub/comp/os/os2/leo/gnu
759 Make sure that no copies or perl are currently running. Later steps
760 of the build may fail since an older version of perl.dll loaded into
763 Also make sure that you have F</tmp> directory on the current drive,
764 and F<.> directory in your C<LIBPATH>. One may try to correct the
769 if you use something like F<CMD.EXE> or latest versions of F<4os2.exe>.
771 Make sure your gcc is good for C<-Zomf> linking: run C<omflibs>
772 script in F</emx/lib> directory.
774 Check that you have link386 installed. It comes standard with OS/2,
775 but may be not installed due to customization. If typing
779 shows you do not have it, do I<Selective install>, and choose C<Link
780 object modules> in I<Optional system utilities/More>. If you get into
781 link386, press C<Ctrl-C>.
783 =head2 Getting perl source
785 You need to fetch the latest perl source (including developers
786 releases). With some probability it is located in
788 http://www.perl.com/CPAN/src/5.0
789 http://www.perl.com/CPAN/src/5.0/unsupported
791 If not, you may need to dig in the indices to find it in the directory
792 of the current maintainer.
794 Quick cycle of developers release may break the OS/2 build time to
797 http://www.perl.com/CPAN/ports/os2/ilyaz/
799 may indicate the latest release which was publicly released by the
800 maintainer. Note that the release may include some additional patches
801 to apply to the current source of perl.
805 tar vzxf perl5.00409.tar.gz
807 You may see a message about errors while extracting F<Configure>. This is
808 because there is a conflict with a similarly-named file F<configure>.
810 Change to the directory of extraction.
812 =head2 Application of the patches
814 You need to apply the patches in F<./os2/diff.*> like this:
816 gnupatch -p0 < os2\diff.configure
818 You may also need to apply the patches supplied with the binary
819 distribution of perl.
821 Note also that the F<db.lib> and F<db.a> from the EMX distribution
822 are not suitable for multi-threaded compile (note that currently perl
823 is not multithread-safe, but is compiled as multithreaded for
824 compatibility with XFree86-OS/2). Get a corrected one from
826 ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/db_mt.zip
828 To make C<-p> filetest work, one may also need to apply the following patch
831 --- /emx/include/sys/stat.h.orig Thu May 23 13:48:16 1996
832 +++ /emx/include/sys/stat.h Sun Jul 12 14:11:32 1998
833 @@ -53,7 +53,7 @@ struct stat
836 #if !defined (S_IFMT)
837 -#define S_IFMT 0160000 /* Mask for file type */
838 +#define S_IFMT 0170000 /* Mask for file type */
839 #define S_IFIFO 0010000 /* Pipe */
840 #define S_IFCHR 0020000 /* Character device */
841 #define S_IFDIR 0040000 /* Directory */
846 You may look into the file F<./hints/os2.sh> and correct anything
847 wrong you find there. I do not expect it is needed anywhere.
851 sh Configure -des -D prefix=f:/perllib
853 C<prefix> means: where to install the resulting perl library. Giving
854 correct prefix you may avoid the need to specify C<PERLLIB_PREFIX>,
855 see L<"PERLLIB_PREFIX">.
857 I<Ignore the message about missing C<ln>, and about C<-c> option to
858 tr>. In fact if you can trace where the latter spurious warning
859 comes from, please inform me.
865 At some moment the built may die, reporting a I<version mismatch> or
866 I<unable to run F<perl>>. This means that most of the build has been
867 finished, and it is the time to move the constructed F<perl.dll> to
868 some I<absolute> location in LIBPATH. After this is done the build
869 should finish without a lot of fuss. I<One can avoid the interruption
870 if one has the correct prebuilt version of F<perl.dll> on LIBPATH, but
871 probably this is not needed anymore, since F<miniperl.exe> is linked
874 Warnings which are safe to ignore: I<mkfifo() redefined> inside
879 If you haven't yet moved perl.dll onto LIBPATH, do it now (alternatively, if
880 you have a previous perl installation you'd rather not disrupt until this one
881 is installed, copy perl.dll to the t directory).
887 All tests should succeed (with some of them skipped). Note that on one
888 of the systems I see intermittent failures of F<io/pipe.t> subtest 9.
889 Any help to track what happens with this test is appreciated.
891 Some tests may generate extra messages similar to
895 =item A lot of C<bad free>
897 in database tests related to Berkeley DB. This is a confirmed bug of
898 DB. You may disable this warnings, see L<"PERL_BADFREE">.
900 There is not much we can do with it (but apparently it does not cause
901 any real error with data).
903 =item Process terminated by SIGTERM/SIGINT
905 This is a standard message issued by OS/2 applications. *nix
906 applications die in silence. It is considered a feature. One can
907 easily disable this by appropriate sighandlers.
909 However the test engine bleeds these message to screen in unexpected
910 moments. Two messages of this kind I<should> be present during
915 Two F<lib/io_*> tests may generate popups (system error C<SYS3175>),
916 but should succeed anyway. This is due to a bug of EMX related to
917 fork()ing with dynamically loaded libraries.
919 I submitted a patch to EMX which makes it possible to fork() with EMX
920 dynamic libraries loaded, which makes F<lib/io*> tests pass without
921 skipping offended tests. This means that soon the number of skipped tests
922 may decrease yet more.
924 To get finer test reports, call
928 The report with F<io/pipe.t> failing may look like this:
930 Failed Test Status Wstat Total Fail Failed List of failed
931 ------------------------------------------------------------
932 io/pipe.t 12 1 8.33% 9
933 7 tests skipped, plus 56 subtests skipped.
934 Failed 1/195 test scripts, 99.49% okay. 1/6542 subtests failed, 99.98% okay.
936 The reasons for most important skipped tests are:
946 Checks C<atime> and C<mtime> of C<stat()> - unfortunately, HPFS
947 provides only 2sec time granularity (for compatibility with FAT?).
951 Checks C<truncate()> on a filehandle just opened for write - I do not
952 know why this should or should not work.
956 =item F<lib/io_pipe.t>
958 Checks C<IO::Pipe> module. Some feature of EMX - test fork()s with
959 dynamic extension loaded - unsupported now.
961 =item F<lib/io_sock.t>
963 Checks C<IO::Socket> module. Some feature of EMX - test fork()s
964 with dynamic extension loaded - unsupported now.
968 Checks C<stat()>. Tests:
974 Checks C<atime> and C<mtime> of C<stat()> - unfortunately, HPFS
975 provides only 2sec time granularity (for compatibility with FAT?).
979 =item F<lib/io_udp.t>
981 It never terminates, apparently some bug in storing the last socket from
982 which we obtained a message.
986 =head2 Installing the built perl
988 If you haven't yet moved perl.dll onto LIBPATH, do it now.
994 It would put the generated files into needed locations. Manually put
995 F<perl.exe>, F<perl__.exe> and F<perl___.exe> to a location on your
996 PATH, F<perl.dll> to a location on your LIBPATH.
1000 make cmdscripts INSTALLCMDDIR=d:/ir/on/path
1002 to convert perl utilities to F<.cmd> files and put them on
1003 PATH. You need to put F<.EXE>-utilities on path manually. They are
1004 installed in C<$prefix/bin>, here C<$prefix> is what you gave to
1005 F<Configure>, see L<Making>.
1007 =head2 C<a.out>-style build
1009 Proceed as above, but make F<perl_.exe> (see L<"perl_.exe">) by
1018 Manually put F<perl_.exe> to a location on your PATH.
1020 Since C<perl_> has the extensions prebuilt, it does not suffer from
1021 the I<dynamic extensions + fork()> syndrome, thus the failing tests
1024 Failed Test Status Wstat Total Fail Failed List of failed
1025 ---------------------------------------------------------------
1026 io/fs.t 26 11 42.31% 2-5, 7-11, 18, 25
1027 op/stat.t 56 5 8.93% 3-4, 20, 35, 39
1028 Failed 2/118 test scripts, 98.31% okay. 16/2445 subtests failed, 99.35% okay.
1030 B<Note.> The build process for C<perl_> I<does not know> about all the
1031 dependencies, so you should make sure that anything is up-to-date,
1040 =head2 Some C</> became C<\> in pdksh.
1042 You have a very old pdksh. See L<Prerequisites>.
1044 =head2 C<'errno'> - unresolved external
1046 You do not have MT-safe F<db.lib>. See L<Prerequisites>.
1048 =head2 Problems with tr or sed
1050 reported with very old version of tr and sed.
1052 =head2 Some problem (forget which ;-)
1054 You have an older version of F<perl.dll> on your LIBPATH, which
1055 broke the build of extensions.
1057 =head2 Library ... not found
1059 You did not run C<omflibs>. See L<Prerequisites>.
1061 =head2 Segfault in make
1063 You use an old version of GNU make. See L<Prerequisites>.
1065 =head2 op/sprintf test failure
1067 This can result from a bug in emx sprintf which was fixed in 0.9d fix 03.
1069 =head1 Specific (mis)features of OS/2 port
1071 =head2 C<setpriority>, C<getpriority>
1073 Note that these functions are compatible with *nix, not with the older
1074 ports of '94 - 95. The priorities are absolute, go from 32 to -95,
1075 lower is quicker. 0 is the default priority.
1079 Multi-argument form of C<system()> allows an additional numeric
1080 argument. The meaning of this argument is described in
1083 =head2 C<extproc> on the first line
1085 If the first chars of a script are C<"extproc ">, this line is treated
1086 as C<#!>-line, thus all the switches on this line are processed (twice
1087 if script was started via cmd.exe).
1089 =head2 Additional modules:
1091 L<OS2::Process>, L<OS2::REXX>, L<OS2::PrfDB>, L<OS2::ExtAttr>. These
1092 modules provide access to additional numeric argument for C<system>
1093 and to the list of the running processes,
1094 to DLLs having functions with REXX signature and to REXX runtime, to
1095 OS/2 databases in the F<.INI> format, and to Extended Attributes.
1097 Two additional extensions by Andreas Kaiser, C<OS2::UPM>, and
1098 C<OS2::FTP>, are included into my ftp directory, mirrored on CPAN.
1100 =head2 Prebuilt methods:
1104 =item C<File::Copy::syscopy>
1106 used by C<File::Copy::copy>, see L<File::Copy>.
1108 =item C<DynaLoader::mod2fname>
1110 used by C<DynaLoader> for DLL name mangling.
1112 =item C<Cwd::current_drive()>
1116 =item C<Cwd::sys_chdir(name)>
1118 leaves drive as it is.
1120 =item C<Cwd::change_drive(name)>
1123 =item C<Cwd::sys_is_absolute(name)>
1125 means has drive letter and is_rooted.
1127 =item C<Cwd::sys_is_rooted(name)>
1129 means has leading C<[/\\]> (maybe after a drive-letter:).
1131 =item C<Cwd::sys_is_relative(name)>
1133 means changes with current dir.
1135 =item C<Cwd::sys_cwd(name)>
1137 Interface to cwd from EMX. Used by C<Cwd::cwd>.
1139 =item C<Cwd::sys_abspath(name, dir)>
1141 Really really odious function to implement. Returns absolute name of
1142 file which would have C<name> if CWD were C<dir>. C<Dir> defaults to the
1145 =item C<Cwd::extLibpath([type])>
1147 Get current value of extended library search path. If C<type> is
1148 present and I<true>, works with END_LIBPATH, otherwise with
1151 =item C<Cwd::extLibpath_set( path [, type ] )>
1153 Set current value of extended library search path. If C<type> is
1154 present and I<true>, works with END_LIBPATH, otherwise with
1159 (Note that some of these may be moved to different libraries -
1169 Since L<flock(3)> is present in EMX, but is not functional, it is
1170 emulated by perl. To disable the emulations, set environment variable
1171 C<USE_PERL_FLOCK=0>.
1175 Here is the list of things which may be "broken" on
1176 EMX (from EMX docs):
1182 The functions L<recvmsg(3)>, L<sendmsg(3)>, and L<socketpair(3)> are not
1187 L<sock_init(3)> is not required and not implemented.
1191 L<flock(3)> is not yet implemented (dummy function). (Perl has a workaround.)
1195 L<kill(3)>: Special treatment of PID=0, PID=1 and PID=-1 is not implemented.
1203 waitpid() is not implemented for negative values of PID.
1207 Note that C<kill -9> does not work with the current version of EMX.
1211 Since F<sh.exe> is used for globing (see L<perlfunc/glob>), the bugs
1212 of F<sh.exe> plague perl as well.
1214 In particular, uppercase letters do not work in C<[...]>-patterns with
1219 =head2 Modifications
1221 Perl modifies some standard C library calls in the following ways:
1227 C<my_popen> uses F<sh.exe> if shell is required, cf. L<"PERL_SH_DIR">.
1231 is created using C<TMP> or C<TEMP> environment variable, via
1236 If the current directory is not writable, file is created using modified
1237 C<tmpnam>, so there may be a race condition.
1241 a dummy implementation.
1245 C<os2_stat> special-cases F</dev/tty> and F</dev/con>.
1249 Since L<flock(3)> is present in EMX, but is not functional, it is
1250 emulated by perl. To disable the emulations, set environment variable
1251 C<USE_PERL_FLOCK=0>.
1257 Because of idiosyncrasies of OS/2 one cannot have all the eggs in the
1258 same basket (though EMX environment tries hard to overcome this
1259 limitations, so the situation may somehow improve). There are 4
1260 executables for Perl provided by the distribution:
1264 The main workhorse. This is a chimera executable: it is compiled as an
1265 C<a.out>-style executable, but is linked with C<omf>-style dynamic
1266 library F<perl.dll>, and with dynamic CRT DLL. This executable is a
1269 It can load perl dynamic extensions, and it can fork(). Unfortunately,
1270 with the current version of EMX it cannot fork() with dynamic
1271 extensions loaded (may be fixed by patches to EMX).
1273 B<Note.> Keep in mind that fork() is needed to open a pipe to yourself.
1277 This is a statically linked C<a.out>-style executable. It can fork(),
1278 but cannot load dynamic Perl extensions. The supplied executable has a
1279 lot of extensions prebuilt, thus there are situations when it can
1280 perform tasks not possible using F<perl.exe>, like fork()ing when
1281 having some standard extension loaded. This executable is a VIO
1284 B<Note.> A better behaviour could be obtained from C<perl.exe> if it
1285 were statically linked with standard I<Perl extensions>, but
1286 dynamically linked with the I<Perl DLL> and CRT DLL. Then it would
1287 be able to fork() with standard extensions, I<and> would be able to
1288 dynamically load arbitrary extensions. Some changes to Makefiles and
1289 hint files should be necessary to achieve this.
1291 I<This is also the only executable with does not require OS/2.> The
1292 friends locked into C<M$> world would appreciate the fact that this
1293 executable runs under DOS, Win0.3*, Win0.95 and WinNT with an
1294 appropriate extender. See L<"Other OSes">.
1296 =head2 F<perl__.exe>
1298 This is the same executable as F<perl___.exe>, but it is a PM
1301 B<Note.> Usually STDIN, STDERR, and STDOUT of a PM
1302 application are redirected to C<nul>. However, it is possible to see
1303 them if you start C<perl__.exe> from a PM program which emulates a
1304 console window, like I<Shell mode> of Emacs or EPM. Thus it I<is
1305 possible> to use Perl debugger (see L<perldebug>) to debug your PM
1308 This flavor is required if you load extensions which use PM, like
1309 the forthcoming C<Perl/Tk>.
1311 =head2 F<perl___.exe>
1313 This is an C<omf>-style executable which is dynamically linked to
1314 F<perl.dll> and CRT DLL. I know no advantages of this executable
1315 over C<perl.exe>, but it cannot fork() at all. Well, one advantage is
1316 that the build process is not so convoluted as with C<perl.exe>.
1318 It is a VIO application.
1320 =head2 Why strange names?
1322 Since Perl processes the C<#!>-line (cf.
1323 L<perlrun/DESCRIPTION>, L<perlrun/Switches>,
1324 L<perldiag/"Not a perl script">,
1325 L<perldiag/"No Perl script found in input">), it should know when a
1326 program I<is a Perl>. There is some naming convention which allows
1327 Perl to distinguish correct lines from wrong ones. The above names are
1328 almost the only names allowed by this convention which do not contain
1329 digits (which have absolutely different semantics).
1331 =head2 Why dynamic linking?
1333 Well, having several executables dynamically linked to the same huge
1334 library has its advantages, but this would not substantiate the
1335 additional work to make it compile. The reason is stupid-but-quick
1336 "hard" dynamic linking used by OS/2.
1338 The address tables of DLLs are patched only once, when they are
1339 loaded. The addresses of entry points into DLLs are guaranteed to be
1340 the same for all programs which use the same DLL, which reduces the
1341 amount of runtime patching - once DLL is loaded, its code is
1344 While this allows some performance advantages, this makes life
1345 terrible for developers, since the above scheme makes it impossible
1346 for a DLL to be resolved to a symbol in the .EXE file, since this
1347 would need a DLL to have different relocations tables for the
1348 executables which use it.
1350 However, a Perl extension is forced to use some symbols from the perl
1351 executable, say to know how to find the arguments provided on the perl
1352 internal evaluation stack. The solution is that the main code of
1353 interpreter should be contained in a DLL, and the F<.EXE> file just loads
1354 this DLL into memory and supplies command-arguments.
1356 This I<greatly> increases the load time for the application (as well as
1357 the number of problems during compilation). Since interpreter is in a DLL,
1358 the CRT is basically forced to reside in a DLL as well (otherwise
1359 extensions would not be able to use CRT).
1361 =head2 Why chimera build?
1363 Current EMX environment does not allow DLLs compiled using Unixish
1364 C<a.out> format to export symbols for data. This forces C<omf>-style
1365 compile of F<perl.dll>.
1367 Current EMX environment does not allow F<.EXE> files compiled in
1368 C<omf> format to fork(). fork() is needed for exactly three Perl
1373 =item explicit fork()
1381 opening pipes to itself.
1385 While these operations are not questions of life and death, a lot of
1386 useful scripts use them. This forces C<a.out>-style compile of
1392 Here we list environment variables with are either OS/2- and DOS- and
1393 Win*-specific, or are more important under OS/2 than under other OSes.
1395 =head2 C<PERLLIB_PREFIX>
1397 Specific for EMX port. Should have the form
1405 If the beginning of some prebuilt path matches F<path1>, it is
1406 substituted with F<path2>.
1408 Should be used if the perl library is moved from the default
1409 location in preference to C<PERL(5)LIB>, since this would not leave wrong
1410 entries in @INC. Say, if the compiled version of perl looks for @INC
1411 in F<f:/perllib/lib>, and you want to install the library in
1414 set PERLLIB_PREFIX=f:/perllib/lib;h:/opt/gnu
1416 =head2 C<PERL_BADLANG>
1418 If 1, perl ignores setlocale() failing. May be useful with some
1421 =head2 C<PERL_BADFREE>
1423 If 1, perl would not warn of in case of unwarranted free(). May be
1424 useful in conjunction with the module DB_File, since Berkeley DB
1425 memory handling code is buggy.
1427 =head2 C<PERL_SH_DIR>
1429 Specific for EMX port. Gives the directory part of the location for
1432 =head2 C<USE_PERL_FLOCK>
1434 Specific for EMX port. Since L<flock(3)> is present in EMX, but is not
1435 functional, it is emulated by perl. To disable the emulations, set
1436 environment variable C<USE_PERL_FLOCK=0>.
1438 =head2 C<TMP> or C<TEMP>
1440 Specific for EMX port. Used as storage place for temporary files, most
1441 notably C<-e> scripts.
1445 Here we list major changes which could make you by surprise.
1449 C<setpriority> and C<getpriority> are not compatible with earlier
1450 ports by Andreas Kaiser. See C<"setpriority, getpriority">.
1452 =head2 DLL name mangling
1454 With the release 5.003_01 the dynamically loadable libraries
1455 should be rebuilt. In particular, DLLs are now created with the names
1456 which contain a checksum, thus allowing workaround for OS/2 scheme of
1461 As of release 5.003_01 perl is linked to multithreaded CRT
1462 DLL. If perl itself is not compiled multithread-enabled, so will not be perl
1463 malloc(). However, extensions may use multiple thread on their own
1466 Needed to compile C<Perl/Tk> for XFree86-OS/2 out-of-the-box.
1468 =head2 Calls to external programs
1470 Due to a popular demand the perl external program calling has been
1471 changed wrt Andreas Kaiser's port. I<If> perl needs to call an
1472 external program I<via shell>, the F<f:/bin/sh.exe> will be called, or
1473 whatever is the override, see L<"PERL_SH_DIR">.
1475 Thus means that you need to get some copy of a F<sh.exe> as well (I
1476 use one from pdksh). The drive F<F:> above is set up automatically during
1477 the build to a correct value on the builder machine, but is
1478 overridable at runtime,
1480 B<Reasons:> a consensus on C<perl5-porters> was that perl should use
1481 one non-overridable shell per platform. The obvious choices for OS/2
1482 are F<cmd.exe> and F<sh.exe>. Having perl build itself would be impossible
1483 with F<cmd.exe> as a shell, thus I picked up C<sh.exe>. Thus assures almost
1484 100% compatibility with the scripts coming from *nix. As an added benefit
1485 this works as well under DOS if you use DOS-enabled port of pdksh
1486 (see L<"Prerequisites">).
1488 B<Disadvantages:> currently F<sh.exe> of pdksh calls external programs
1489 via fork()/exec(), and there is I<no> functioning exec() on
1490 OS/2. exec() is emulated by EMX by asynchronous call while the caller
1491 waits for child completion (to pretend that the C<pid> did not change). This
1492 means that 1 I<extra> copy of F<sh.exe> is made active via fork()/exec(),
1493 which may lead to some resources taken from the system (even if we do
1494 not count extra work needed for fork()ing).
1496 Note that this a lesser issue now when we do not spawn F<sh.exe>
1497 unless needed (metachars found).
1499 One can always start F<cmd.exe> explicitly via
1501 system 'cmd', '/c', 'mycmd', 'arg1', 'arg2', ...
1503 If you need to use F<cmd.exe>, and do not want to hand-edit thousands of your
1504 scripts, the long-term solution proposed on p5-p is to have a directive
1508 which will override system(), exec(), C<``>, and
1509 C<open(,'...|')>. With current perl you may override only system(),
1510 readpipe() - the explicit version of C<``>, and maybe exec(). The code
1511 will substitute the one-argument call to system() by
1512 C<CORE::system('cmd.exe', '/c', shift)>.
1514 If you have some working code for C<OS2::Cmd>, please send it to me,
1515 I will include it into distribution. I have no need for such a module, so
1518 For the details of the current situation with calling external programs,
1519 see L<Starting OS/2 (and DOS) programs under Perl>.
1525 External scripts may be called by name. Perl will try the same extensions
1526 as when processing B<-S> command-line switch.
1530 =head2 Memory allocation
1532 Perl uses its own malloc() under OS/2 - interpreters are usually malloc-bound
1533 for speed, but perl is not, since its malloc is lightning-fast.
1534 Perl-memory-usage-tuned benchmarks show that Perl's malloc is 5 times quicker
1535 than EMX one. I do not have convincing data about memory footprint, but
1536 a (pretty random) benchmark showed that Perl one is 5% better.
1538 Combination of perl's malloc() and rigid DLL name resolution creates
1539 a special problem with library functions which expect their return value to
1540 be free()d by system's free(). To facilitate extensions which need to call
1541 such functions, system memory-allocation functions are still available with
1542 the prefix C<emx_> added. (Currently only DLL perl has this, it should
1543 propagate to F<perl_.exe> shortly.)
1547 One can build perl with thread support enabled by providing C<-D usethreads>
1548 option to F<Configure>. Currently OS/2 support of threads is very
1551 Most notable problems:
1557 may have a race condition. Needs a reimplementation (in terms of chaining
1558 waiting threads, with linker list stored in per-thread structure?).
1562 has a couple of static variables used in OS/2-specific functions. (Need to be
1563 moved to per-thread structure, or serialized?)
1567 Note that these problems should not discourage experimenting, since they
1568 have a low probability of affecting small programs.
1574 I include 3 extensions by Andreas Kaiser, OS2::REXX, OS2::UPM, and OS2::FTP,
1575 into my ftp directory, mirrored on CPAN. I made
1576 some minor changes needed to compile them by standard tools. I cannot
1577 test UPM and FTP, so I will appreciate your feedback. Other extensions
1578 there are OS2::ExtAttr, OS2::PrfDB for tied access to EAs and .INI
1579 files - and maybe some other extensions at the time you read it.
1581 Note that OS2 perl defines 2 pseudo-extension functions
1582 OS2::Copy::copy and DynaLoader::mod2fname (many more now, see
1583 L<Prebuilt methods>).
1585 The -R switch of older perl is deprecated. If you need to call a REXX code
1586 which needs access to variables, include the call into a REXX compartment
1588 REXX_call {...block...};
1590 Two new functions are supported by REXX code,
1592 REXX_eval_with 'string', REXX_function_name => \&perl_sub_reference;
1594 If you have some other extensions you want to share, send the code to
1595 me. At least two are available: tied access to EA's, and tied access
1596 to system databases.
1600 Ilya Zakharevich, ilya@math.ohio-state.edu