Debian Codegraph @

upstream/debian-unstable/man1/perlos2.1

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