Debian Codegraph @

upstream/fedora-44/man1/perlos2.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLOS2 1"
61 .TH PERLOS2 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlos2 \- Perl under OS/2, DOS, Win0.3*, Win0.95 and WinNT.
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 One can read this document in the following formats:
71 .PP
72 .Vb 4
73 \& man perlos2
74 \& view perl perlos2
75 \& explorer perlos2.html
76 \& info perlos2
77 .Ve
78 .PP
79 to list some (not all may be available simultaneously), or it may
80 be read \fIas is\fR: either as \fIREADME.os2\fR, or \fIpod/perlos2.pod\fR.
81 .PP
82 To read the \fI.INF\fR version of documentation (\fBvery\fR recommended)
83 outside of OS/2, one needs an IBM\*(Aqs reader (may be available on IBM
84 ftp sites (?) (URL anyone?)) or shipped with PC DOS 7.0 and IBM\*(Aqs
85 Visual Age C++ 3.5.
86 .PP
87 A copy of a Win* viewer is contained in the "Just add OS/2 Warp" package
88 .PP
89 .Vb 1
90 \& ftp://ftp.software.ibm.com/ps/products/os2/tools/jaow/jaow.zip
91 .Ve
92 .PP
93 in \fI?:\eJUST_ADD\eview.exe\fR. This gives one an access to EMX\*(Aqs
94 \&\fI.INF\fR docs as well (text form is available in \fI/emx/doc\fR in
95 EMX\*(Aqs distribution). There is also a different viewer named xview.
96 .PP
97 Note that if you have \fIlynx.exe\fR or \fInetscape.exe\fR installed, you can follow WWW links
98 from this document in \fI.INF\fR format. If you have EMX docs installed
99 correctly, you can follow library links (you need to have \f(CW\*(C`view emxbook\*(C'\fR
100 working by setting \f(CW\*(C`EMXBOOK\*(C'\fR environment variable as it is described
101 in EMX docs).
102 .SH DESCRIPTION
103 .IX Header "DESCRIPTION"
104 .SS Target
105 .IX Subsection "Target"
106 The target is to make OS/2 one of the best supported platform for
107 using/building/developing Perl and \fIPerl applications\fR, as well as
108 make Perl the best language to use under OS/2. The secondary target is
109 to try to make this work under DOS and Win* as well (but not \fBtoo\fR hard).
110 .PP
111 The current state is quite close to this target. Known limitations:
112 .IP \(bu 5
113 Some *nix programs use \fBfork()\fR a lot; with the mostly useful flavors of
114 perl for OS/2 (there are several built simultaneously) this is
115 supported; but some flavors do not support this (e.g., when Perl is
116 called from inside REXX). Using \fBfork()\fR after
117 \&\fIuse\fRing dynamically loading extensions would not work with \fIvery\fR old
118 versions of EMX.
119 .IP \(bu 5
120 You need a separate perl executable \fIperl_\|_.exe\fR (see "perl_\|_.exe")
121 if you want to use PM code in your application (as Perl/Tk or OpenGL
122 Perl modules do) without having a text\-mode window present.
123 .Sp
124 While using the standard \fIperl.exe\fR from a text\-mode window is possible
125 too, I have seen cases when this causes degradation of the system stability.
126 Using \fIperl_\|_.exe\fR avoids such a degradation.
127 .IP \(bu 5
128 There is no simple way to access WPS objects. The only way I know
129 is via \f(CW\*(C`OS2::REXX\*(C'\fR and \f(CW\*(C`SOM\*(C'\fR extensions (see OS2::REXX, SOM).
130 However, we do not have access to
131 convenience methods of Object\-REXX. (Is it possible at all? I know
132 of no Object\-REXX API.) The \f(CW\*(C`SOM\*(C'\fR extension (currently in alpha\-text)
133 may eventually remove this shortcoming; however, due to the fact that
134 DII is not supported by the \f(CW\*(C`SOM\*(C'\fR module, using \f(CW\*(C`SOM\*(C'\fR is not as
135 convenient as one would like it.
136 .PP
137 Please keep this list up\-to\-date by informing me about other items.
138 .SS "Other OSes"
139 .IX Subsection "Other OSes"
140 Since OS/2 port of perl uses a remarkable EMX environment, it can
141 run (and build extensions, and \- possibly \- be built itself) under any
142 environment which can run EMX. The current list is DOS,
143 DOS\-inside\-OS/2, Win0.3*, Win0.95 and WinNT. Out of many perl flavors,
144 only one works, see "\fIperl_.exe\fR".
145 .PP
146 Note that not all features of Perl are available under these
147 environments. This depends on the features the \fIextender\fR \- most
148 probably RSX \- decided to implement.
149 .PP
150 Cf. "Prerequisites".
151 .SS Prerequisites
152 .IX Subsection "Prerequisites"
153 .IP EMX 6
154 .IX Item "EMX"
155 EMX runtime is required (may be substituted by RSX). Note that
156 it is possible to make \fIperl_.exe\fR to run under DOS without any
157 external support by binding \fIemx.exe\fR/\fIrsx.exe\fR to it, see \fBemxbind\fR\|(1).
158 Note that under DOS for best results one should use RSX runtime, which
159 has much more functions working (like \f(CW\*(C`fork\*(C'\fR, \f(CW\*(C`popen\*(C'\fR and so on). In
160 fact RSX is required if there is no VCPI present. Note the
161 RSX requires DPMI. Many implementations of DPMI are known to be very
162 buggy, beware!
163 .Sp
164 Only the latest runtime is supported, currently \f(CW\*(C`0.9d fix 03\*(C'\fR. Perl may run
165 under earlier versions of EMX, but this is not tested.
166 .Sp
167 One can get different parts of EMX from, say
168 .Sp
169 .Vb 2
170 \& ftp://crydee.sai.msu.ru/pub/comp/os/os2/leo/gnu/emx+gcc/
171 \& http://hobbes.nmsu.edu/h\-browse.php?dir=/pub/os2/dev/emx/v0.9d/
172 .Ve
173 .Sp
174 The runtime component should have the name \fIemxrt.zip\fR.
175 .Sp
176 \&\fBNOTE\fR. When using \fIemx.exe\fR/\fIrsx.exe\fR, it is enough to have them on your path. One
177 does not need to specify them explicitly (though this
178 .Sp
179 .Vb 1
180 \& emx perl_.exe \-de 0
181 .Ve
182 .Sp
183 will work as well.)
184 .IP RSX 6
185 .IX Item "RSX"
186 To run Perl on DPMI platforms one needs RSX runtime. This is
187 needed under DOS\-inside\-OS/2, Win0.3*, Win0.95 and WinNT (see
188 "Other OSes"). RSX would not work with VCPI
189 only, as EMX would, it requires DMPI.
190 .Sp
191 Having RSX and the latest \fIsh.exe\fR one gets a fully functional
192 \&\fB*nix\fR\-ish environment under DOS, say, \f(CW\*(C`fork\*(C'\fR, \f(CW\`\`\fR and
193 pipe\-\f(CW\*(C`open\*(C'\fR work. In fact, MakeMaker works (for static build), so one
194 can have Perl development environment under DOS.
195 .Sp
196 One can get RSX from, say
197 .Sp
198 .Vb 2
199 \& http://cd.textfiles.com/hobbesos29804/disk1/EMX09C/
200 \& ftp://crydee.sai.msu.ru/pub/comp/os/os2/leo/gnu/emx+gcc/contrib/
201 .Ve
202 .Sp
203 Contact the author on \f(CW\*(C`[email protected]\-bielefeld.de\*(C'\fR.
204 .Sp
205 The latest \fIsh.exe\fR with DOS hooks is available in
206 .Sp
207 .Vb 1
208 \& http://www.ilyaz.org/software/os2/
209 .Ve
210 .Sp
211 as \fIsh_dos.zip\fR or under similar names starting with \f(CW\*(C`sh\*(C'\fR, \f(CW\*(C`pdksh\*(C'\fR etc.
212 .IP HPFS 6
213 .IX Item "HPFS"
214 Perl does not care about file systems, but the perl library contains
215 many files with long names, so to install it intact one needs a file
216 system which supports long file names.
217 .Sp
218 Note that if you do not plan to build the perl itself, it may be
219 possible to fool EMX to truncate file names. This is not supported,
220 read EMX docs to see how to do it.
221 .IP pdksh 6
222 .IX Item "pdksh"
223 To start external programs with complicated command lines (like with
224 pipes in between, and/or quoting of arguments), Perl uses an external
225 shell. With EMX port such shell should be named \fIsh.exe\fR, and located
226 either in the wired\-in\-during\-compile locations (usually \fIF:/bin\fR),
227 or in configurable location (see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR").
228 .Sp
229 For best results use EMX pdksh. The standard binary (5.2.14 or later) runs
230 under DOS (with "RSX") as well, see
231 .Sp
232 .Vb 1
233 \& http://www.ilyaz.org/software/os2/
234 .Ve
235 .SS "Starting Perl programs under OS/2 (and DOS and...)"
236 .IX Subsection "Starting Perl programs under OS/2 (and DOS and...)"
237 Start your Perl program \fIfoo.pl\fR with arguments \f(CW\*(C`arg1 arg2 arg3\*(C'\fR the
238 same way as on any other platform, by
239 .PP
240 .Vb 1
241 \& perl foo.pl arg1 arg2 arg3
242 .Ve
243 .PP
244 If you want to specify perl options \f(CW\*(C`\-my_opts\*(C'\fR to the perl itself (as
245 opposed to your program), use
246 .PP
247 .Vb 1
248 \& perl \-my_opts foo.pl arg1 arg2 arg3
249 .Ve
250 .PP
251 Alternately, if you use OS/2\-ish shell, like CMD or 4os2, put
252 the following at the start of your perl script:
253 .PP
254 .Vb 1
255 \& extproc perl \-S \-my_opts
256 .Ve
257 .PP
258 rename your program to \fIfoo.cmd\fR, and start it by typing
259 .PP
260 .Vb 1
261 \& foo arg1 arg2 arg3
262 .Ve
263 .PP
264 Note that because of stupid OS/2 limitations the full path of the perl
265 script is not available when you use \f(CW\*(C`extproc\*(C'\fR, thus you are forced to
266 use \f(CW\*(C`\-S\*(C'\fR perl switch, and your script should be on the \f(CW\*(C`PATH\*(C'\fR. As a plus
267 side, if you know a full path to your script, you may still start it
268 with
269 .PP
270 .Vb 1
271 \& perl ../../blah/foo.cmd arg1 arg2 arg3
272 .Ve
273 .PP
274 (note that the argument \f(CW\*(C`\-my_opts\*(C'\fR is taken care of by the \f(CW\*(C`extproc\*(C'\fR line
275 in your script, see \f(CW"extproc"\fR on the first line).
276 .PP
277 To understand what the above \fImagic\fR does, read perl docs about \f(CW\*(C`\-S\*(C'\fR
278 switch \- see perlrun, and cmdref about \f(CW\*(C`extproc\*(C'\fR:
279 .PP
280 .Vb 4
281 \& view perl perlrun
282 \& man perlrun
283 \& view cmdref extproc
284 \& help extproc
285 .Ve
286 .PP
287 or whatever method you prefer.
288 .PP
289 There are also endless possibilities to use \fIexecutable extensions\fR of
290 4os2, \fIassociations\fR of WPS and so on... However, if you use
291 *nixish shell (like \fIsh.exe\fR supplied in the binary distribution),
292 you need to follow the syntax specified in "Command Switches" in perlrun.
293 .PP
294 Note that \fB\-S\fR switch supports scripts with additional extensions
295 \&\fI.cmd\fR, \fI.btm\fR, \fI.bat\fR, \fI.pl\fR as well.
296 .SS "Starting OS/2 (and DOS) programs under Perl"
297 .IX Subsection "Starting OS/2 (and DOS) programs under Perl"
298 This is what \fBsystem()\fR (see "system" in perlfunc), \f(CW\`\`\fR (see
299 "I/O Operators" in perlop), and \fIopen pipe\fR (see "open" in perlfunc)
300 are for. (Avoid \fBexec()\fR (see "exec" in perlfunc) unless you know what you
301 do).
302 .PP
303 Note however that to use some of these operators you need to have a
304 sh\-syntax shell installed (see "Pdksh",
305 "Frequently asked questions"), and perl should be able to find it
306 (see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR").
307 .PP
308 The cases when the shell is used are:
309 .IP 1. 4
310 One\-argument \fBsystem()\fR (see "system" in perlfunc), \fBexec()\fR (see "exec" in perlfunc)
311 with redirection or shell meta\-characters;
312 .IP 2. 4
313 Pipe\-open (see "open" in perlfunc) with the command which contains redirection
314 or shell meta\-characters;
315 .IP 3. 4
316 Backticks \f(CW\`\`\fR (see "I/O Operators" in perlop) with the command which contains
317 redirection or shell meta\-characters;
318 .IP 4. 4
319 If the executable called by \fBsystem()\fR/\fBexec()\fR/pipe\-\fBopen()\fR/\f(CW\`\`\fR is a script
320 with the "magic" \f(CW\*(C`#!\*(C'\fR line or \f(CW\*(C`extproc\*(C'\fR line which specifies shell;
321 .IP 5. 4
322 If the executable called by \fBsystem()\fR/\fBexec()\fR/pipe\-\fBopen()\fR/\f(CW\`\`\fR is a script
323 without "magic" line, and \f(CW$ENV{EXECSHELL}\fR is set to shell;
324 .IP 6. 4
325 If the executable called by \fBsystem()\fR/\fBexec()\fR/pipe\-\fBopen()\fR/\f(CW\`\`\fR is not
326 found (is not this remark obsolete?);
327 .IP 7. 4
328 For globbing (see "glob" in perlfunc, "I/O Operators" in perlop)
329 (obsolete? Perl uses builtin globbing nowadays...).
330 .PP
331 For the sake of speed for a common case, in the above algorithms
332 backslashes in the command name are not considered as shell metacharacters.
333 .PP
334 Perl starts scripts which begin with cookies
335 \&\f(CW\*(C`extproc\*(C'\fR or \f(CW\*(C`#!\*(C'\fR directly, without an intervention of shell. Perl uses the
336 same algorithm to find the executable as \fIpdksh\fR: if the path
337 on \f(CW\*(C`#!\*(C'\fR line does not work, and contains \f(CW\*(C`/\*(C'\fR, then the directory
338 part of the executable is ignored, and the executable
339 is searched in \fI.\fR and on \f(CW\*(C`PATH\*(C'\fR. To find arguments for these scripts
340 Perl uses a different algorithm than \fIpdksh\fR: up to 3 arguments are
341 recognized, and trailing whitespace is stripped.
342 .PP
343 If a script
344 does not contain such a cooky, then to avoid calling \fIsh.exe\fR, Perl uses
345 the same algorithm as \fIpdksh\fR: if \f(CW$ENV{EXECSHELL}\fR is set, the
346 script is given as the first argument to this command, if not set, then
347 \&\f(CW\*(C`$ENV{COMSPEC} /c\*(C'\fR is used (or a hardwired guess if \f(CW$ENV{COMSPEC}\fR is
348 not set).
349 .PP
350 When starting scripts directly, Perl uses exactly the same algorithm as for
351 the search of script given by \fB\-S\fR command\-line option: it will look in
352 the current directory, then on components of \f(CW$ENV{PATH}\fR using the
353 following order of appended extensions: no extension, \fI.cmd\fR, \fI.btm\fR,
354 \&\fI.bat\fR, \fI.pl\fR.
355 .PP
356 Note that Perl will start to look for scripts only if OS/2 cannot start the
357 specified application, thus \f(CW\*(C`system \*(Aqblah\*(Aq\*(C'\fR will not look for a script if
358 there is an executable file \fIblah.exe\fR \fIanywhere\fR on \f(CW\*(C`PATH\*(C'\fR. In
359 other words, \f(CW\*(C`PATH\*(C'\fR is essentially searched twice: once by the OS for
360 an executable, then by Perl for scripts.
361 .PP
362 Note also that executable files on OS/2 can have an arbitrary extension, but
363 \&\fI.exe\fR will be automatically appended if no dot is present in the name. The
364 workaround is as simple as that: since \fIblah.\fR and \fIblah\fR denote the same
365 file (at list on FAT and HPFS file systems), to start an executable residing in
366 file \fIn:/bin/blah\fR (no extension) give an argument \f(CW\*(C`n:/bin/blah.\*(C'\fR (dot
367 appended) to \fBsystem()\fR.
368 .PP
369 Perl will start PM programs from VIO (=text\-mode) Perl process in a
370 separate PM session;
371 the opposite is not true: when you start a non\-PM program from a PM
372 Perl process, Perl would not run it in a separate session. If a separate
373 session is desired, either ensure
374 that shell will be used, as in \f(CW\*(C`system \*(Aqcmd /c myprog\*(Aq\*(C'\fR, or start it using
375 optional arguments to \fBsystem()\fR documented in \f(CW\*(C`OS2::Process\*(C'\fR module. This
376 is considered to be a feature.
377 .SH "Frequently asked questions"
378 .IX Header "Frequently asked questions"
379 .SS """It does not work"""
380 .IX Subsection """It does not work"""
381 Perl binary distributions come with a \fItestperl.cmd\fR script which tries
382 to detect common problems with misconfigured installations. There is a
383 pretty large chance it will discover which step of the installation you
384 managed to goof. \f(CW\*(C`;\-)\*(C'\fR
385 .SS "I cannot run external programs"
386 .IX Subsection "I cannot run external programs"
387 .IP \(bu 4
388 Did you run your programs with \f(CW\*(C`\-w\*(C'\fR switch? See
389 "Starting OS/2 (and DOS) programs under Perl".
390 .IP \(bu 4
391 Do you try to run \fIinternal\fR shell commands, like \f(CW\`copy a b\`\fR
392 (internal for \fIcmd.exe\fR), or \f(CW\`glob a*b\`\fR (internal for ksh)? You
393 need to specify your shell explicitly, like \f(CW\`cmd /c copy a b\`\fR,
394 since Perl cannot deduce which commands are internal to your shell.
395 .SS "I cannot embed perl into my program, or use \fIperl.dll\fP from my program."
396 .IX Subsection "I cannot embed perl into my program, or use perl.dll from my program."
397 .ie n .IP "Is your program EMX\-compiled with ""\-Zmt \-Zcrtdll""?" 4
398 .el .IP "Is your program EMX\-compiled with \f(CW\-Zmt \-Zcrtdll\fR?" 4
399 .IX Item "Is your program EMX-compiled with -Zmt -Zcrtdll?"
400 Well, nowadays Perl DLL should be usable from a differently compiled
401 program too... If you can run Perl code from REXX scripts (see
402 OS2::REXX), then there are some other aspect of interaction which
403 are overlooked by the current hackish code to support
404 differently\-compiled principal programs.
405 .Sp
406 If everything else fails, you need to build a stand\-alone DLL for
407 perl. Contact me, I did it once. Sockets would not work, as a lot of
408 other stuff.
409 .IP "Did you use ExtUtils::Embed?" 4
410 .IX Item "Did you use ExtUtils::Embed?"
411 Some time ago I had reports it does not work. Nowadays it is checked
412 in the Perl test suite, so grep \fI./t\fR subdirectory of the build tree
413 (as well as \fI*.t\fR files in the \fI./lib\fR subdirectory) to find how it
414 should be done "correctly".
415 .ie n .SS "\`\` and pipe\-""open"" do not work under DOS"
416 .el .SS "\f(CW\`\`\fP and pipe\-\f(CWopen\fP do not work under DOS"
417 .IX Subsection "`` and pipe-open do not work under DOS"
418 This may a variant of just "I cannot run external programs", or a
419 deeper problem. Basically: you \fIneed\fR RSX (see "Prerequisites")
420 for these commands to work, and you may need a port of \fIsh.exe\fR which
421 understands command arguments. One of such ports is listed in
422 "Prerequisites" under RSX. Do not forget to set variable
423 "\f(CW\*(C`PERL_SH_DIR\*(C'\fR" as well.
424 .PP
425 DPMI is required for RSX.
426 .ie n .SS "Cannot start ""find.exe ""pattern"" file"""
427 .el .SS "Cannot start \f(CWfind.exe ""pattern"" file\fP"
428 .IX Subsection "Cannot start find.exe ""pattern"" file"
429 The whole idea of the "standard C API to start applications" is that
430 the forms \f(CW\*(C`foo\*(C'\fR and \f(CW"foo"\fR of program arguments are completely
431 interchangeable. \fIfind\fR breaks this paradigm;
432 .PP
433 .Vb 2
434 \& find "pattern" file
435 \& find pattern file
436 .Ve
437 .PP
438 are not equivalent; \fIfind\fR cannot be started directly using the above
439 API. One needs a way to surround the doublequotes in some other
440 quoting construction, necessarily having an extra non\-Unixish shell in
441 between.
442 .PP
443 Use one of
444 .PP
445 .Vb 2
446 \& system \*(Aqcmd\*(Aq, \*(Aq/c\*(Aq, \*(Aqfind "pattern" file\*(Aq;
447 \& \`cmd /c \*(Aqfind "pattern" file\*(Aq\`
448 .Ve
449 .PP
450 This would start \fIfind.exe\fR via \fIcmd.exe\fR via \f(CW\*(C`sh.exe\*(C'\fR via
451 \&\f(CW\*(C`perl.exe\*(C'\fR, but this is a price to pay if you want to use
452 non\-conforming program.
453 .SH INSTALLATION
454 .IX Header "INSTALLATION"
455 .SS "Automatic binary installation"
456 .IX Subsection "Automatic binary installation"
457 The most convenient way of installing a binary distribution of perl is via perl installer
458 \&\fIinstall.exe\fR. Just follow the instructions, and 99% of the
459 installation blues would go away.
460 .PP
461 Note however, that you need to have \fIunzip.exe\fR on your path, and
462 EMX environment \fIrunning\fR. The latter means that if you just
463 installed EMX, and made all the needed changes to \fIConfig.sys\fR,
464 you may need to reboot in between. Check EMX runtime by running
465 .PP
466 .Vb 1
467 \& emxrev
468 .Ve
469 .PP
470 Binary installer also creates a folder on your desktop with some useful
471 objects. If you need to change some aspects of the work of the binary
472 installer, feel free to edit the file \fIPerl.pkg\fR. This may be useful
473 e.g., if you need to run the installer many times and do not want to
474 make many interactive changes in the GUI.
475 .PP
476 \&\fBThings not taken care of by automatic binary installation:\fR
477 .ie n .IP """PERL_BADLANG""" 15
478 .el .IP \f(CWPERL_BADLANG\fR 15
479 .IX Item "PERL_BADLANG"
480 may be needed if you change your codepage \fIafter\fR perl installation,
481 and the new value is not supported by EMX. See "\f(CW\*(C`PERL_BADLANG\*(C'\fR".
482 .ie n .IP """PERL_BADFREE""" 15
483 .el .IP \f(CWPERL_BADFREE\fR 15
484 .IX Item "PERL_BADFREE"
485 see "\f(CW\*(C`PERL_BADFREE\*(C'\fR".
486 .IP \fIConfig.pm\fR 15
487 .IX Item "Config.pm"
488 This file resides somewhere deep in the location you installed your
489 perl library, find it out by
490 .Sp
491 .Vb 1
492 \& perl \-MConfig \-le "print $INC{\*(AqConfig.pm\*(Aq}"
493 .Ve
494 .Sp
495 While most important values in this file \fIare\fR updated by the binary
496 installer, some of them may need to be hand\-edited. I know no such
497 data, please keep me informed if you find one. Moreover, manual
498 changes to the installed version may need to be accompanied by an edit
499 of this file.
500 .PP
501 \&\fBNOTE\fR. Because of a typo the binary installer of 5.00305
502 would install a variable \f(CW\*(C`PERL_SHPATH\*(C'\fR into \fIConfig.sys\fR. Please
503 remove this variable and put \f(CW"PERL_SH_DIR"\fR instead.
504 .SS "Manual binary installation"
505 .IX Subsection "Manual binary installation"
506 As of version 5.00305, OS/2 perl binary distribution comes split
507 into 11 components. Unfortunately, to enable configurable binary
508 installation, the file paths in the zip files are not absolute, but
509 relative to some directory.
510 .PP
511 Note that the extraction with the stored paths is still necessary
512 (default with unzip, specify \f(CW\*(C`\-d\*(C'\fR to pkunzip). However, you
513 need to know where to extract the files. You need also to manually
514 change entries in \fIConfig.sys\fR to reflect where did you put the
515 files. Note that if you have some primitive unzipper (like
516 \&\f(CW\*(C`pkunzip\*(C'\fR), you may get a lot of warnings/errors during
517 unzipping. Upgrade to \f(CW\*(C`(w)unzip\*(C'\fR.
518 .PP
519 Below is the sample of what to do to reproduce the configuration on my
520 machine. In \fIVIEW.EXE\fR you can press \f(CW\*(C`Ctrl\-Insert\*(C'\fR now, and
521 cut\-and\-paste from the resulting file \- created in the directory you
522 started \fIVIEW.EXE\fR from.
523 .PP
524 For each component, we mention environment variables related to each
525 installation directory. Either choose directories to match your
526 values of the variables, or create/append\-to variables to take into
527 account the directories.
528 .IP "Perl VIO and PM executables (dynamically linked)" 3
529 .IX Item "Perl VIO and PM executables (dynamically linked)"
530 .Vb 2
531 \& unzip perl_exc.zip *.exe *.ico \-d f:/emx.add/bin
532 \& unzip perl_exc.zip *.dll \-d f:/emx.add/dll
533 .Ve
534 .Sp
535 (have the directories with \f(CW\*(C`*.exe\*(C'\fR on PATH, and \f(CW\*(C`*.dll\*(C'\fR on
536 LIBPATH);
537 .IP "Perl_ VIO executable (statically linked)" 3
538 .IX Item "Perl_ VIO executable (statically linked)"
539 .Vb 1
540 \& unzip perl_aou.zip \-d f:/emx.add/bin
541 .Ve
542 .Sp
543 (have the directory on PATH);
544 .IP "Executables for Perl utilities" 3
545 .IX Item "Executables for Perl utilities"
546 .Vb 1
547 \& unzip perl_utl.zip \-d f:/emx.add/bin
548 .Ve
549 .Sp
550 (have the directory on PATH);
551 .IP "Main Perl library" 3
552 .IX Item "Main Perl library"
553 .Vb 1
554 \& unzip perl_mlb.zip \-d f:/perllib/lib
555 .Ve
556 .Sp
557 If this directory is exactly the same as the prefix which was compiled
558 into \fIperl.exe\fR, you do not need to change
559 anything. However, for perl to find the library if you use a different
560 path, you need to
561 \&\f(CW\*(C`set PERLLIB_PREFIX\*(C'\fR in \fIConfig.sys\fR, see "\f(CW\*(C`PERLLIB_PREFIX\*(C'\fR".
562 .IP "Additional Perl modules" 3
563 .IX Item "Additional Perl modules"
564 .Vb 1
565 \& unzip perl_ste.zip \-d f:/perllib/lib/site_perl/5.42.1/
566 .Ve
567 .Sp
568 Same remark as above applies. Additionally, if this directory is not
569 one of directories on \f(CW@INC\fR (and \f(CW@INC\fR is influenced by \f(CW\*(C`PERLLIB_PREFIX\*(C'\fR), you
570 need to put this
571 directory and subdirectory \fI./os2\fR in \f(CW\*(C`PERLLIB\*(C'\fR or \f(CW\*(C`PERL5LIB\*(C'\fR
572 variable. Do not use \f(CW\*(C`PERL5LIB\*(C'\fR unless you have it set already. See
573 "ENVIRONMENT" in perl.
574 .Sp
575 \&\fB[Check whether this extraction directory is still applicable with
576 the new directory structure layout!]\fR
577 .IP "Tools to compile Perl modules" 3
578 .IX Item "Tools to compile Perl modules"
579 .Vb 1
580 \& unzip perl_blb.zip \-d f:/perllib/lib
581 .Ve
582 .Sp
583 Same remark as for \fIperl_ste.zip\fR.
584 .IP "Manpages for Perl and utilities" 3
585 .IX Item "Manpages for Perl and utilities"
586 .Vb 1
587 \& unzip perl_man.zip \-d f:/perllib/man
588 .Ve
589 .Sp
590 This directory should better be on \f(CW\*(C`MANPATH\*(C'\fR. You need to have a
591 working \fIman\fR to access these files.
592 .IP "Manpages for Perl modules" 3
593 .IX Item "Manpages for Perl modules"
594 .Vb 1
595 \& unzip perl_mam.zip \-d f:/perllib/man
596 .Ve
597 .Sp
598 This directory should better be on \f(CW\*(C`MANPATH\*(C'\fR. You need to have a
599 working man to access these files.
600 .IP "Source for Perl documentation" 3
601 .IX Item "Source for Perl documentation"
602 .Vb 1
603 \& unzip perl_pod.zip \-d f:/perllib/lib
604 .Ve
605 .Sp
606 This is used by the \f(CW\*(C`perldoc\*(C'\fR program (see perldoc), and may be used to
607 generate HTML documentation usable by WWW browsers, and
608 documentation in zillions of other formats: \f(CW\*(C`info\*(C'\fR, \f(CW\*(C`LaTeX\*(C'\fR,
609 \&\f(CW\*(C`Acrobat\*(C'\fR, \f(CW\*(C`FrameMaker\*(C'\fR and so on. [Use programs such as
610 \&\fIpod2latex\fR etc.]
611 .IP "Perl manual in \fI.INF\fR format" 3
612 .IX Item "Perl manual in .INF format"
613 .Vb 1
614 \& unzip perl_inf.zip \-d d:/os2/book
615 .Ve
616 .Sp
617 This directory should better be on \f(CW\*(C`BOOKSHELF\*(C'\fR.
618 .IP Pdksh 3
619 .IX Item "Pdksh"
620 .Vb 1
621 \& unzip perl_sh.zip \-d f:/bin
622 .Ve
623 .Sp
624 This is used by perl to run external commands which explicitly
625 require shell, like the commands using \fIredirection\fR and \fIshell
626 metacharacters\fR. It is also used instead of explicit \fI/bin/sh\fR.
627 .Sp
628 Set \f(CW\*(C`PERL_SH_DIR\*(C'\fR (see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR") if you move \fIsh.exe\fR from
629 the above location.
630 .Sp
631 \&\fBNote.\fR It may be possible to use some other sh\-compatible shell (untested).
632 .PP
633 After you installed the components you needed and updated the
634 \&\fIConfig.sys\fR correspondingly, you need to hand\-edit
635 \&\fIConfig.pm\fR. This file resides somewhere deep in the location you
636 installed your perl library, find it out by
637 .PP
638 .Vb 1
639 \& perl \-MConfig \-le "print $INC{\*(AqConfig.pm\*(Aq}"
640 .Ve
641 .PP
642 You need to correct all the entries which look like file paths (they
643 currently start with \f(CW\*(C`f:/\*(C'\fR).
644 .SS \fBWarning\fP
645 .IX Subsection "Warning"
646 The automatic and manual perl installation leave precompiled paths
647 inside perl executables. While these paths are overwritable (see
648 "\f(CW\*(C`PERLLIB_PREFIX\*(C'\fR", "\f(CW\*(C`PERL_SH_DIR\*(C'\fR"), some people may prefer
649 binary editing of paths inside the executables/DLLs.
650 .SH "Accessing documentation"
651 .IX Header "Accessing documentation"
652 Depending on how you built/installed perl you may have (otherwise
653 identical) Perl documentation in the following formats:
654 .SS "OS/2 \fI.INF\fP file"
655 .IX Subsection "OS/2 .INF file"
656 Most probably the most convenient form. Under OS/2 view it as
657 .PP
658 .Vb 4
659 \& view perl
660 \& view perl perlfunc
661 \& view perl less
662 \& view perl ExtUtils::MakeMaker
663 .Ve
664 .PP
665 (currently the last two may hit a wrong location, but this may improve
666 soon). Under Win* see "SYNOPSIS".
667 .PP
668 If you want to build the docs yourself, and have \fIOS/2 toolkit\fR, run
669 .PP
670 .Vb 1
671 \& pod2ipf > perl.ipf
672 .Ve
673 .PP
674 in \fI/perllib/lib/pod\fR directory, then
675 .PP
676 .Vb 1
677 \& ipfc /inf perl.ipf
678 .Ve
679 .PP
680 (Expect a lot of errors during the both steps.) Now move it on your
681 BOOKSHELF path.
682 .SS "Plain text"
683 .IX Subsection "Plain text"
684 If you have perl documentation in the source form, perl utilities
685 installed, and GNU groff installed, you may use
686 .PP
687 .Vb 3
688 \& perldoc perlfunc
689 \& perldoc less
690 \& perldoc ExtUtils::MakeMaker
691 .Ve
692 .PP
693 to access the perl documentation in the text form (note that you may get
694 better results using perl manpages).
695 .PP
696 Alternately, try running pod2text on \fI.pod\fR files.
697 .SS Manpages
698 .IX Subsection "Manpages"
699 If you have \fIman\fR installed on your system, and you installed perl
700 manpages, use something like this:
701 .PP
702 .Vb 3
703 \& man perlfunc
704 \& man 3 less
705 \& man ExtUtils.MakeMaker
706 .Ve
707 .PP
708 to access documentation for different components of Perl. Start with
709 .PP
710 .Vb 1
711 \& man perl
712 .Ve
713 .PP
714 Note that dot (\fI.\fR) is used as a package separator for documentation
715 for packages, and as usual, sometimes you need to give the section \- \f(CW3\fR
716 above \- to avoid shadowing by the \fR\f(BIless\fR\fI\|(1) manpage\fR.
717 .PP
718 Make sure that the directory \fBabove\fR the directory with manpages is
719 on our \f(CW\*(C`MANPATH\*(C'\fR, like this
720 .PP
721 .Vb 1
722 \& set MANPATH=c:/man;f:/perllib/man
723 .Ve
724 .PP
725 for Perl manpages in \f(CW\*(C`f:/perllib/man/man1/\*(C'\fR etc.
726 .SS HTML
727 .IX Subsection "HTML"
728 If you have some WWW browser available, installed the Perl
729 documentation in the source form, and Perl utilities, you can build
730 HTML docs. Cd to directory with \fI.pod\fR files, and do like this
731 .PP
732 .Vb 2
733 \& cd f:/perllib/lib/pod
734 \& pod2html
735 .Ve
736 .PP
737 After this you can direct your browser the file \fIperl.html\fR in this
738 directory, and go ahead with reading docs, like this:
739 .PP
740 .Vb 1
741 \& explore file:///f:/perllib/lib/pod/perl.html
742 .Ve
743 .PP
744 Alternatively you may be able to get these docs prebuilt from CPAN.
745 .ie n .SS "GNU ""info"" files"
746 .el .SS "GNU \f(CWinfo\fP files"
747 .IX Subsection "GNU info files"
748 Users of Emacs would appreciate it very much, especially with
749 \&\f(CW\*(C`CPerl\*(C'\fR mode loaded. You need to get latest \f(CW\*(C`pod2texi\*(C'\fR from \f(CW\*(C`CPAN\*(C'\fR,
750 or, alternately, the prebuilt info pages.
751 .SS "\fIPDF\fP files"
752 .IX Subsection "PDF files"
753 for \f(CW\*(C`Acrobat\*(C'\fR are available on CPAN (may be for slightly older version of
754 perl).
755 .ie n .SS """LaTeX"" docs"
756 .el .SS "\f(CWLaTeX\fP docs"
757 .IX Subsection "LaTeX docs"
758 can be constructed using \f(CW\*(C`pod2latex\*(C'\fR.
759 .SH BUILD
760 .IX Header "BUILD"
761 Here we discuss how to build Perl under OS/2.
762 .SS "The short story"
763 .IX Subsection "The short story"
764 Assume that you are a seasoned porter, so are sure that all the necessary
765 tools are already present on your system, and you know how to get the Perl
766 source distribution. Untar it, change to the extract directory, and
767 .PP
768 .Vb 7
769 \& gnupatch \-p0 < os2\ediff.configure
770 \& sh Configure \-des \-D prefix=f:/perllib
771 \& make
772 \& make test
773 \& make install
774 \& make aout_test
775 \& make aout_install
776 .Ve
777 .PP
778 This puts the executables in f:/perllib/bin. Manually move them to the
779 \&\f(CW\*(C`PATH\*(C'\fR, manually move the built \fIperl*.dll\fR to \f(CW\*(C`LIBPATH\*(C'\fR (here for
780 Perl DLL \fI*\fR is a not\-very\-meaningful hex checksum), and run
781 .PP
782 .Vb 1
783 \& make installcmd INSTALLCMDDIR=d:/ir/on/path
784 .Ve
785 .PP
786 Assuming that the \f(CW\*(C`man\*(C'\fR\-files were put on an appropriate location,
787 this completes the installation of minimal Perl system. (The binary
788 distribution contains also a lot of additional modules, and the
789 documentation in INF format.)
790 .PP
791 What follows is a detailed guide through these steps.
792 .SS Prerequisites
793 .IX Subsection "Prerequisites"
794 You need to have the latest EMX development environment, the full
795 GNU tool suite (gawk renamed to awk, and GNU \fIfind.exe\fR
796 earlier on path than the OS/2 \fIfind.exe\fR, same with \fIsort.exe\fR, to
797 check use
798 .PP
799 .Vb 2
800 \& find \-\-version
801 \& sort \-\-version
802 .Ve
803 .PP
804 ). You need the latest version of \fIpdksh\fR installed as \fIsh.exe\fR.
805 .PP
806 Check that you have \fBBSD\fR libraries and headers installed, and \-
807 optionally \- Berkeley DB headers and libraries, and crypt.
808 .PP
809 Possible locations to get the files:
810 .PP
811 .Vb 4
812 \& ftp://ftp.uni\-heidelberg.de/pub/os2/unix/
813 \& http://hobbes.nmsu.edu/h\-browse.php?dir=/pub/os2
814 \& http://cd.textfiles.com/hobbesos29804/disk1/DEV32/
815 \& http://cd.textfiles.com/hobbesos29804/disk1/EMX09C/
816 .Ve
817 .PP
818 It is reported that the following archives contain enough utils to
819 build perl: \fIgnufutil.zip\fR, \fIgnusutil.zip\fR, \fIgnututil.zip\fR, \fIgnused.zip\fR,
820 \&\fIgnupatch.zip\fR, \fIgnuawk.zip\fR, \fIgnumake.zip\fR, \fIgnugrep.zip\fR, \fIbsddev.zip\fR and
821 \&\fIksh527rt.zip\fR (or a later version). Note that all these utilities are
822 known to be available from LEO:
823 .PP
824 .Vb 1
825 \& ftp://crydee.sai.msu.ru/pub/comp/os/os2/leo/gnu/
826 .Ve
827 .PP
828 Note also that the \fIdb.lib\fR and \fIdb.a\fR from the EMX distribution
829 are not suitable for multi\-threaded compile (even single\-threaded
830 flavor of Perl uses multi\-threaded C RTL, for
831 compatibility with XFree86\-OS/2). Get a corrected one from
832 .PP
833 .Vb 1
834 \& http://www.ilyaz.org/software/os2/db_mt.zip
835 .Ve
836 .PP
837 If you have \fIexactly the same version of Perl\fR installed already,
838 make sure that no copies or perl are currently running. Later steps
839 of the build may fail since an older version of \fIperl.dll\fR loaded into
840 memory may be found. Running \f(CW\*(C`make test\*(C'\fR becomes meaningless, since
841 the test are checking a previous build of perl (this situation is detected
842 and reported by \fIos2/os2_base.t\fR test). Do not forget to unset
843 \&\f(CW\*(C`PERL_EMXLOAD_SEC\*(C'\fR in environment.
844 .PP
845 Also make sure that you have \fI/tmp\fR directory on the current drive,
846 and \fI.\fR directory in your \f(CW\*(C`LIBPATH\*(C'\fR. One may try to correct the
847 latter condition by
848 .PP
849 .Vb 1
850 \& set BEGINLIBPATH .\e.
851 .Ve
852 .PP
853 if you use something like \fICMD.EXE\fR or latest versions of
854 \&\fI4os2.exe\fR. (Setting BEGINLIBPATH to just \f(CW\*(C`.\*(C'\fR is ignored by the
855 OS/2 kernel.)
856 .PP
857 Make sure your gcc is good for \f(CW\*(C`\-Zomf\*(C'\fR linking: run \f(CW\*(C`omflibs\*(C'\fR
858 script in \fI/emx/lib\fR directory.
859 .PP
860 Check that you have link386 installed. It comes standard with OS/2,
861 but may be not installed due to customization. If typing
862 .PP
863 .Vb 1
864 \& link386
865 .Ve
866 .PP
867 shows you do not have it, do \fISelective install\fR, and choose \f(CW\*(C`Link
868 object modules\*(C'\fR in \fIOptional system utilities/More\fR. If you get into
869 link386 prompts, press \f(CW\*(C`Ctrl\-C\*(C'\fR to exit.
870 .SS "Getting perl source"
871 .IX Subsection "Getting perl source"
872 You need to fetch the latest perl source (including developers
873 releases). With some probability it is located in
874 .PP
875 .Vb 2
876 \& http://www.cpan.org/src/
877 \& http://www.cpan.org/src/unsupported
878 .Ve
879 .PP
880 If not, you may need to dig in the indices to find it in the directory
881 of the current maintainer.
882 .PP
883 Quick cycle of developers release may break the OS/2 build time to
884 time, looking into
885 .PP
886 .Vb 1
887 \& http://www.cpan.org/ports/os2/
888 .Ve
889 .PP
890 may indicate the latest release which was publicly released by the
891 maintainer. Note that the release may include some additional patches
892 to apply to the current source of perl.
893 .PP
894 Extract it like this
895 .PP
896 .Vb 1
897 \& tar vzxf perl5.00409.tar.gz
898 .Ve
899 .PP
900 You may see a message about errors while extracting \fIConfigure\fR. This is
901 because there is a conflict with a similarly\-named file \fIconfigure\fR.
902 .PP
903 Change to the directory of extraction.
904 .SS "Application of the patches"
905 .IX Subsection "Application of the patches"
906 You need to apply the patches in \fI./os2/diff.*\fR like this:
907 .PP
908 .Vb 1
909 \& gnupatch \-p0 < os2\ediff.configure
910 .Ve
911 .PP
912 You may also need to apply the patches supplied with the binary
913 distribution of perl. It also makes sense to look on the
914 perl5\-porters mailing list for the latest OS/2\-related patches (see
915 <http://www.xray.mpe.mpg.de/mailing\-lists/perl5\-porters/>). Such
916 patches usually contain strings \f(CW\*(C`/os2/\*(C'\fR and \f(CW\*(C`patch\*(C'\fR, so it makes
917 sense looking for these strings.
918 .SS Hand\-editing
919 .IX Subsection "Hand-editing"
920 You may look into the file \fI./hints/os2.sh\fR and correct anything
921 wrong you find there. I do not expect it is needed anywhere.
922 .SS Making
923 .IX Subsection "Making"
924 .Vb 1
925 \& sh Configure \-des \-D prefix=f:/perllib
926 .Ve
927 .PP
928 \&\f(CW\*(C`prefix\*(C'\fR means: where to install the resulting perl library. Giving
929 correct prefix you may avoid the need to specify \f(CW\*(C`PERLLIB_PREFIX\*(C'\fR,
930 see "\f(CW\*(C`PERLLIB_PREFIX\*(C'\fR".
931 .PP
932 \&\fIIgnore the message about missing \fR\f(CI\*(C`ln\*(C'\fR\fI, and about \fR\f(CI\*(C`\-c\*(C'\fR\fI option to
933 tr\fR. The latter is most probably already fixed, if you see it and can trace
934 where the latter spurious warning comes from, please inform me.
935 .PP
936 Now
937 .PP
938 .Vb 1
939 \& make
940 .Ve
941 .PP
942 At some moment the built may die, reporting a \fIversion mismatch\fR or
943 \&\fIunable to run perl\fR. This means that you do not have \fI.\fR in
944 your LIBPATH, so \fIperl.exe\fR cannot find the needed \fIperl67B2.dll\fR (treat
945 these hex digits as line noise). After this is fixed the build
946 should finish without a lot of fuss.
947 .SS Testing
948 .IX Subsection "Testing"
949 Now run
950 .PP
951 .Vb 1
952 \& make test
953 .Ve
954 .PP
955 All tests should succeed (with some of them skipped). If you have the
956 same version of Perl installed, it is crucial that you have \f(CW\*(C`.\*(C'\fR early
957 in your LIBPATH (or in BEGINLIBPATH), otherwise your tests will most
958 probably test the wrong version of Perl.
959 .PP
960 Some tests may generate extra messages similar to
961 .ie n .IP "A lot of ""bad free""" 4
962 .el .IP "A lot of \f(CWbad free\fR" 4
963 .IX Item "A lot of bad free"
964 in database tests related to Berkeley DB. \fIThis should be fixed already.\fR
965 If it persists, you may disable this warnings, see "\f(CW\*(C`PERL_BADFREE\*(C'\fR".
966 .IP "Process terminated by SIGTERM/SIGINT" 4
967 .IX Item "Process terminated by SIGTERM/SIGINT"
968 This is a standard message issued by OS/2 applications. *nix
969 applications die in silence. It is considered to be a feature. One can
970 easily disable this by appropriate sighandlers.
971 .Sp
972 However the test engine bleeds these message to screen in unexpected
973 moments. Two messages of this kind \fIshould\fR be present during
974 testing.
975 .PP
976 To get finer test reports, call
977 .PP
978 .Vb 1
979 \& perl t/harness
980 .Ve
981 .PP
982 The report with \fIio/pipe.t\fR failing may look like this:
983 .PP
984 .Vb 6
985 \& Failed Test Status Wstat Total Fail Failed List of failed
986 \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
987 \& io/pipe.t 12 1 8.33% 9
988 \& 7 tests skipped, plus 56 subtests skipped.
989 \& Failed 1/195 test scripts, 99.49% okay. 1/6542 subtests failed,
990 \& 99.98% okay.
991 .Ve
992 .PP
993 The reasons for most important skipped tests are:
994 .IP \fIop/fs.t\fR 8
995 .IX Item "op/fs.t"
996 .RS 8
997 .PD 0
998 .IP 18 4
999 .IX Item "18"
1000 .PD
1001 Checks \f(CW\*(C`atime\*(C'\fR and \f(CW\*(C`mtime\*(C'\fR of \f(CWstat()\fR \- unfortunately, HPFS
1002 provides only 2sec time granularity (for compatibility with FAT?).
1003 .IP 25 4
1004 .IX Item "25"
1005 Checks \f(CWtruncate()\fR on a filehandle just opened for write \- I do not
1006 know why this should or should not work.
1007 .RE
1008 .RS 8
1009 .RE
1010 .IP \fIop/stat.t\fR 8
1011 .IX Item "op/stat.t"
1012 Checks \f(CWstat()\fR. Tests:
1013 .RS 8
1014 .IP 4 4
1015 .IX Item "4"
1016 Checks \f(CW\*(C`atime\*(C'\fR and \f(CW\*(C`mtime\*(C'\fR of \f(CWstat()\fR \- unfortunately, HPFS
1017 provides only 2sec time granularity (for compatibility with FAT?).
1018 .RE
1019 .RS 8
1020 .RE
1021 .SS "Installing the built perl"
1022 .IX Subsection "Installing the built perl"
1023 If you haven\*(Aqt yet moved \f(CW\*(C`perl*.dll\*(C'\fR onto LIBPATH, do it now.
1024 .PP
1025 Run
1026 .PP
1027 .Vb 1
1028 \& make install
1029 .Ve
1030 .PP
1031 It would put the generated files into needed locations. Manually put
1032 \&\fIperl.exe\fR, \fIperl_\|_.exe\fR and \fIperl_\|_\|_.exe\fR to a location on your
1033 PATH, \fIperl.dll\fR to a location on your LIBPATH.
1034 .PP
1035 Run
1036 .PP
1037 .Vb 1
1038 \& make installcmd INSTALLCMDDIR=d:/ir/on/path
1039 .Ve
1040 .PP
1041 to convert perl utilities to \fI.cmd\fR files and put them on
1042 PATH. You need to put \fI.EXE\fR\-utilities on path manually. They are
1043 installed in \f(CW\*(C`$prefix/bin\*(C'\fR, here \f(CW$prefix\fR is what you gave to
1044 \&\fIConfigure\fR, see "Making".
1045 .PP
1046 If you use \f(CW\*(C`man\*(C'\fR, either move the installed \fI*/man/\fR directories to
1047 your \f(CW\*(C`MANPATH\*(C'\fR, or modify \f(CW\*(C`MANPATH\*(C'\fR to match the location. (One
1048 could have avoided this by providing a correct \f(CW\*(C`manpath\*(C'\fR option to
1049 \&\fI./Configure\fR, or editing \fI./config.sh\fR between configuring and
1050 making steps.)
1051 .ie n .SS """a.out""\-style build"
1052 .el .SS "\f(CWa.out\fP\-style build"
1053 .IX Subsection "a.out-style build"
1054 Proceed as above, but make \fIperl_.exe\fR (see "\fIperl_.exe\fR") by
1055 .PP
1056 .Vb 1
1057 \& make perl_
1058 .Ve
1059 .PP
1060 test and install by
1061 .PP
1062 .Vb 2
1063 \& make aout_test
1064 \& make aout_install
1065 .Ve
1066 .PP
1067 Manually put \fIperl_.exe\fR to a location on your PATH.
1068 .PP
1069 \&\fBNote.\fR The build process for \f(CW\*(C`perl_\*(C'\fR \fIdoes not know\fR about all the
1070 dependencies, so you should make sure that anything is up\-to\-date,
1071 say, by doing
1072 .PP
1073 .Vb 1
1074 \& make perl_dll
1075 .Ve
1076 .PP
1077 first.
1078 .SH "Building a binary distribution"
1079 .IX Header "Building a binary distribution"
1080 [This section provides a short overview only...]
1081 .PP
1082 Building should proceed differently depending on whether the version of perl
1083 you install is already present and used on your system, or is a new version
1084 not yet used. The description below assumes that the version is new, so
1085 installing its DLLs and \fI.pm\fR files will not disrupt the operation of your
1086 system even if some intermediate steps are not yet fully working.
1087 .PP
1088 The other cases require a little bit more convoluted procedures. Below I
1089 suppose that the current version of Perl is \f(CW5.8.2\fR, so the executables are
1090 named accordingly.
1091 .IP 1. 4
1092 Fully build and test the Perl distribution. Make sure that no tests are
1093 failing with \f(CW\*(C`test\*(C'\fR and \f(CW\*(C`aout_test\*(C'\fR targets; fix the bugs in Perl and
1094 the Perl test suite detected by these tests. Make sure that \f(CW\*(C`all_test\*(C'\fR
1095 make target runs as clean as possible. Check that \fIos2/perlrexx.cmd\fR
1096 runs fine.
1097 .IP 2. 4
1098 Fully install Perl, including \f(CW\*(C`installcmd\*(C'\fR target. Copy the generated DLLs
1099 to \f(CW\*(C`LIBPATH\*(C'\fR; copy the numbered Perl executables (as in \fIperl5.8.2.exe\fR)
1100 to \f(CW\*(C`PATH\*(C'\fR; copy \f(CW\*(C`perl_.exe\*(C'\fR to \f(CW\*(C`PATH\*(C'\fR as \f(CW\*(C`perl_5.8.2.exe\*(C'\fR. Think whether
1101 you need backward\-compatibility DLLs. In most cases you do not need to install
1102 them yet; but sometime this may simplify the following steps.
1103 .IP 3. 4
1104 Make sure that \f(CW\*(C`CPAN.pm\*(C'\fR can download files from CPAN. If not, you may need
1105 to manually install \f(CW\*(C`Net::FTP\*(C'\fR.
1106 .IP 4. 4
1107 Install the bundle \f(CW\*(C`Bundle::OS2_default\*(C'\fR
1108 .Sp
1109 .Vb 1
1110 \& perl5.8.2 \-MCPAN \-e "install Bundle::OS2_default" < nul |& tee 00cpan_i_1
1111 .Ve
1112 .Sp
1113 This may take a couple of hours on 1GHz processor (when run the first time).
1114 And this should not be necessarily a smooth procedure. Some modules may not
1115 specify required dependencies, so one may need to repeat this procedure several
1116 times until the results stabilize.
1117 .Sp
1118 .Vb 2
1119 \& perl5.8.2 \-MCPAN \-e "install Bundle::OS2_default" < nul |& tee 00cpan_i_2
1120 \& perl5.8.2 \-MCPAN \-e "install Bundle::OS2_default" < nul |& tee 00cpan_i_3
1121 .Ve
1122 .Sp
1123 Even after they stabilize, some tests may fail.
1124 .Sp
1125 Fix as many discovered bugs as possible. Document all the bugs which are not
1126 fixed, and all the failures with unknown reasons. Inspect the produced logs
1127 \&\fI00cpan_i_1\fR to find suspiciously skipped tests, and other fishy events.
1128 .Sp
1129 Keep in mind that \fIinstallation\fR of some modules may fail too: for example,
1130 the DLLs to update may be already loaded by \fICPAN.pm\fR. Inspect the \f(CW\*(C`install\*(C'\fR
1131 logs (in the example above \fI00cpan_i_1\fR etc) for errors, and install things
1132 manually, as in
1133 .Sp
1134 .Vb 2
1135 \& cd $CPANHOME/.cpan/build/Digest\-MD5\-2.31
1136 \& make install
1137 .Ve
1138 .Sp
1139 Some distributions may fail some tests, but you may want to install them
1140 anyway (as above, or via \f(CW\*(C`force install\*(C'\fR command of \f(CW\*(C`CPAN.pm\*(C'\fR shell\-mode).
1141 .Sp
1142 Since this procedure may take quite a long time to complete, it makes sense
1143 to "freeze" your CPAN configuration by disabling periodic updates of the
1144 local copy of CPAN index: set \f(CW\*(C`index_expire\*(C'\fR to some big value (I use 365),
1145 then save the settings
1146 .Sp
1147 .Vb 2
1148 \& CPAN> o conf index_expire 365
1149 \& CPAN> o conf commit
1150 .Ve
1151 .Sp
1152 Reset back to the default value \f(CW1\fR when you are finished.
1153 .IP 5. 4
1154 When satisfied with the results, rerun the \f(CW\*(C`installcmd\*(C'\fR target. Now you
1155 can copy \f(CW\*(C`perl5.8.2.exe\*(C'\fR to \f(CW\*(C`perl.exe\*(C'\fR, and install the other OMF\-build
1156 executables: \f(CW\*(C`perl_\|_.exe\*(C'\fR etc. They are ready to be used.
1157 .IP 6. 4
1158 Change to the \f(CW\*(C`./pod\*(C'\fR directory of the build tree, download the Perl logo
1159 \&\fICamelGrayBig.BMP\fR, and run
1160 .Sp
1161 .Vb 2
1162 \& ( perl2ipf > perl.ipf ) |& tee 00ipf
1163 \& ipfc /INF perl.ipf |& tee 00inf
1164 .Ve
1165 .Sp
1166 This produces the Perl docs online book \f(CW\*(C`perl.INF\*(C'\fR. Install in on
1167 \&\f(CW\*(C`BOOKSHELF\*(C'\fR path.
1168 .IP 7. 4
1169 Now is the time to build statically linked executable \fIperl_.exe\fR which
1170 includes newly\-installed via \f(CW\*(C`Bundle::OS2_default\*(C'\fR modules. Doing testing
1171 via \f(CW\*(C`CPAN.pm\*(C'\fR is going to be painfully slow, since it statically links
1172 a new executable per XS extension.
1173 .Sp
1174 Here is a possible workaround: create a toplevel \fIMakefile.PL\fR in
1175 \&\fR\f(CI$CPANHOME\fR\fI/.cpan/build/\fR with contents being (compare with "Making
1176 executables with a custom collection of statically loaded extensions")
1177 .Sp
1178 .Vb 2
1179 \& use ExtUtils::MakeMaker;
1180 \& WriteMakefile NAME => \*(Aqdummy\*(Aq;
1181 .Ve
1182 .Sp
1183 execute this as
1184 .Sp
1185 .Vb 2
1186 \& perl_5.8.2.exe Makefile.PL <nul |& tee 00aout_c1
1187 \& make \-k all test <nul |& 00aout_t1
1188 .Ve
1189 .Sp
1190 Again, this procedure should not be absolutely smooth. Some \f(CW\*(C`Makefile.PL\*(C'\fR\*(Aqs
1191 in subdirectories may be buggy, and would not run as "child" scripts. The
1192 interdependency of modules can strike you; however, since non\-XS modules
1193 are already installed, the prerequisites of most modules have a very good
1194 chance to be present.
1195 .Sp
1196 If you discover some glitches, move directories of problematic modules to a
1197 different location; if these modules are non\-XS modules, you may just ignore
1198 them \- they are already installed; the remaining, XS, modules you need to
1199 install manually one by one.
1200 .Sp
1201 After each such removal you need to rerun the \f(CW\*(C`Makefile.PL\*(C'\fR/\f(CW\*(C`make\*(C'\fR process;
1202 usually this procedure converges soon. (But be sure to convert all the
1203 necessary external C libraries from \fI.lib\fR format to \fI.a\fR format: run one of
1204 .Sp
1205 .Vb 2
1206 \& emxaout foo.lib
1207 \& emximp \-o foo.a foo.lib
1208 .Ve
1209 .Sp
1210 whichever is appropriate.) Also, make sure that the DLLs for external
1211 libraries are usable with executables compiled without \f(CW\*(C`\-Zmtd\*(C'\fR options.
1212 .Sp
1213 When you are sure that only a few subdirectories
1214 lead to failures, you may want to add \f(CW\*(C`\-j4\*(C'\fR option to \f(CW\*(C`make\*(C'\fR to speed up
1215 skipping subdirectories with already finished build.
1216 .Sp
1217 When you are satisfied with the results of tests, install the build C libraries
1218 for extensions:
1219 .Sp
1220 .Vb 1
1221 \& make install |& tee 00aout_i
1222 .Ve
1223 .Sp
1224 Now you can rename the file \fI./perl.exe\fR generated during the last phase
1225 to \fIperl_5.8.2.exe\fR; place it on \f(CW\*(C`PATH\*(C'\fR; if there is an inter\-dependency
1226 between some XS modules, you may need to repeat the \f(CW\*(C`test\*(C'\fR/\f(CW\*(C`install\*(C'\fR loop
1227 with this new executable and some excluded modules \- until the procedure
1228 converges.
1229 .Sp
1230 Now you have all the necessary \fI.a\fR libraries for these Perl modules in the
1231 places where Perl builder can find it. Use the perl builder: change to an
1232 empty directory, create a "dummy" \fIMakefile.PL\fR again, and run
1233 .Sp
1234 .Vb 2
1235 \& perl_5.8.2.exe Makefile.PL |& tee 00c
1236 \& make perl |& tee 00p
1237 .Ve
1238 .Sp
1239 This should create an executable \fI./perl.exe\fR with all the statically loaded
1240 extensions built in. Compare the generated \fIperlmain.c\fR files to make sure
1241 that during the iterations the number of loaded extensions only increases.
1242 Rename \fI./perl.exe\fR to \fIperl_5.8.2.exe\fR on \f(CW\*(C`PATH\*(C'\fR.
1243 .Sp
1244 When it converges, you got a functional variant of \fIperl_5.8.2.exe\fR; copy it
1245 to \f(CW\*(C`perl_.exe\*(C'\fR. You are done with generation of the local Perl installation.
1246 .IP 8. 4
1247 Make sure that the installed modules are actually installed in the location
1248 of the new Perl, and are not inherited from entries of \f(CW@INC\fR given for
1249 inheritance from the older versions of Perl: set \f(CW\*(C`PERLLIB_582_PREFIX\*(C'\fR to
1250 redirect the new version of Perl to a new location, and copy the installed
1251 files to this new location. Redo the tests to make sure that the versions of
1252 modules inherited from older versions of Perl are not needed.
1253 .Sp
1254 Actually, the log output of \fBpod2ipf\fR\|(1) during the step 6 gives a very detailed
1255 info about which modules are loaded from which place; so you may use it as
1256 an additional verification tool.
1257 .Sp
1258 Check that some temporary files did not make into the perl install tree.
1259 Run something like this
1260 .Sp
1261 .Vb 1
1262 \& pfind . \-f "!(/\e.(pm|pl|ix|al|h|a|lib|txt|pod|imp|bs|dll|ld|bs|inc|xbm|yml|cgi|uu|e2x|skip|packlist|eg|cfg|html|pub|enc|all|ini|po|pot)$/i or /^\ew+$/") | less
1263 .Ve
1264 .Sp
1265 in the install tree (both top one and \fIsitelib\fR one).
1266 .Sp
1267 Compress all the DLLs with \fIlxlite\fR. The tiny \fI.exe\fR can be compressed with
1268 \&\f(CW\*(C`/c:max\*(C'\fR (the bug only appears when there is a fixup in the last 6 bytes of a
1269 page (?); since the tiny executables are much smaller than a page, the bug
1270 will not hit). Do not compress \f(CW\*(C`perl_.exe\*(C'\fR \- it would not work under DOS.
1271 .IP 9. 4
1272 Now you can generate the binary distribution. This is done by running the
1273 test of the CPAN distribution \f(CW\*(C`OS2::SoftInstaller\*(C'\fR. Tune up the file
1274 \&\fItest.pl\fR to suit the layout of current version of Perl first. Do not
1275 forget to pack the necessary external DLLs accordingly. Include the
1276 description of the bugs and test suite failures you could not fix. Include
1277 the small\-stack versions of Perl executables from Perl build directory.
1278 .Sp
1279 Include \fIperl5.def\fR so that people can relink the perl DLL preserving
1280 the binary compatibility, or can create compatibility DLLs. Include the diff
1281 files (\f(CW\*(C`diff \-pu old new\*(C'\fR) of fixes you did so that people can rebuild your
1282 version. Include \fIperl5.map\fR so that one can use remote debugging.
1283 .IP 10. 4
1284 Share what you did with the other people. Relax. Enjoy fruits of your work.
1285 .IP 11. 4
1286 Brace yourself for thanks, bug reports, hate mail and spam coming as result
1287 of the previous step. No good deed should remain unpunished!
1288 .SH "Building custom \fI.EXE\fP files"
1289 .IX Header "Building custom .EXE files"
1290 The Perl executables can be easily rebuilt at any moment. Moreover, one can
1291 use the \fIembedding\fR interface (see perlembed) to make very customized
1292 executables.
1293 .SS "Making executables with a custom collection of statically loaded extensions"
1294 .IX Subsection "Making executables with a custom collection of statically loaded extensions"
1295 It is a little bit easier to do so while \fIdecreasing\fR the list of statically
1296 loaded extensions. We discuss this case only here.
1297 .IP 1. 4
1298 Change to an empty directory, and create a placeholder <Makefile.PL>:
1299 .Sp
1300 .Vb 2
1301 \& use ExtUtils::MakeMaker;
1302 \& WriteMakefile NAME => \*(Aqdummy\*(Aq;
1303 .Ve
1304 .IP 2. 4
1305 Run it with the flavor of Perl (\fIperl.exe\fR or \fIperl_.exe\fR) you want to
1306 rebuild.
1307 .Sp
1308 .Vb 1
1309 \& perl_ Makefile.PL
1310 .Ve
1311 .IP 3. 4
1312 Ask it to create new Perl executable:
1313 .Sp
1314 .Vb 1
1315 \& make perl
1316 .Ve
1317 .Sp
1318 (you may need to manually add \f(CW\*(C`PERLTYPE=\-DPERL_CORE\*(C'\fR to this commandline on
1319 some versions of Perl; the symptom is that the command\-line globbing does not
1320 work from OS/2 shells with the newly\-compiled executable; check with
1321 .Sp
1322 .Vb 1
1323 \& .\eperl.exe \-wle "print for @ARGV" *
1324 .Ve
1325 .Sp
1326 ).
1327 .IP 4. 4
1328 The previous step created \fIperlmain.c\fR which contains a list of \fBnewXS()\fR calls
1329 near the end. Removing unnecessary calls, and rerunning
1330 .Sp
1331 .Vb 1
1332 \& make perl
1333 .Ve
1334 .Sp
1335 will produce a customized executable.
1336 .SS "Making executables with a custom search\-paths"
1337 .IX Subsection "Making executables with a custom search-paths"
1338 The default perl executable is flexible enough to support most usages.
1339 However, one may want something yet more flexible; for example, one may want
1340 to find Perl DLL relatively to the location of the EXE file; or one may want
1341 to ignore the environment when setting the Perl\-library search patch, etc.
1342 .PP
1343 If you fill comfortable with \fIembedding\fR interface (see perlembed), such
1344 things are easy to do repeating the steps outlined in "Making
1345 executables with a custom collection of statically loaded extensions", and
1346 doing more comprehensive edits to \fBmain()\fR of \fIperlmain.c\fR. The people with
1347 little desire to understand Perl can just rename \fBmain()\fR, and do necessary
1348 modification in a custom \fBmain()\fR which calls the renamed function in appropriate
1349 time.
1350 .PP
1351 However, there is a third way: perl DLL exports the \fBmain()\fR function and several
1352 callbacks to customize the search path. Below is a complete example of a
1353 "Perl loader" which
1354 .IP 1. 4
1355 Looks for Perl DLL in the directory \f(CW\*(C`$exedir/../dll\*(C'\fR;
1356 .IP 2. 4
1357 Prepends the above directory to \f(CW\*(C`BEGINLIBPATH\*(C'\fR;
1358 .IP 3. 4
1359 Fails if the Perl DLL found via \f(CW\*(C`BEGINLIBPATH\*(C'\fR is different from what was
1360 loaded on step 1; e.g., another process could have loaded it from \f(CW\*(C`LIBPATH\*(C'\fR
1361 or from a different value of \f(CW\*(C`BEGINLIBPATH\*(C'\fR. In these cases one needs to
1362 modify the setting of the system so that this other process either does not
1363 run, or loads the DLL from \f(CW\*(C`BEGINLIBPATH\*(C'\fR with \f(CW\*(C`LIBPATHSTRICT=T\*(C'\fR (available
1364 with kernels after September 2000).
1365 .IP 4. 4
1366 Loads Perl library from \f(CW\*(C`$exedir/../dll/lib/\*(C'\fR.
1367 .IP 5. 4
1368 Uses Bourne shell from \f(CW\*(C`$exedir/../dll/sh/ksh.exe\*(C'\fR.
1369 .PP
1370 For best results compile the C file below with the same options as the Perl
1371 DLL. However, a lot of functionality will work even if the executable is not
1372 an EMX applications, e.g., if compiled with
1373 .PP
1374 .Vb 2
1375 \& gcc \-Wall \-DDOSISH \-DOS2=1 \-O2 \-s \-Zomf \-Zsys perl\-starter.c \e
1376 \& \-DPERL_DLL_BASENAME=\e"perl312F\e" \-Zstack 8192 \-Zlinker /PM:VIO
1377 .Ve
1378 .PP
1379 Here is the sample C file:
1380 .PP
1381 .Vb 6
1382 \& #define INCL_DOS
1383 \& #define INCL_NOPM
1384 \& /* These are needed for compile if os2.h includes os2tk.h, not
1385 \& * os2emx.h */
1386 \& #define INCL_DOSPROCESS
1387 \& #include <os2.h>
1388 \&
1389 \& #include "EXTERN.h"
1390 \& #define PERL_IN_MINIPERLMAIN_C
1391 \& #include "perl.h"
1392 \&
1393 \& static char *me;
1394 \& HMODULE handle;
1395 \&
1396 \& static void
1397 \& die_with(char *msg1, char *msg2, char *msg3, char *msg4)
1398 \& {
1399 \& ULONG c;
1400 \& char *s = " error: ";
1401 \&
1402 \& DosWrite(2, me, strlen(me), &c);
1403 \& DosWrite(2, s, strlen(s), &c);
1404 \& DosWrite(2, msg1, strlen(msg1), &c);
1405 \& DosWrite(2, msg2, strlen(msg2), &c);
1406 \& DosWrite(2, msg3, strlen(msg3), &c);
1407 \& DosWrite(2, msg4, strlen(msg4), &c);
1408 \& DosWrite(2, "\er\en", 2, &c);
1409 \& exit(255);
1410 \& }
1411 \&
1412 \& typedef ULONG (*fill_extLibpath_t)(int type,
1413 \& char *pre,
1414 \& char *post,
1415 \& int replace,
1416 \& char *msg);
1417 \& typedef int (*main_t)(int type, char *argv[], char *env[]);
1418 \& typedef int (*handler_t)(void* data, int which);
1419 \&
1420 \& #ifndef PERL_DLL_BASENAME
1421 \& # define PERL_DLL_BASENAME "perl"
1422 \& #endif
1423 \&
1424 \& static HMODULE
1425 \& load_perl_dll(char *basename)
1426 \& {
1427 \& char buf[300], fail[260];
1428 \& STRLEN l, dirl;
1429 \& fill_extLibpath_t f;
1430 \& ULONG rc_fullname;
1431 \& HMODULE handle, handle1;
1432 \&
1433 \& if (_execname(buf, sizeof(buf) \- 13) != 0)
1434 \& die_with("Can\*(Aqt find full path: ", strerror(errno), "", "");
1435 \& /* XXXX Fill \*(Aqme\*(Aq with new value */
1436 \& l = strlen(buf);
1437 \& while (l && buf[l\-1] != \*(Aq/\*(Aq && buf[l\-1] != \*(Aq\e\e\*(Aq)
1438 \& l\-\-;
1439 \& dirl = l \- 1;
1440 \& strcpy(buf + l, basename);
1441 \& l += strlen(basename);
1442 \& strcpy(buf + l, ".dll");
1443 \& if ( (rc_fullname = DosLoadModule(fail, sizeof fail, buf, &handle))
1444 \& != 0
1445 \& && DosLoadModule(fail, sizeof fail, basename, &handle) != 0 )
1446 \& die_with("Can\*(Aqt load DLL ", buf, "", "");
1447 \& if (rc_fullname)
1448 \& return handle; /* was loaded with short name; all is fine */
1449 \& if (DosQueryProcAddr(handle, 0, "fill_extLibpath", (PFN*)&f))
1450 \& die_with(buf,
1451 \& ": DLL exports no symbol ",
1452 \& "fill_extLibpath",
1453 \& "");
1454 \& buf[dirl] = 0;
1455 \& if (f(0 /*BEGINLIBPATH*/, buf /* prepend */, NULL /* append */,
1456 \& 0 /* keep old value */, me))
1457 \& die_with(me, ": prepending BEGINLIBPATH", "", "");
1458 \& if (DosLoadModule(fail, sizeof fail, basename, &handle1) != 0)
1459 \& die_with(me,
1460 \& ": finding perl DLL again via BEGINLIBPATH",
1461 \& "",
1462 \& "");
1463 \& buf[dirl] = \*(Aq\e\e\*(Aq;
1464 \& if (handle1 != handle) {
1465 \& if (DosQueryModuleName(handle1, sizeof(fail), fail))
1466 \& strcpy(fail, "???");
1467 \& die_with(buf,
1468 \& ":\en\etperl DLL via BEGINLIBPATH is different: \en\et",
1469 \& fail,
1470 \& "\en\etYou may need to manipulate global BEGINLIBPATH"
1471 \& " and LIBPATHSTRICT"
1472 \& "\en\etso that the other copy is loaded via"
1473 \& BEGINLIBPATH.");
1474 \& }
1475 \& return handle;
1476 \& }
1477 \&
1478 \& int
1479 \& main(int argc, char **argv, char **env)
1480 \& {
1481 \& main_t f;
1482 \& handler_t h;
1483 \&
1484 \& me = argv[0];
1485 \& /**/
1486 \& handle = load_perl_dll(PERL_DLL_BASENAME);
1487 \&
1488 \& if (DosQueryProcAddr(handle,
1489 \& 0,
1490 \& "Perl_OS2_handler_install",
1491 \& (PFN*)&h))
1492 \& die_with(PERL_DLL_BASENAME,
1493 \& ": DLL exports no symbol ",
1494 \& "Perl_OS2_handler_install",
1495 \& "");
1496 \& if ( !h((void *)"~installprefix", Perlos2_handler_perllib_from)
1497 \& || !h((void *)"~dll", Perlos2_handler_perllib_to)
1498 \& || !h((void *)"~dll/sh/ksh.exe", Perlos2_handler_perl_sh) )
1499 \& die_with(PERL_DLL_BASENAME,
1500 \& ": Can\*(Aqt install @INC manglers",
1501 \& "",
1502 \& "");
1503 \& if (DosQueryProcAddr(handle, 0, "dll_perlmain", (PFN*)&f))
1504 \& die_with(PERL_DLL_BASENAME,
1505 \& ": DLL exports no symbol ",
1506 \& "dll_perlmain",
1507 \& "");
1508 \& return f(argc, argv, env);
1509 \& }
1510 .Ve
1511 .SH "Build FAQ"
1512 .IX Header "Build FAQ"
1513 .ie n .SS "Some ""/"" became ""\e"" in pdksh"
1514 .el .SS "Some \f(CW/\fP became \f(CW\e\fP in pdksh"
1515 .IX Subsection "Some / became in pdksh"
1516 You have a very old pdksh. See "Prerequisites".
1517 .ie n .SS "\*(Aqerrno\*(Aq \- unresolved external"
1518 .el .SS "\f(CW\*(Aqerrno\*(Aq\fP \- unresolved external"
1519 .IX Subsection "'errno' - unresolved external"
1520 You do not have MT\-safe \fIdb.lib\fR. See "Prerequisites".
1521 .SS "Problems with tr or sed"
1522 .IX Subsection "Problems with tr or sed"
1523 reported with very old version of tr and sed.
1524 .SS "Some problem (forget which ;\-)"
1525 .IX Subsection "Some problem (forget which ;-)"
1526 You have an older version of \fIperl.dll\fR on your LIBPATH, which
1527 broke the build of extensions.
1528 .SS "Library ... not found"
1529 .IX Subsection "Library ... not found"
1530 You did not run \f(CW\*(C`omflibs\*(C'\fR. See "Prerequisites".
1531 .SS "Segfault in make"
1532 .IX Subsection "Segfault in make"
1533 You use an old version of GNU make. See "Prerequisites".
1534 .SS "op/sprintf test failure"
1535 .IX Subsection "op/sprintf test failure"
1536 This can result from a bug in emx sprintf which was fixed in 0.9d fix 03.
1537 .SH "Specific (mis)features of OS/2 port"
1538 .IX Header "Specific (mis)features of OS/2 port"
1539 .ie n .SS """setpriority"", ""getpriority"""
1540 .el .SS "\f(CWsetpriority\fP, \f(CWgetpriority\fP"
1541 .IX Subsection "setpriority, getpriority"
1542 Note that these functions are compatible with *nix, not with the older
1543 ports of \*(Aq94 \- 95. The priorities are absolute, go from 32 to \-95,
1544 lower is quicker. 0 is the default priority.
1545 .PP
1546 \&\fBWARNING\fR. Calling \f(CW\*(C`getpriority\*(C'\fR on a non\-existing process could lock
1547 the system before Warp3 fixpak22. Starting with Warp3, Perl will use
1548 a workaround: it aborts \fBgetpriority()\fR if the process is not present.
1549 This is not possible on older versions \f(CW\*(C`2.*\*(C'\fR, and has a race
1550 condition anyway.
1551 .ie n .SS system()
1552 .el .SS \f(CWsystem()\fP
1553 .IX Subsection "system()"
1554 Multi\-argument form of \f(CWsystem()\fR allows an additional numeric
1555 argument. The meaning of this argument is described in
1556 OS2::Process.
1557 .PP
1558 When finding a program to run, Perl first asks the OS to look for executables
1559 on \f(CW\*(C`PATH\*(C'\fR (OS/2 adds extension \fI.exe\fR if no extension is present).
1560 If not found, it looks for a script with possible extensions
1561 added in this order: no extension, \fI.cmd\fR, \fI.btm\fR,
1562 \&\fI.bat\fR, \fI.pl\fR. If found, Perl checks the start of the file for magic
1563 strings \f(CW"#!"\fR and \f(CW"extproc "\fR. If found, Perl uses the rest of the
1564 first line as the beginning of the command line to run this script. The
1565 only mangling done to the first line is extraction of arguments (currently
1566 up to 3), and ignoring of the path\-part of the "interpreter" name if it can\*(Aqt
1567 be found using the full path.
1568 .PP
1569 E.g., \f(CW\*(C`system \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq, \*(Aqbaz\*(Aq\*(C'\fR may lead Perl to finding
1570 \&\fIC:/emx/bin/foo.cmd\fR with the first line being
1571 .PP
1572 .Vb 1
1573 \& extproc /bin/bash \-x \-c
1574 .Ve
1575 .PP
1576 If \fI/bin/bash.exe\fR is not found, then Perl looks for an executable \fIbash.exe\fR on
1577 \&\f(CW\*(C`PATH\*(C'\fR. If found in \fIC:/emx.add/bin/bash.exe\fR, then the above \fBsystem()\fR is
1578 translated to
1579 .PP
1580 .Vb 1
1581 \& system qw(C:/emx.add/bin/bash.exe \-x \-c C:/emx/bin/foo.cmd bar baz)
1582 .Ve
1583 .PP
1584 One additional translation is performed: instead of \fI/bin/sh\fR Perl uses
1585 the hardwired\-or\-customized shell (see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR").
1586 .PP
1587 The above search for "interpreter" is recursive: if \fIbash\fR executable is not
1588 found, but \fIbash.btm\fR is found, Perl will investigate its first line etc.
1589 The only hardwired limit on the recursion depth is implicit: there is a limit
1590 4 on the number of additional arguments inserted before the actual arguments
1591 given to \fBsystem()\fR. In particular, if no additional arguments are specified
1592 on the "magic" first lines, then the limit on the depth is 4.
1593 .PP
1594 If Perl finds that the found executable is of PM type when the
1595 current session is not, it will start the new process in a separate session of
1596 necessary type. Call via \f(CW\*(C`OS2::Process\*(C'\fR to disable this magic.
1597 .PP
1598 \&\fBWARNING\fR. Due to the described logic, you need to explicitly
1599 specify \fI.com\fR extension if needed. Moreover, if the executable
1600 \&\fIperl5.6.1\fR is requested, Perl will not look for \fIperl5.6.1.exe\fR.
1601 [This may change in the future.]
1602 .ie n .SS """extproc"" on the first line"
1603 .el .SS "\f(CWextproc\fP on the first line"
1604 .IX Subsection "extproc on the first line"
1605 If the first chars of a Perl script are \f(CW"extproc "\fR, this line is treated
1606 as \f(CW\*(C`#!\*(C'\fR\-line, thus all the switches on this line are processed (twice
1607 if script was started via cmd.exe). See "DESCRIPTION" in perlrun.
1608 .SS "Additional modules:"
1609 .IX Subsection "Additional modules:"
1610 OS2::Process, OS2::DLL, OS2::REXX, OS2::PrfDB, OS2::ExtAttr. These
1611 modules provide access to additional numeric argument for \f(CW\*(C`system\*(C'\fR
1612 and to the information about the running process,
1613 to DLLs having functions with REXX signature and to the REXX runtime, to
1614 OS/2 databases in the \fI.INI\fR format, and to Extended Attributes.
1615 .PP
1616 Two additional extensions by Andreas Kaiser, \f(CW\*(C`OS2::UPM\*(C'\fR, and
1617 \&\f(CW\*(C`OS2::FTP\*(C'\fR, are included into \f(CW\*(C`ILYAZ\*(C'\fR directory, mirrored on CPAN.
1618 Other OS/2\-related extensions are available too.
1619 .SS "Prebuilt methods:"
1620 .IX Subsection "Prebuilt methods:"
1621 .ie n .IP """File::Copy::syscopy""" 4
1622 .el .IP \f(CWFile::Copy::syscopy\fR 4
1623 .IX Item "File::Copy::syscopy"
1624 used by \f(CW\*(C`File::Copy::copy\*(C'\fR, see File::Copy.
1625 .ie n .IP """DynaLoader::mod2fname""" 4
1626 .el .IP \f(CWDynaLoader::mod2fname\fR 4
1627 .IX Item "DynaLoader::mod2fname"
1628 used by \f(CW\*(C`DynaLoader\*(C'\fR for DLL name mangling.
1629 .ie n .IP Cwd::current_drive() 4
1630 .el .IP \f(CWCwd::current_drive()\fR 4
1631 .IX Item "Cwd::current_drive()"
1632 Self explanatory.
1633 .ie n .IP Cwd::sys_chdir(name) 4
1634 .el .IP \f(CWCwd::sys_chdir(name)\fR 4
1635 .IX Item "Cwd::sys_chdir(name)"
1636 leaves drive as it is.
1637 .ie n .IP Cwd::change_drive(name) 4
1638 .el .IP \f(CWCwd::change_drive(name)\fR 4
1639 .IX Item "Cwd::change_drive(name)"
1640 changes the "current" drive.
1641 .ie n .IP Cwd::sys_is_absolute(name) 4
1642 .el .IP \f(CWCwd::sys_is_absolute(name)\fR 4
1643 .IX Item "Cwd::sys_is_absolute(name)"
1644 means has drive letter and is_rooted.
1645 .ie n .IP Cwd::sys_is_rooted(name) 4
1646 .el .IP \f(CWCwd::sys_is_rooted(name)\fR 4
1647 .IX Item "Cwd::sys_is_rooted(name)"
1648 means has leading \f(CW\*(C`[/\e\e]\*(C'\fR (maybe after a drive\-letter:).
1649 .ie n .IP Cwd::sys_is_relative(name) 4
1650 .el .IP \f(CWCwd::sys_is_relative(name)\fR 4
1651 .IX Item "Cwd::sys_is_relative(name)"
1652 means changes with current dir.
1653 .ie n .IP Cwd::sys_cwd(name) 4
1654 .el .IP \f(CWCwd::sys_cwd(name)\fR 4
1655 .IX Item "Cwd::sys_cwd(name)"
1656 Interface to cwd from EMX. Used by \f(CW\*(C`Cwd::cwd\*(C'\fR.
1657 .ie n .IP """Cwd::sys_abspath(name, dir)""" 4
1658 .el .IP "\f(CWCwd::sys_abspath(name, dir)\fR" 4
1659 .IX Item "Cwd::sys_abspath(name, dir)"
1660 Really really odious function to implement. Returns absolute name of
1661 file which would have \f(CW\*(C`name\*(C'\fR if CWD were \f(CW\*(C`dir\*(C'\fR. \f(CW\*(C`Dir\*(C'\fR defaults to the
1662 current dir.
1663 .ie n .IP Cwd::extLibpath([type]) 4
1664 .el .IP \f(CWCwd::extLibpath([type])\fR 4
1665 .IX Item "Cwd::extLibpath([type])"
1666 Get current value of extended library search path. If \f(CW\*(C`type\*(C'\fR is
1667 present and positive, works with \f(CW\*(C`END_LIBPATH\*(C'\fR, if negative, works
1668 with \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, otherwise with \f(CW\*(C`BEGIN_LIBPATH\*(C'\fR.
1669 .ie n .IP """Cwd::extLibpath_set( path [, type ] )""" 4
1670 .el .IP "\f(CWCwd::extLibpath_set( path [, type ] )\fR" 4
1671 .IX Item "Cwd::extLibpath_set( path [, type ] )"
1672 Set current value of extended library search path. If \f(CW\*(C`type\*(C'\fR is
1673 present and positive, works with <END_LIBPATH>, if negative, works
1674 with \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, otherwise with \f(CW\*(C`BEGIN_LIBPATH\*(C'\fR.
1675 .ie n .IP """OS2::Error(do_harderror,do_exception)""" 4
1676 .el .IP \f(CWOS2::Error(do_harderror,do_exception)\fR 4
1677 .IX Item "OS2::Error(do_harderror,do_exception)"
1678 Returns \f(CW\*(C`undef\*(C'\fR if it was not called yet, otherwise bit 1 is
1679 set if on the previous call do_harderror was enabled, bit
1680 2 is set if on previous call do_exception was enabled.
1681 .Sp
1682 This function enables/disables error popups associated with
1683 hardware errors (Disk not ready etc.) and software exceptions.
1684 .Sp
1685 I know of no way to find out the state of popups \fIbefore\fR the first call
1686 to this function.
1687 .ie n .IP OS2::Errors2Drive(drive) 4
1688 .el .IP \f(CWOS2::Errors2Drive(drive)\fR 4
1689 .IX Item "OS2::Errors2Drive(drive)"
1690 Returns \f(CW\*(C`undef\*(C'\fR if it was not called yet, otherwise return false if errors
1691 were not requested to be written to a hard drive, or the drive letter if
1692 this was requested.
1693 .Sp
1694 This function may redirect error popups associated with hardware errors
1695 (Disk not ready etc.) and software exceptions to the file POPUPLOG.OS2 at
1696 the root directory of the specified drive. Overrides \fBOS2::Error()\fR specified
1697 by individual programs. Given argument undef will disable redirection.
1698 .Sp
1699 Has global effect, persists after the application exits.
1700 .Sp
1701 I know of no way to find out the state of redirection of popups to the disk
1702 \&\fIbefore\fR the first call to this function.
1703 .IP \fBOS2::SysInfo()\fR 4
1704 .IX Item "OS2::SysInfo()"
1705 Returns a hash with system information. The keys of the hash are
1706 .Sp
1707 .Vb 8
1708 \& MAX_PATH_LENGTH, MAX_TEXT_SESSIONS, MAX_PM_SESSIONS,
1709 \& MAX_VDM_SESSIONS, BOOT_DRIVE, DYN_PRI_VARIATION,
1710 \& MAX_WAIT, MIN_SLICE, MAX_SLICE, PAGE_SIZE,
1711 \& VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION,
1712 \& MS_COUNT, TIME_LOW, TIME_HIGH, TOTPHYSMEM, TOTRESMEM,
1713 \& TOTAVAILMEM, MAXPRMEM, MAXSHMEM, TIMER_INTERVAL,
1714 \& MAX_COMP_LENGTH, FOREGROUND_FS_SESSION,
1715 \& FOREGROUND_PROCESS
1716 .Ve
1717 .IP \fBOS2::BootDrive()\fR 4
1718 .IX Item "OS2::BootDrive()"
1719 Returns a letter without colon.
1720 .ie n .IP "OS2::MorphPM(serve), OS2::UnMorphPM(serve)" 4
1721 .el .IP "\f(CWOS2::MorphPM(serve)\fR, \f(CWOS2::UnMorphPM(serve)\fR" 4
1722 .IX Item "OS2::MorphPM(serve), OS2::UnMorphPM(serve)"
1723 Transforms the current application into a PM application and back.
1724 The argument true means that a real message loop is going to be served.
1725 \&\fBOS2::MorphPM()\fR returns the PM message queue handle as an integer.
1726 .Sp
1727 See "Centralized management of resources" for additional details.
1728 .ie n .IP OS2::Serve_Messages(force) 4
1729 .el .IP \f(CWOS2::Serve_Messages(force)\fR 4
1730 .IX Item "OS2::Serve_Messages(force)"
1731 Fake on\-demand retrieval of outstanding PM messages. If \f(CW\*(C`force\*(C'\fR is false,
1732 will not dispatch messages if a real message loop is known to
1733 be present. Returns number of messages retrieved.
1734 .Sp
1735 Dies with "QUITing..." if WM_QUIT message is obtained.
1736 .ie n .IP """OS2::Process_Messages(force [, cnt])""" 4
1737 .el .IP "\f(CWOS2::Process_Messages(force [, cnt])\fR" 4
1738 .IX Item "OS2::Process_Messages(force [, cnt])"
1739 Retrieval of PM messages until window creation/destruction.
1740 If \f(CW\*(C`force\*(C'\fR is false, will not dispatch messages if a real message loop
1741 is known to be present.
1742 .Sp
1743 Returns change in number of windows. If \f(CW\*(C`cnt\*(C'\fR is given,
1744 it is incremented by the number of messages retrieved.
1745 .Sp
1746 Dies with "QUITing..." if WM_QUIT message is obtained.
1747 .ie n .IP """OS2::_control87(new,mask)""" 4
1748 .el .IP \f(CWOS2::_control87(new,mask)\fR 4
1749 .IX Item "OS2::_control87(new,mask)"
1750 the same as \fB_control87\fR\|(3) of EMX. Takes integers as arguments, returns
1751 the previous coprocessor control word as an integer. Only bits in \f(CW\*(C`new\*(C'\fR which
1752 are present in \f(CW\*(C`mask\*(C'\fR are changed in the control word.
1753 .IP \fBOS2::get_control87()\fR 4
1754 .IX Item "OS2::get_control87()"
1755 gets the coprocessor control word as an integer.
1756 .ie n .IP """OS2::set_control87_em(new=MCW_EM,mask=MCW_EM)""" 4
1757 .el .IP \f(CWOS2::set_control87_em(new=MCW_EM,mask=MCW_EM)\fR 4
1758 .IX Item "OS2::set_control87_em(new=MCW_EM,mask=MCW_EM)"
1759 The variant of \fBOS2::_control87()\fR with default values good for
1760 handling exception mask: if no \f(CW\*(C`mask\*(C'\fR, uses exception mask part of \f(CW\*(C`new\*(C'\fR
1761 only. If no \f(CW\*(C`new\*(C'\fR, disables all the floating point exceptions.
1762 .Sp
1763 See "Misfeatures" for details.
1764 .ie n .IP """OS2::DLLname([how [, \e&xsub]])""" 4
1765 .el .IP "\f(CWOS2::DLLname([how [, \e&xsub]])\fR" 4
1766 .IX Item "OS2::DLLname([how [, &xsub]])"
1767 Gives the information about the Perl DLL or the DLL containing the C
1768 function bound to by \f(CW&xsub\fR. The meaning of \f(CW\*(C`how\*(C'\fR is: default (2):
1769 full name; 0: handle; 1: module name.
1770 .PP
1771 (Note that some of these may be moved to different libraries \-
1772 eventually).
1773 .SS "Prebuilt variables:"
1774 .IX Subsection "Prebuilt variables:"
1775 .ie n .IP $OS2::emx_rev 4
1776 .el .IP \f(CW$OS2::emx_rev\fR 4
1777 .IX Item "$OS2::emx_rev"
1778 numeric value is the same as _emx_rev of EMX, a string value the same
1779 as _emx_vprt (similar to \f(CW\*(C`0.9c\*(C'\fR).
1780 .ie n .IP $OS2::emx_env 4
1781 .el .IP \f(CW$OS2::emx_env\fR 4
1782 .IX Item "$OS2::emx_env"
1783 same as _emx_env of EMX, a number similar to 0x8001.
1784 .ie n .IP $OS2::os_ver 4
1785 .el .IP \f(CW$OS2::os_ver\fR 4
1786 .IX Item "$OS2::os_ver"
1787 a number \f(CW\*(C`OS_MAJOR + 0.001 * OS_MINOR\*(C'\fR.
1788 .ie n .IP $OS2::is_aout 4
1789 .el .IP \f(CW$OS2::is_aout\fR 4
1790 .IX Item "$OS2::is_aout"
1791 true if the Perl library was compiled in AOUT format.
1792 .ie n .IP $OS2::can_fork 4
1793 .el .IP \f(CW$OS2::can_fork\fR 4
1794 .IX Item "$OS2::can_fork"
1795 true if the current executable is an AOUT EMX executable, so Perl can
1796 fork. Do not use this, use the portable check for
1797 \&\f(CW$Config::Config\fR{dfork}.
1798 .ie n .IP $OS2::nsyserror 4
1799 .el .IP \f(CW$OS2::nsyserror\fR 4
1800 .IX Item "$OS2::nsyserror"
1801 This variable (default is 1) controls whether to enforce the contents
1802 of $^E to start with \f(CW\*(C`SYS0003\*(C'\fR\-like id. If set to 0, then the string
1803 value of $^E is what is available from the OS/2 message file. (Some
1804 messages in this file have an \f(CW\*(C`SYS0003\*(C'\fR\-like id prepended, some not.)
1805 .SS Misfeatures
1806 .IX Subsection "Misfeatures"
1807 .IP \(bu 4
1808 Since \fBflock\fR\|(3) is present in EMX, but is not functional, it is
1809 emulated by perl. To disable the emulations, set environment variable
1810 \&\f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
1811 .IP \(bu 4
1812 Here is the list of things which may be "broken" on
1813 EMX (from EMX docs):
1814 .RS 4
1815 .IP \(bu 4
1816 The functions \fBrecvmsg\fR\|(3), \fBsendmsg\fR\|(3), and \fBsocketpair\fR\|(3) are not
1817 implemented.
1818 .IP \(bu 4
1819 \&\fBsock_init\fR\|(3) is not required and not implemented.
1820 .IP \(bu 4
1821 \&\fBflock\fR\|(3) is not yet implemented (dummy function). (Perl has a workaround.)
1822 .IP \(bu 4
1823 \&\fBkill\fR\|(3): Special treatment of PID=0, PID=1 and PID=\-1 is not implemented.
1824 .IP \(bu 4
1825 \&\fBwaitpid\fR\|(3):
1826 .Sp
1827 .Vb 3
1828 \& WUNTRACED
1829 \& Not implemented.
1830 \& waitpid() is not implemented for negative values of PID.
1831 .Ve
1832 .RE
1833 .RS 4
1834 .Sp
1835 Note that \f(CW\*(C`kill \-9\*(C'\fR does not work with the current version of EMX.
1836 .RE
1837 .IP \(bu 4
1838 See "Text\-mode filehandles".
1839 .IP \(bu 4
1840 Unix\-domain sockets on OS/2 live in a pseudo\-file\-system \f(CW\*(C`/sockets/...\*(C'\fR.
1841 To avoid a failure to create a socket with a name of a different form,
1842 \&\f(CW"/socket/"\fR is prepended to the socket name (unless it starts with this
1843 already).
1844 .Sp
1845 This may lead to problems later in case the socket is accessed via the
1846 "usual" file\-system calls using the "initial" name.
1847 .IP \(bu 4
1848 Apparently, IBM used a compiler (for some period of time around \*(Aq95?) which
1849 changes FP mask right and left. This is not \fIthat\fR bad for IBM\*(Aqs
1850 programs, but the same compiler was used for DLLs which are used with
1851 general\-purpose applications. When these DLLs are used, the state of
1852 floating\-point flags in the application is not predictable.
1853 .Sp
1854 What is much worse, some DLLs change the floating point flags when in
1855 \&\fB_DLLInitTerm()\fR (e.g., \fITCP32IP\fR). This means that even if you do not \fIcall\fR
1856 any function in the DLL, just the act of loading this DLL will reset your
1857 flags. What is worse, the same compiler was used to compile some HOOK DLLs.
1858 Given that HOOK dlls are executed in the context of \fIall\fR the applications
1859 in the system, this means a complete unpredictability of floating point
1860 flags on systems using such HOOK DLLs. E.g., \fIGAMESRVR.DLL\fR of \fBDIVE\fR
1861 origin changes the floating point flags on each write to the TTY of a VIO
1862 (windowed text\-mode) applications.
1863 .Sp
1864 Some other (not completely debugged) situations when FP flags change include
1865 some video drivers (?), and some operations related to creation of the windows.
1866 People who code \fBOpenGL\fR may have more experience on this.
1867 .Sp
1868 Perl is generally used in the situation when all the floating\-point
1869 exceptions are ignored, as is the default under EMX. If they are not ignored,
1870 some benign Perl programs would get a \f(CW\*(C`SIGFPE\*(C'\fR and would die a horrible death.
1871 .Sp
1872 To circumvent this, Perl uses two hacks. They help against \fIone\fR type of
1873 damage only: FP flags changed when loading a DLL.
1874 .Sp
1875 One of the hacks is to disable floating point exceptions on Perl startup (as
1876 is the default with EMX). This helps only with compile\-time\-linked DLLs
1877 changing the flags before \fBmain()\fR had a chance to be called.
1878 .Sp
1879 The other hack is to restore FP flags after a call to \fBdlopen()\fR. This helps
1880 against similar damage done by DLLs \fB_DLLInitTerm()\fR at runtime. Currently
1881 no way to switch these hacks off is provided.
1882 .SS Modifications
1883 .IX Subsection "Modifications"
1884 Perl modifies some standard C library calls in the following ways:
1885 .ie n .IP """popen""" 9
1886 .el .IP \f(CWpopen\fR 9
1887 .IX Item "popen"
1888 \&\f(CW\*(C`my_popen\*(C'\fR uses \fIsh.exe\fR if shell is required, cf. "\f(CW\*(C`PERL_SH_DIR\*(C'\fR".
1889 .ie n .IP """tmpnam""" 9
1890 .el .IP \f(CWtmpnam\fR 9
1891 .IX Item "tmpnam"
1892 is created using \f(CW\*(C`TMP\*(C'\fR or \f(CW\*(C`TEMP\*(C'\fR environment variable, via
1893 \&\f(CW\*(C`tempnam\*(C'\fR.
1894 .ie n .IP """tmpfile""" 9
1895 .el .IP \f(CWtmpfile\fR 9
1896 .IX Item "tmpfile"
1897 If the current directory is not writable, file is created using modified
1898 \&\f(CW\*(C`tmpnam\*(C'\fR, so there may be a race condition.
1899 .ie n .IP """ctermid""" 9
1900 .el .IP \f(CWctermid\fR 9
1901 .IX Item "ctermid"
1902 a dummy implementation.
1903 .ie n .IP """stat""" 9
1904 .el .IP \f(CWstat\fR 9
1905 .IX Item "stat"
1906 \&\f(CW\*(C`os2_stat\*(C'\fR special\-cases \fI/dev/tty\fR and \fI/dev/con\fR.
1907 .ie n .IP """mkdir"", ""rmdir""" 9
1908 .el .IP "\f(CWmkdir\fR, \f(CWrmdir\fR" 9
1909 .IX Item "mkdir, rmdir"
1910 these EMX functions do not work if the path contains a trailing \f(CW\*(C`/\*(C'\fR.
1911 Perl contains a workaround for this.
1912 .ie n .IP """flock""" 9
1913 .el .IP \f(CWflock\fR 9
1914 .IX Item "flock"
1915 Since \fBflock\fR\|(3) is present in EMX, but is not functional, it is
1916 emulated by perl. To disable the emulations, set environment variable
1917 \&\f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
1918 .SS "Identifying DLLs"
1919 .IX Subsection "Identifying DLLs"
1920 All the DLLs built with the current versions of Perl have ID strings
1921 identifying the name of the extension, its version, and the version
1922 of Perl required for this DLL. Run \f(CW\*(C`bldlevel DLL\-name\*(C'\fR to find this
1923 info.
1924 .SS "Centralized management of resources"
1925 .IX Subsection "Centralized management of resources"
1926 Since to call certain OS/2 API one needs to have a correctly initialized
1927 \&\f(CW\*(C`Win\*(C'\fR subsystem, OS/2\-specific extensions may require getting \f(CW\*(C`HAB\*(C'\fRs and
1928 \&\f(CW\*(C`HMQ\*(C'\fRs. If an extension would do it on its own, another extension could
1929 fail to initialize.
1930 .PP
1931 Perl provides a centralized management of these resources:
1932 .ie n .IP """HAB""" 4
1933 .el .IP \f(CWHAB\fR 4
1934 .IX Item "HAB"
1935 To get the HAB, the extension should call \f(CW\*(C`hab = perl_hab_GET()\*(C'\fR in C. After
1936 this call is performed, \f(CW\*(C`hab\*(C'\fR may be accessed as \f(CW\*(C`Perl_hab\*(C'\fR. There is
1937 no need to release the HAB after it is used.
1938 .Sp
1939 If by some reasons \fIperl.h\fR cannot be included, use
1940 .Sp
1941 .Vb 1
1942 \& extern int Perl_hab_GET(void);
1943 .Ve
1944 .Sp
1945 instead.
1946 .ie n .IP """HMQ""" 4
1947 .el .IP \f(CWHMQ\fR 4
1948 .IX Item "HMQ"
1949 There are two cases:
1950 .RS 4
1951 .IP \(bu 4
1952 the extension needs an \f(CW\*(C`HMQ\*(C'\fR only because some API will not work otherwise.
1953 Use \f(CW\*(C`serve = 0\*(C'\fR below.
1954 .IP \(bu 4
1955 the extension needs an \f(CW\*(C`HMQ\*(C'\fR since it wants to engage in a PM event loop.
1956 Use \f(CW\*(C`serve = 1\*(C'\fR below.
1957 .RE
1958 .RS 4
1959 .Sp
1960 To get an \f(CW\*(C`HMQ\*(C'\fR, the extension should call \f(CW\*(C`hmq = perl_hmq_GET(serve)\*(C'\fR in C.
1961 After this call is performed, \f(CW\*(C`hmq\*(C'\fR may be accessed as \f(CW\*(C`Perl_hmq\*(C'\fR.
1962 .Sp
1963 To signal to Perl that HMQ is not needed any more, call
1964 \&\f(CWperl_hmq_UNSET(serve)\fR. Perl process will automatically morph/unmorph itself
1965 into/from a PM process if HMQ is needed/not\-needed. Perl will automatically
1966 enable/disable \f(CW\*(C`WM_QUIT\*(C'\fR message during shutdown if the message queue is
1967 served/not\-served.
1968 .Sp
1969 \&\fBNOTE\fR. If during a shutdown there is a message queue which did not disable
1970 WM_QUIT, and which did not process the received WM_QUIT message, the
1971 shutdown will be automatically cancelled. Do not call \f(CWperl_hmq_GET(1)\fR
1972 unless you are going to process messages on an orderly basis.
1973 .RE
1974 .IP "Treating errors reported by OS/2 API" 4
1975 .IX Item "Treating errors reported by OS/2 API"
1976 There are two principal conventions (it is useful to call them \f(CW\*(C`Dos*\*(C'\fR
1977 and \f(CW\*(C`Win*\*(C'\fR \- though this part of the function signature is not always
1978 determined by the name of the API) of reporting the error conditions
1979 of OS/2 API. Most of \f(CW\*(C`Dos*\*(C'\fR APIs report the error code as the result
1980 of the call (so 0 means success, and there are many types of errors).
1981 Most of \f(CW\*(C`Win*\*(C'\fR API report success/fail via the result being
1982 \&\f(CW\*(C`TRUE\*(C'\fR/\f(CW\*(C`FALSE\*(C'\fR; to find the reason for the failure one should call
1983 \&\fBWinGetLastError()\fR API.
1984 .Sp
1985 Some \f(CW\*(C`Win*\*(C'\fR entry points also overload a "meaningful" return value
1986 with the error indicator; having a 0 return value indicates an error.
1987 Yet some other \f(CW\*(C`Win*\*(C'\fR entry points overload things even more, and 0
1988 return value may mean a successful call returning a valid value 0, as
1989 well as an error condition; in the case of a 0 return value one should
1990 call \fBWinGetLastError()\fR API to distinguish a successful call from a
1991 failing one.
1992 .Sp
1993 By convention, all the calls to OS/2 API should indicate their
1994 failures by resetting $^E. All the Perl\-accessible functions which
1995 call OS/2 API may be broken into two classes: some \fBdie()\fRs when an API
1996 error is encountered, the other report the error via a false return
1997 value (of course, this does not concern Perl\-accessible functions
1998 which \fIexpect\fR a failure of the OS/2 API call, having some workarounds
1999 coded).
2000 .Sp
2001 Obviously, in the situation of the last type of the signature of an OS/2
2002 API, it is must more convenient for the users if the failure is
2003 indicated by \fBdie()\fRing: one does not need to check $^E to know that
2004 something went wrong. If, however, this solution is not desirable by
2005 some reason, the code in question should reset $^E to 0 before making
2006 this OS/2 API call, so that the caller of this Perl\-accessible
2007 function has a chance to distinguish a success\-but\-0\-return value from
2008 a failure. (One may return undef as an alternative way of reporting
2009 an error.)
2010 .Sp
2011 The macros to simplify this type of error propagation are
2012 .RS 4
2013 .ie n .IP CheckOSError(expr) 4
2014 .el .IP \f(CWCheckOSError(expr)\fR 4
2015 .IX Item "CheckOSError(expr)"
2016 Returns true on error, sets $^E. Expects \fBexpr()\fR be a call of
2017 \&\f(CW\*(C`Dos*\*(C'\fR\-style API.
2018 .ie n .IP CheckWinError(expr) 4
2019 .el .IP \f(CWCheckWinError(expr)\fR 4
2020 .IX Item "CheckWinError(expr)"
2021 Returns true on error, sets $^E. Expects \fBexpr()\fR be a call of
2022 \&\f(CW\*(C`Win*\*(C'\fR\-style API.
2023 .ie n .IP SaveWinError(expr) 4
2024 .el .IP \f(CWSaveWinError(expr)\fR 4
2025 .IX Item "SaveWinError(expr)"
2026 Returns \f(CW\*(C`expr\*(C'\fR, sets $^E from \fBWinGetLastError()\fR if \f(CW\*(C`expr\*(C'\fR is false.
2027 .ie n .IP """SaveCroakWinError(expr,die,name1,name2)""" 4
2028 .el .IP \f(CWSaveCroakWinError(expr,die,name1,name2)\fR 4
2029 .IX Item "SaveCroakWinError(expr,die,name1,name2)"
2030 Returns \f(CW\*(C`expr\*(C'\fR, sets $^E from \fBWinGetLastError()\fR if \f(CW\*(C`expr\*(C'\fR is false,
2031 and \fBdie()\fRs if \f(CW\*(C`die\*(C'\fR and $^E are true. The message to die is the
2032 concatenated strings \f(CW\*(C`name1\*(C'\fR and \f(CW\*(C`name2\*(C'\fR, separated by \f(CW": "\fR from
2033 the contents of $^E.
2034 .ie n .IP """WinError_2_Perl_rc""" 4
2035 .el .IP \f(CWWinError_2_Perl_rc\fR 4
2036 .IX Item "WinError_2_Perl_rc"
2037 Sets \f(CW\*(C`Perl_rc\*(C'\fR to the return value of \fBWinGetLastError()\fR.
2038 .ie n .IP """FillWinError""" 4
2039 .el .IP \f(CWFillWinError\fR 4
2040 .IX Item "FillWinError"
2041 Sets \f(CW\*(C`Perl_rc\*(C'\fR to the return value of \fBWinGetLastError()\fR, and sets $^E
2042 to the corresponding value.
2043 .ie n .IP FillOSError(rc) 4
2044 .el .IP \f(CWFillOSError(rc)\fR 4
2045 .IX Item "FillOSError(rc)"
2046 Sets \f(CW\*(C`Perl_rc\*(C'\fR to \f(CW\*(C`rc\*(C'\fR, and sets $^E to the corresponding value.
2047 .RE
2048 .RS 4
2049 .RE
2050 .IP "Loading DLLs and ordinals in DLLs" 4
2051 .IX Item "Loading DLLs and ordinals in DLLs"
2052 Some DLLs are only present in some versions of OS/2, or in some
2053 configurations of OS/2. Some exported entry points are present only
2054 in DLLs shipped with some versions of OS/2. If these DLLs and entry
2055 points were linked directly for a Perl executable/DLL or from a Perl
2056 extensions, this binary would work only with the specified
2057 versions/setups. Even if these entry points were not needed, the
2058 \&\fIload\fR of the executable (or DLL) would fail.
2059 .Sp
2060 For example, many newer useful APIs are not present in OS/2 v2; many
2061 PM\-related APIs require DLLs not available on floppy\-boot setup.
2062 .Sp
2063 To make these calls fail \fIonly when the calls are executed\fR, one
2064 should call these API via a dynamic linking API. There is a subsystem
2065 in Perl to simplify such type of calls. A large number of entry
2066 points available for such linking is provided (see \f(CW\*(C`entries_ordinals\*(C'\fR
2067 \&\- and also \f(CW\*(C`PMWIN_entries\*(C'\fR \- in \fIos2ish.h\fR). These ordinals can be
2068 accessed via the APIs:
2069 .Sp
2070 .Vb 6
2071 \& CallORD(), DeclFuncByORD(), DeclVoidFuncByORD(),
2072 \& DeclOSFuncByORD(), DeclWinFuncByORD(), AssignFuncPByORD(),
2073 \& DeclWinFuncByORD_CACHE(), DeclWinFuncByORD_CACHE_survive(),
2074 \& DeclWinFuncByORD_CACHE_resetError_survive(),
2075 \& DeclWinFunc_CACHE(), DeclWinFunc_CACHE_resetError(),
2076 \& DeclWinFunc_CACHE_survive(), DeclWinFunc_CACHE_resetError_survive()
2077 .Ve
2078 .Sp
2079 See the header files and the C code in the supplied OS/2\-related
2080 modules for the details on usage of these functions.
2081 .Sp
2082 Some of these functions also combine dynaloading semantic with the
2083 error\-propagation semantic discussed above.
2084 .SH "Perl flavors"
2085 .IX Header "Perl flavors"
2086 Because of idiosyncrasies of OS/2 one cannot have all the eggs in the
2087 same basket (though EMX environment tries hard to overcome this
2088 limitations, so the situation may somehow improve). There are 4
2089 executables for Perl provided by the distribution:
2090 .SS \fIperl.exe\fP
2091 .IX Subsection "perl.exe"
2092 The main workhorse. This is a chimera executable: it is compiled as an
2093 \&\f(CW\*(C`a.out\*(C'\fR\-style executable, but is linked with \f(CW\*(C`omf\*(C'\fR\-style dynamic
2094 library \fIperl.dll\fR, and with dynamic CRT DLL. This executable is a
2095 VIO application.
2096 .PP
2097 It can load perl dynamic extensions, and it can \fBfork()\fR.
2098 .PP
2099 \&\fBNote.\fR Keep in mind that \fBfork()\fR is needed to open a pipe to yourself.
2100 .SS \fIperl_.exe\fP
2101 .IX Subsection "perl_.exe"
2102 This is a statically linked \f(CW\*(C`a.out\*(C'\fR\-style executable. It cannot
2103 load dynamic Perl extensions. The executable supplied in binary
2104 distributions has a lot of extensions prebuilt, thus the above restriction is
2105 important only if you use custom\-built extensions. This executable is a VIO
2106 application.
2107 .PP
2108 \&\fIThis is the only executable with does not require OS/2.\fR The
2109 friends locked into \f(CW\*(C`M$\*(C'\fR world would appreciate the fact that this
2110 executable runs under DOS, Win0.3*, Win0.95 and WinNT with an
2111 appropriate extender. See "Other OSes".
2112 .SS \fIperl_\|_.exe\fP
2113 .IX Subsection "perl__.exe"
2114 This is the same executable as \fIperl_\|_\|_.exe\fR, but it is a PM
2115 application.
2116 .PP
2117 \&\fBNote.\fR Usually (unless explicitly redirected during the startup)
2118 STDIN, STDERR, and STDOUT of a PM
2119 application are redirected to \fInul\fR. However, it is possible to \fIsee\fR
2120 them if you start \f(CW\*(C`perl_\|_.exe\*(C'\fR from a PM program which emulates a
2121 console window, like \fIShell mode\fR of Emacs or EPM. Thus it \fIis
2122 possible\fR to use Perl debugger (see perldebug) to debug your PM
2123 application (but beware of the message loop lockups \- this will not
2124 work if you have a message queue to serve, unless you hook the serving
2125 into the \fBgetc()\fR function of the debugger).
2126 .PP
2127 Another way to see the output of a PM program is to run it as
2128 .PP
2129 .Vb 1
2130 \& pm_prog args 2>&1 | cat \-
2131 .Ve
2132 .PP
2133 with a shell \fIdifferent\fR from \fIcmd.exe\fR, so that it does not create
2134 a link between a VIO session and the session of \f(CW\*(C`pm_porg\*(C'\fR. (Such a link
2135 closes the VIO window.) E.g., this works with \fIsh.exe\fR \- or with Perl!
2136 .PP
2137 .Vb 2
2138 \& open P, \*(Aqpm_prog args 2>&1 |\*(Aq or die;
2139 \& print while <P>;
2140 .Ve
2141 .PP
2142 The flavor \fIperl_\|_.exe\fR is required if you want to start your program without
2143 a VIO window present, but not \f(CW\*(C`detach\*(C'\fRed (run \f(CW\*(C`help detach\*(C'\fR for more info).
2144 Very useful for extensions which use PM, like \f(CW\*(C`Perl/Tk\*(C'\fR or \f(CW\*(C`OpenGL\*(C'\fR.
2145 .PP
2146 Note also that the differences between PM and VIO executables are only
2147 in the \fIdefault\fR behaviour. One can start \fIany\fR executable in
2148 \&\fIany\fR kind of session by using the arguments \f(CW\*(C`/fs\*(C'\fR, \f(CW\*(C`/pm\*(C'\fR or
2149 \&\f(CW\*(C`/win\*(C'\fR switches of the command \f(CW\*(C`start\*(C'\fR (of \fICMD.EXE\fR or a similar
2150 shell). Alternatively, one can use the numeric first argument of the
2151 \&\f(CW\*(C`system\*(C'\fR Perl function (see OS2::Process).
2152 .SS \fIperl_\|_\|_.exe\fP
2153 .IX Subsection "perl___.exe"
2154 This is an \f(CW\*(C`omf\*(C'\fR\-style executable which is dynamically linked to
2155 \&\fIperl.dll\fR and CRT DLL. I know no advantages of this executable
2156 over \f(CW\*(C`perl.exe\*(C'\fR, but it cannot \fBfork()\fR at all. Well, one advantage is
2157 that the build process is not so convoluted as with \f(CW\*(C`perl.exe\*(C'\fR.
2158 .PP
2159 It is a VIO application.
2160 .SS "Why strange names?"
2161 .IX Subsection "Why strange names?"
2162 Since Perl processes the \f(CW\*(C`#!\*(C'\fR\-line (cf.
2163 "DESCRIPTION" in perlrun, "Command Switches" in perlrun,
2164 "No Perl script found in input" in perldiag), it should know when a
2165 program \fIis a Perl\fR. There is some naming convention which allows
2166 Perl to distinguish correct lines from wrong ones. The above names are
2167 almost the only names allowed by this convention which do not contain
2168 digits (which have absolutely different semantics).
2169 .SS "Why dynamic linking?"
2170 .IX Subsection "Why dynamic linking?"
2171 Well, having several executables dynamically linked to the same huge
2172 library has its advantages, but this would not substantiate the
2173 additional work to make it compile. The reason is the complicated\-to\-developers
2174 but very quick and convenient\-to\-users "hard" dynamic linking used by OS/2.
2175 .PP
2176 There are two distinctive features of the dyna\-linking model of OS/2:
2177 first, all the references to external functions are resolved at the compile time;
2178 second, there is no runtime fixup of the DLLs after they are loaded into memory.
2179 The first feature is an enormous advantage over other models: it avoids
2180 conflicts when several DLLs used by an application export entries with
2181 the same name. In such cases "other" models of dyna\-linking just choose
2182 between these two entry points using some random criterion \- with predictable
2183 disasters as results. But it is the second feature which requires the build
2184 of \fIperl.dll\fR.
2185 .PP
2186 The address tables of DLLs are patched only once, when they are
2187 loaded. The addresses of the entry points into DLLs are guaranteed to be
2188 the same for all the programs which use the same DLL. This removes the
2189 runtime fixup \- once DLL is loaded, its code is read\-only.
2190 .PP
2191 While this allows some (significant?) performance advantages, this makes life
2192 much harder for developers, since the above scheme makes it impossible
2193 for a DLL to be "linked" to a symbol in the \fI.EXE\fR file. Indeed, this
2194 would need a DLL to have different relocations tables for the
2195 (different) executables which use this DLL.
2196 .PP
2197 However, a dynamically loaded Perl extension is forced to use some symbols
2198 from the perl
2199 executable, e.g., to know how to find the arguments to the functions:
2200 the arguments live on the perl
2201 internal evaluation stack. The solution is to put the main code of
2202 the interpreter into a DLL, and make the \fI.EXE\fR file which just loads
2203 this DLL into memory and supplies command\-arguments. The extension DLL
2204 cannot link to symbols in \fI.EXE\fR, but it has no problem linking
2205 to symbols in the \fI.DLL\fR.
2206 .PP
2207 This \fIgreatly\fR increases the load time for the application (as well as
2208 complexity of the compilation). Since interpreter is in a DLL,
2209 the C RTL is basically forced to reside in a DLL as well (otherwise
2210 extensions would not be able to use CRT). There are some advantages if
2211 you use different flavors of perl, such as running \fIperl.exe\fR and
2212 \&\fIperl_\|_.exe\fR simultaneously: they share the memory of \fIperl.dll\fR.
2213 .PP
2214 \&\fBNOTE\fR. There is one additional effect which makes DLLs more wasteful:
2215 DLLs are loaded in the shared memory region, which is a scarse resource
2216 given the 512M barrier of the "standard" OS/2 virtual memory. The code of
2217 \&\fI.EXE\fR files is also shared by all the processes which use the particular
2218 \&\fI.EXE\fR, but they are "shared in the private address space of the process";
2219 this is possible because the address at which different sections
2220 of the \fI.EXE\fR file are loaded is decided at compile\-time, thus all the
2221 processes have these sections loaded at same addresses, and no fixup
2222 of internal links inside the \fI.EXE\fR is needed.
2223 .PP
2224 Since DLLs may be loaded at run time, to have the same mechanism for DLLs
2225 one needs to have the address range of \fIany of the loaded\fR DLLs in the
2226 system to be available \fIin all the processes\fR which did not load a particular
2227 DLL yet. This is why the DLLs are mapped to the shared memory region.
2228 .SS "Why chimera build?"
2229 .IX Subsection "Why chimera build?"
2230 Current EMX environment does not allow DLLs compiled using Unixish
2231 \&\f(CW\*(C`a.out\*(C'\fR format to export symbols for data (or at least some types of
2232 data). This forces \f(CW\*(C`omf\*(C'\fR\-style compile of \fIperl.dll\fR.
2233 .PP
2234 Current EMX environment does not allow \fI.EXE\fR files compiled in
2235 \&\f(CW\*(C`omf\*(C'\fR format to \fBfork()\fR. \fBfork()\fR is needed for exactly three Perl
2236 operations:
2237 .IP \(bu 4
2238 explicit \fBfork()\fR in the script,
2239 .IP \(bu 4
2240 \&\f(CW\*(C`open FH, "|\-"\*(C'\fR
2241 .IP \(bu 4
2242 \&\f(CW\*(C`open FH, "\-|"\*(C'\fR, in other words, opening pipes to itself.
2243 .PP
2244 While these operations are not questions of life and death, they are
2245 needed for a lot of
2246 useful scripts. This forces \f(CW\*(C`a.out\*(C'\fR\-style compile of
2247 \&\fIperl.exe\fR.
2248 .SH ENVIRONMENT
2249 .IX Header "ENVIRONMENT"
2250 Here we list environment variables with are either OS/2\- and DOS\- and
2251 Win*\-specific, or are more important under OS/2 than under other OSes.
2252 .ie n .SS """PERLLIB_PREFIX"""
2253 .el .SS \f(CWPERLLIB_PREFIX\fP
2254 .IX Subsection "PERLLIB_PREFIX"
2255 Specific for EMX port. Should have the form
2256 .PP
2257 .Vb 1
2258 \& path1;path2
2259 .Ve
2260 .PP
2261 or
2262 .PP
2263 .Vb 1
2264 \& path1 path2
2265 .Ve
2266 .PP
2267 If the beginning of some prebuilt path matches \fIpath1\fR, it is
2268 substituted with \fIpath2\fR.
2269 .PP
2270 Should be used if the perl library is moved from the default
2271 location in preference to \f(CW\*(C`PERL(5)LIB\*(C'\fR, since this would not leave wrong
2272 entries in \f(CW@INC\fR. For example, if the compiled version of perl looks for \f(CW@INC\fR
2273 in \fIf:/perllib/lib\fR, and you want to install the library in
2274 \&\fIh:/opt/gnu\fR, do
2275 .PP
2276 .Vb 1
2277 \& set PERLLIB_PREFIX=f:/perllib/lib;h:/opt/gnu
2278 .Ve
2279 .PP
2280 This will cause Perl with the prebuilt \f(CW@INC\fR of
2281 .PP
2282 .Vb 5
2283 \& f:/perllib/lib/5.00553/os2
2284 \& f:/perllib/lib/5.00553
2285 \& f:/perllib/lib/site_perl/5.00553/os2
2286 \& f:/perllib/lib/site_perl/5.00553
2287 \& .
2288 .Ve
2289 .PP
2290 to use the following \f(CW@INC:\fR
2291 .PP
2292 .Vb 5
2293 \& h:/opt/gnu/5.00553/os2
2294 \& h:/opt/gnu/5.00553
2295 \& h:/opt/gnu/site_perl/5.00553/os2
2296 \& h:/opt/gnu/site_perl/5.00553
2297 \& .
2298 .Ve
2299 .ie n .SS """PERL_BADLANG"""
2300 .el .SS \f(CWPERL_BADLANG\fP
2301 .IX Subsection "PERL_BADLANG"
2302 If 0, perl ignores \fBsetlocale()\fR failing. May be useful with some
2303 strange \fIlocale\fRs.
2304 .ie n .SS """PERL_BADFREE"""
2305 .el .SS \f(CWPERL_BADFREE\fP
2306 .IX Subsection "PERL_BADFREE"
2307 If 0, perl would not warn of in case of unwarranted \fBfree()\fR. With older
2308 perls this might be
2309 useful in conjunction with the module DB_File, which was buggy when
2310 dynamically linked and OMF\-built.
2311 .PP
2312 Should not be set with newer Perls, since this may hide some \fIreal\fR problems.
2313 .ie n .SS """PERL_SH_DIR"""
2314 .el .SS \f(CWPERL_SH_DIR\fP
2315 .IX Subsection "PERL_SH_DIR"
2316 Specific for EMX port. Gives the directory part of the location for
2317 \&\fIsh.exe\fR.
2318 .ie n .SS """USE_PERL_FLOCK"""
2319 .el .SS \f(CWUSE_PERL_FLOCK\fP
2320 .IX Subsection "USE_PERL_FLOCK"
2321 Specific for EMX port. Since \fBflock\fR\|(3) is present in EMX, but is not
2322 functional, it is emulated by perl. To disable the emulations, set
2323 environment variable \f(CW\*(C`USE_PERL_FLOCK=0\*(C'\fR.
2324 .ie n .SS """TMP"" or ""TEMP"""
2325 .el .SS "\f(CWTMP\fP or \f(CWTEMP\fP"
2326 .IX Subsection "TMP or TEMP"
2327 Specific for EMX port. Used as storage place for temporary files.
2328 .SH Evolution
2329 .IX Header "Evolution"
2330 Here we list major changes which could make you by surprise.
2331 .SS "Text\-mode filehandles"
2332 .IX Subsection "Text-mode filehandles"
2333 Starting from version 5.8, Perl uses a builtin translation layer for
2334 text\-mode files. This replaces the efficient well\-tested EMX layer by
2335 some code which should be best characterized as a "quick hack".
2336 .PP
2337 In addition to possible bugs and an inability to follow changes to the
2338 translation policy with off/on switches of TERMIO translation, this
2339 introduces a serious incompatible change: before \fBsysread()\fR on
2340 text\-mode filehandles would go through the translation layer, now it
2341 would not.
2342 .SS Priorities
2343 .IX Subsection "Priorities"
2344 \&\f(CW\*(C`setpriority\*(C'\fR and \f(CW\*(C`getpriority\*(C'\fR are not compatible with earlier
2345 ports by Andreas Kaiser. See "setpriority, getpriority".
2346 .SS "DLL name mangling: pre 5.6.2"
2347 .IX Subsection "DLL name mangling: pre 5.6.2"
2348 With the release 5.003_01 the dynamically loadable libraries
2349 should be rebuilt when a different version of Perl is compiled. In particular,
2350 DLLs (including \fIperl.dll\fR) are now created with the names
2351 which contain a checksum, thus allowing workaround for OS/2 scheme of
2352 caching DLLs.
2353 .PP
2354 It may be possible to code a simple workaround which would
2355 .IP \(bu 4
2356 find the old DLLs looking through the old \f(CW@INC\fR;
2357 .IP \(bu 4
2358 mangle the names according to the scheme of new perl and copy the DLLs to
2359 these names;
2360 .IP \(bu 4
2361 edit the internal \f(CW\*(C`LX\*(C'\fR tables of DLL to reflect the change of the name
2362 (probably not needed for Perl extension DLLs, since the internally coded names
2363 are not used for "specific" DLLs, they used only for "global" DLLs).
2364 .IP \(bu 4
2365 edit the internal \f(CW\*(C`IMPORT\*(C'\fR tables and change the name of the "old"
2366 \&\fIperl????.dll\fR to the "new" \fIperl????.dll\fR.
2367 .SS "DLL name mangling: 5.6.2 and beyond"
2368 .IX Subsection "DLL name mangling: 5.6.2 and beyond"
2369 In fact mangling of \fIextension\fR DLLs was done due to misunderstanding
2370 of the OS/2 dynaloading model. OS/2 (effectively) maintains two
2371 different tables of loaded DLL:
2372 .IP "Global DLLs" 4
2373 .IX Item "Global DLLs"
2374 those loaded by the base name from \f(CW\*(C`LIBPATH\*(C'\fR; including those
2375 associated at link time;
2376 .IP "specific DLLs" 4
2377 .IX Item "specific DLLs"
2378 loaded by the full name.
2379 .PP
2380 When resolving a request for a global DLL, the table of already\-loaded
2381 specific DLLs is (effectively) ignored; moreover, specific DLLs are
2382 \&\fIalways\fR loaded from the prescribed path.
2383 .PP
2384 There is/was a minor twist which makes this scheme fragile: what to do
2385 with DLLs loaded from
2386 .ie n .IP """BEGINLIBPATH"" and ""ENDLIBPATH""" 4
2387 .el .IP "\f(CWBEGINLIBPATH\fR and \f(CWENDLIBPATH\fR" 4
2388 .IX Item "BEGINLIBPATH and ENDLIBPATH"
2389 (which depend on the process)
2390 .ie n .IP "\fI.\fR from ""LIBPATH""" 4
2391 .el .IP "\fI.\fR from \f(CWLIBPATH\fR" 4
2392 .IX Item ". from LIBPATH"
2393 which \fIeffectively\fR depends on the process (although \f(CW\*(C`LIBPATH\*(C'\fR is the
2394 same for all the processes).
2395 .PP
2396 Unless \f(CW\*(C`LIBPATHSTRICT\*(C'\fR is set to \f(CW\*(C`T\*(C'\fR (and the kernel is after
2397 2000/09/01), such DLLs are considered to be global. When loading a
2398 global DLL it is first looked in the table of already\-loaded global
2399 DLLs. Because of this the fact that one executable loaded a DLL from
2400 \&\f(CW\*(C`BEGINLIBPATH\*(C'\fR and \f(CW\*(C`ENDLIBPATH\*(C'\fR, or \fI.\fR from \f(CW\*(C`LIBPATH\*(C'\fR may affect
2401 \&\fIwhich\fR DLL is loaded when \fIanother\fR executable requests a DLL with
2402 the same name. \fIThis\fR is the reason for version\-specific mangling of
2403 the DLL name for perl DLL.
2404 .PP
2405 Since the Perl extension DLLs are always loaded with the full path,
2406 there is no need to mangle their names in a version\-specific ways:
2407 their directory already reflects the corresponding version of perl,
2408 and \f(CW@INC\fR takes into account binary compatibility with older version.
2409 Starting from \f(CW5.6.2\fR the name mangling scheme is fixed to be the
2410 same as for Perl 5.005_53 (same as in a popular binary release). Thus
2411 new Perls will be able to \fIresolve the names\fR of old extension DLLs
2412 if \f(CW@INC\fR allows finding their directories.
2413 .PP
2414 However, this still does not guarantee that these DLL may be loaded.
2415 The reason is the mangling of the name of the \fIPerl DLL\fR. And since
2416 the extension DLLs link with the Perl DLL, extension DLLs for older
2417 versions would load an older Perl DLL, and would most probably
2418 segfault (since the data in this DLL is not properly initialized).
2419 .PP
2420 There is a partial workaround (which can be made complete with newer
2421 OS/2 kernels): create a forwarder DLL with the same name as the DLL of
2422 the older version of Perl, which forwards the entry points to the
2423 newer Perl\*(Aqs DLL. Make this DLL accessible on (say) the \f(CW\*(C`BEGINLIBPATH\*(C'\fR of
2424 the new Perl executable. When the new executable accesses old Perl\*(Aqs
2425 extension DLLs, they would request the old Perl\*(Aqs DLL by name, get the
2426 forwarder instead, so effectively will link with the currently running
2427 (new) Perl DLL.
2428 .PP
2429 This may break in two ways:
2430 .IP \(bu 4
2431 Old perl executable is started when a new executable is running has
2432 loaded an extension compiled for the old executable (ouph!). In this
2433 case the old executable will get a forwarder DLL instead of the old
2434 perl DLL, so would link with the new perl DLL. While not directly
2435 fatal, it will behave the same as new executable. This beats the whole
2436 purpose of explicitly starting an old executable.
2437 .IP \(bu 4
2438 A new executable loads an extension compiled for the old executable
2439 when an old perl executable is running. In this case the extension
2440 will not pick up the forwarder \- with fatal results.
2441 .PP
2442 With support for \f(CW\*(C`LIBPATHSTRICT\*(C'\fR this may be circumvented \- unless
2443 one of DLLs is started from \fI.\fR from \f(CW\*(C`LIBPATH\*(C'\fR (I do not know
2444 whether \f(CW\*(C`LIBPATHSTRICT\*(C'\fR affects this case).
2445 .PP
2446 \&\fBREMARK\fR. Unless newer kernels allow \fI.\fR in \f(CW\*(C`BEGINLIBPATH\*(C'\fR (older
2447 do not), this mess cannot be completely cleaned. (It turns out that
2448 as of the beginning of 2002, \fI.\fR is not allowed, but \fI.\e.\fR is \- and
2449 it has the same effect.)
2450 .PP
2451 \&\fBREMARK\fR. \f(CW\*(C`LIBPATHSTRICT\*(C'\fR, \f(CW\*(C`BEGINLIBPATH\*(C'\fR and \f(CW\*(C`ENDLIBPATH\*(C'\fR are
2452 not environment variables, although \fIcmd.exe\fR emulates them on \f(CW\*(C`SET
2453 \&...\*(C'\fR lines. From Perl they may be accessed by
2454 Cwd::extLibpath and
2455 Cwd::extLibpath_set.
2456 .SS "DLL forwarder generation"
2457 .IX Subsection "DLL forwarder generation"
2458 Assume that the old DLL is named \fIperlE0AC.dll\fR (as is one for
2459 5.005_53), and the new version is 5.6.1. Create a file
2460 \&\fIperl5shim.def\-leader\fR with
2461 .PP
2462 .Vb 5
2463 \& LIBRARY \*(AqperlE0AC\*(Aq INITINSTANCE TERMINSTANCE
2464 \& DESCRIPTION \*(Aq@#perl5\[email protected]:5.006001#@ Perl module for 5.00553 \-> Perl 5.6.1 forwarder\*(Aq
2465 \& CODE LOADONCALL
2466 \& DATA LOADONCALL NONSHARED MULTIPLE
2467 \& EXPORTS
2468 .Ve
2469 .PP
2470 modifying the versions/names as needed. Run
2471 .PP
2472 .Vb 2
2473 \& perl \-wnle "next if 0../EXPORTS/; print qq( \e"$1\e")
2474 \& if /\e"(\ew+)\e"/" perl5.def >lst
2475 .Ve
2476 .PP
2477 in the Perl build directory (to make the DLL smaller replace perl5.def
2478 with the definition file for the older version of Perl if present).
2479 .PP
2480 .Vb 2
2481 \& cat perl5shim.def\-leader lst >perl5shim.def
2482 \& gcc \-Zomf \-Zdll \-o perlE0AC.dll perl5shim.def \-s \-llibperl
2483 .Ve
2484 .PP
2485 (ignore multiple \f(CW\*(C`warning L4085\*(C'\fR).
2486 .SS Threading
2487 .IX Subsection "Threading"
2488 As of release 5.003_01 perl is linked to multithreaded C RTL
2489 DLL. If perl itself is not compiled multithread\-enabled, so will not be perl\*(Aqs
2490 \&\fBmalloc()\fR. However, extensions may use multiple thread on their own
2491 risk.
2492 .PP
2493 This was needed to compile \f(CW\*(C`Perl/Tk\*(C'\fR for XFree86\-OS/2 out\-of\-the\-box, and
2494 link with DLLs for other useful libraries, which typically are compiled
2495 with \f(CW\*(C`\-Zmt \-Zcrtdll\*(C'\fR.
2496 .SS "Calls to external programs"
2497 .IX Subsection "Calls to external programs"
2498 Due to a popular demand the perl external program calling has been
2499 changed wrt Andreas Kaiser\*(Aqs port. \fIIf\fR perl needs to call an
2500 external program \fIvia shell\fR, the \fIf:/bin/sh.exe\fR will be called, or
2501 whatever is the override, see "\f(CW\*(C`PERL_SH_DIR\*(C'\fR".
2502 .PP
2503 Thus means that you need to get some copy of a \fIsh.exe\fR as well (I
2504 use one from pdksh). The path \fIF:/bin\fR above is set up automatically during
2505 the build to a correct value on the builder machine, but is
2506 overridable at runtime,
2507 .PP
2508 \&\fBReasons:\fR a consensus on \f(CW\*(C`perl5\-porters\*(C'\fR was that perl should use
2509 one non\-overridable shell per platform. The obvious choices for OS/2
2510 are \fIcmd.exe\fR and \fIsh.exe\fR. Having perl build itself would be impossible
2511 with \fIcmd.exe\fR as a shell, thus I picked up \f(CW\*(C`sh.exe\*(C'\fR. This assures almost
2512 100% compatibility with the scripts coming from *nix. As an added benefit
2513 this works as well under DOS if you use DOS\-enabled port of pdksh
2514 (see "Prerequisites").
2515 .PP
2516 \&\fBDisadvantages:\fR currently \fIsh.exe\fR of pdksh calls external programs
2517 via \fBfork()\fR/\fBexec()\fR, and there is \fIno\fR functioning \fBexec()\fR on
2518 OS/2. \fBexec()\fR is emulated by EMX by an asynchronous call while the caller
2519 waits for child completion (to pretend that the \f(CW\*(C`pid\*(C'\fR did not change). This
2520 means that 1 \fIextra\fR copy of \fIsh.exe\fR is made active via \fBfork()\fR/\fBexec()\fR,
2521 which may lead to some resources taken from the system (even if we do
2522 not count extra work needed for \fBfork()\fRing).
2523 .PP
2524 Note that this a lesser issue now when we do not spawn \fIsh.exe\fR
2525 unless needed (metachars found).
2526 .PP
2527 One can always start \fIcmd.exe\fR explicitly via
2528 .PP
2529 .Vb 1
2530 \& system \*(Aqcmd\*(Aq, \*(Aq/c\*(Aq, \*(Aqmycmd\*(Aq, \*(Aqarg1\*(Aq, \*(Aqarg2\*(Aq, ...
2531 .Ve
2532 .PP
2533 If you need to use \fIcmd.exe\fR, and do not want to hand\-edit thousands of your
2534 scripts, the long\-term solution proposed on p5\-p is to have a directive
2535 .PP
2536 .Vb 1
2537 \& use OS2::Cmd;
2538 .Ve
2539 .PP
2540 which will override \fBsystem()\fR, \fBexec()\fR, \f(CW\`\`\fR, and
2541 \&\f(CW\*(C`open(,\*(Aq...|\*(Aq)\*(C'\fR. With current perl you may override only \fBsystem()\fR,
2542 \&\fBreadpipe()\fR \- the explicit version of \f(CW\`\`\fR, and maybe \fBexec()\fR. The code
2543 will substitute the one\-argument call to \fBsystem()\fR by
2544 \&\f(CW\*(C`CORE::system(\*(Aqcmd.exe\*(Aq, \*(Aq/c\*(Aq, shift)\*(C'\fR.
2545 .PP
2546 If you have some working code for \f(CW\*(C`OS2::Cmd\*(C'\fR, please send it to me,
2547 I will include it into distribution. I have no need for such a module, so
2548 cannot test it.
2549 .PP
2550 For the details of the current situation with calling external programs,
2551 see "Starting OS/2 (and DOS) programs under Perl". Set us
2552 mention a couple of features:
2553 .IP \(bu 4
2554 External scripts may be called by their basename. Perl will try the same
2555 extensions as when processing \fB\-S\fR command\-line switch.
2556 .IP \(bu 4
2557 External scripts starting with \f(CW\*(C`#!\*(C'\fR or \f(CW\*(C`extproc \*(C'\fR will be executed directly,
2558 without calling the shell, by calling the program specified on the rest of
2559 the first line.
2560 .SS "Memory allocation"
2561 .IX Subsection "Memory allocation"
2562 Perl uses its own \fBmalloc()\fR under OS/2 \- interpreters are usually malloc\-bound
2563 for speed, but perl is not, since its malloc is lightning\-fast.
2564 Perl\-memory\-usage\-tuned benchmarks show that Perl\*(Aqs malloc is 5 times quicker
2565 than EMX one. I do not have convincing data about memory footprint, but
2566 a (pretty random) benchmark showed that Perl\*(Aqs one is 5% better.
2567 .PP
2568 Combination of perl\*(Aqs \fBmalloc()\fR and rigid DLL name resolution creates
2569 a special problem with library functions which expect their return value to
2570 be \fBfree()\fRd by system\*(Aqs \fBfree()\fR. To facilitate extensions which need to call
2571 such functions, system memory\-allocation functions are still available with
2572 the prefix \f(CW\*(C`emx_\*(C'\fR added. (Currently only DLL perl has this, it should
2573 propagate to \fIperl_.exe\fR shortly.)
2574 .SS Threads
2575 .IX Subsection "Threads"
2576 One can build perl with thread support enabled by providing \f(CW\*(C`\-D usethreads\*(C'\fR
2577 option to \fIConfigure\fR. Currently OS/2 support of threads is very
2578 preliminary.
2579 .PP
2580 Most notable problems:
2581 .ie n .IP """COND_WAIT""" 4
2582 .el .IP \f(CWCOND_WAIT\fR 4
2583 .IX Item "COND_WAIT"
2584 may have a race condition (but probably does not due to edge\-triggered
2585 nature of OS/2 Event semaphores). (Needs a reimplementation (in terms of chaining
2586 waiting threads, with the linked list stored in per\-thread structure?)?)
2587 .IP \fIos2.c\fR 4
2588 .IX Item "os2.c"
2589 has a couple of static variables used in OS/2\-specific functions. (Need to be
2590 moved to per\-thread structure, or serialized?)
2591 .PP
2592 Note that these problems should not discourage experimenting, since they
2593 have a low probability of affecting small programs.
2594 .SH BUGS
2595 .IX Header "BUGS"
2596 This description is not updated often (since 5.6.1?), see \fI./os2/Changes\fR
2597 for more info.
2598 .SH AUTHOR
2599 .IX Header "AUTHOR"
2600 Ilya Zakharevich, [email protected]
2601 .SH "SEE ALSO"
2602 .IX Header "SEE ALSO"
2603 \&\fBperl\fR\|(1).