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