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