1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see pod/perlpod.pod) which is
3 specifically designed to be readable as is.
7 perlce - Perl for WinCE
9 =head1 Building Perl for WinCE
13 B<< Much of this document has become very out of date and needs updating,
14 rewriting or deleting. The build process was overhauled during the 5.19
15 development track and the current instructions as of that time are given
16 in L</CURRENT BUILD INSTRUCTIONS>; the previous build instructions, which
17 are largely superseded but may still contain some useful information, are
18 left in L</OLD BUILD INSTRUCTIONS> but really need removing after anything
19 of use has been extracted from them. >>
23 This file gives the instructions for building Perl5.8 and above for
24 WinCE. Please read and understand the terms under which this
25 software is distributed.
27 =head2 General explanations on cross-compiling WinCE
33 F<miniperl> is built. This is a single executable (without DLL), intended
34 to run on Win32, and it will facilitate remaining build process; all binaries
35 built after it are foreign and should not run locally.
37 F<miniperl> is built using F<./win32/Makefile>; this is part of normal
38 build process invoked as dependency from wince/Makefile.ce
42 After F<miniperl> is built, F<configpm> is invoked to create right F<Config.pm>
43 in right place and its corresponding Cross.pm.
45 Unlike Win32 build, miniperl will not have F<Config.pm> of host within reach;
46 it rather will use F<Config.pm> from within cross-compilation directories.
48 File F<Cross.pm> is dead simple: for given cross-architecture places in @INC
49 a path where perl modules are, and right F<Config.pm> in that place.
51 That said, C<miniperl -Ilib -MConfig -we 1> should report an error, because
52 it can not find F<Config.pm>. If it does not give an error -- wrong F<Config.pm>
53 is substituted, and resulting binaries will be a mess.
55 C<miniperl -MCross -MConfig -we 1> should run okay, and it will provide right
56 F<Config.pm> for further compilations.
60 During extensions build phase, a script F<./win32/buildext.pl> is invoked,
61 which in turn steps in F<./ext> subdirectories and performs a build of
62 each extension in turn.
64 All invokes of F<Makefile.PL> are provided with C<-MCross> so to enable cross-
69 =head2 CURRENT BUILD INSTRUCTIONS
71 (These instructions assume the host is 32-bit Windows. If you're on 64-bit
72 Windows then change "C:\Program Files" to "C:\Program Files (x86)" throughout.)
76 http://download.microsoft.com/download/c/3/f/c3f8b58b-9753-4c2e-8b96-2dfe3476a2f7/eVC4.exe
78 Use the key mentioned at
80 http://download.cnet.com/Microsoft-eMbedded-Visual-C/3000-2212_4-10108490.html?tag=bc
82 The installer is ancient and has a few bugs on the paths it uses. You
83 will have to fix them later. Basically, some things go into "C:/Program
84 Files/Windows CE Tools", others go into "C:/Windows CE Tools" regardless
85 of the path you gave to the installer (the default will be "C:/Windows
86 CE Tools"). Reboots will be required for the installer to proceed. Also
87 .c and .h associations with Visual Studio might get overridden when
88 installing EVC4. You have been warned.
90 2. Download celib from GitHub (using "Download ZIP") at
92 https://github.com/bulk88/celib
94 Extract it to a spaceless path but not into the perl build source.
95 I call this directory "celib-palm-3.0" but in the GitHub
96 snapshot it will be called "celib-master". Make a copy of the
97 "wince-arm-pocket-wce300-release" folder and rename the copy to
98 "wince-arm-pocket-wce400". This is a hack so we can build a CE 4.0
99 binary by linking in CE 3.0 ARM asm; the linker doesn't care. Windows
100 Mobile/WinCE are backwards compatible with machine code like Desktop Windows.
102 3. Download console-1.3-src.tar.gz from
104 http://sourceforge.net/projects/perlce/files/PerlCE%20support%20files/console/
106 Extract it to a spaceless path but not into the perl build source.
107 Don't extract it into the same directory as celib. Make a copy of the
108 "wince-arm-pocket-wce300" folder and rename the copy to
109 "wince-arm-pocket-wce400". This is a hack so we can build a CE 4.0
110 binary by linking in CE 3.0 ARM asm; the linker doesn't care. Windows
111 Mobile/WinCE are backwards compatible with machine code like Desktop Windows.
113 4. Open a command prompt, run your regular batch file to set the environment
114 for desktop Visual C building, goto the perl source directory, cd into win32/,
115 fill out Makefile, and do a "nmake all" to build a Desktop Perl.
117 5. Open win32/Makefile.ce in a text editor and do something similar to the
120 -CELIBDLLDIR = h:\src\wince\celib-palm-3.0
121 -CECONSOLEDIR = h:\src\wince\w32console
122 +CELIBDLLDIR = C:\sources\celib-palm-3.0
123 +CECONSOLEDIR = C:\sources\w32console
127 !if "$(MACHINE)" == ""
128 MACHINE=wince-arm-hpc-wce300
129 #MACHINE=wince-arm-hpc-wce211
130 #MACHINE=wince-sh3-hpc-wce211
131 #MACHINE=wince-mips-hpc-wce211
132 #MACHINE=wince-sh3-hpc-wce200
133 #MACHINE=wince-mips-hpc-wce200
134 #MACHINE=wince-arm-pocket-wce300
135 #MACHINE=wince-mips-pocket-wce300
136 #MACHINE=wince-sh3-pocket-wce300
137 #MACHINE=wince-x86em-pocket-wce300
138 #MACHINE=wince-mips-palm-wce211
139 #MACHINE=wince-sh3-palm-wce211
140 #MACHINE=wince-x86em-palm-wce211
141 #MACHINE=wince-x86-hpc-wce300
142 #MACHINE=wince-arm-pocket-wce400
147 !if "$(MACHINE)" == ""
148 #MACHINE=wince-arm-hpc-wce300
149 #MACHINE=wince-arm-hpc-wce211
150 #MACHINE=wince-sh3-hpc-wce211
151 #MACHINE=wince-mips-hpc-wce211
152 #MACHINE=wince-sh3-hpc-wce200
153 #MACHINE=wince-mips-hpc-wce200
154 #MACHINE=wince-arm-pocket-wce300
155 #MACHINE=wince-mips-pocket-wce300
156 #MACHINE=wince-sh3-pocket-wce300
157 #MACHINE=wince-x86em-pocket-wce300
158 #MACHINE=wince-mips-palm-wce211
159 #MACHINE=wince-sh3-palm-wce211
160 #MACHINE=wince-x86em-palm-wce211
161 #MACHINE=wince-x86-hpc-wce300
162 MACHINE=wince-arm-pocket-wce400
165 so wince-arm-pocket-wce400 is the MACHINE type.
167 6. Use a text editor to open "C:\Program Files\Microsoft eMbedded C++
168 4.0\EVC\WCE400\BIN\WCEARMV4.BAT". Look for
170 if "%SDKROOT%"=="" set SDKROOT=...
172 On a new install it is "C:\Windows CE Tools". Goto
173 "C:\Windows CE Tools" in a file manager and see if "C:\Windows CE
174 Tools\wce400\STANDARDSDK\Include\Armv4" exists on your disk. If not
175 the SDKROOT need to be changed to "C:\Program Files\Windows CE Tools".
177 Goto celib-palm-3.0\inc\cewin32.h, search for
179 typedef struct _ABC {
181 and uncomment the struct.
183 7. Open another command prompt, ensure PLATFORM is not set to anything
184 already unless you know what you're doing (so that the correct default
185 value is set by the next command), and run "C:\Program Files\Microsoft
186 eMbedded C++ 4.0\EVC\WCE400\BIN\WCEARMV4.BAT"
188 8. In the WinCE command prompt you made with WCEARMV4.BAT, goto the perl
189 source directory, cd into win32/ and run "nmake -f Makefile.ce".
191 9. The ARM perl interpreter (perl519.dll and perl.exe) will be in something
192 like "C:\perl519\src\win32\wince-arm-pocket-wce400", with the XS DLLs in
193 "C:\perl519\src\xlib\wince-arm-hpc-wce400\auto".
195 To prove success on the host machine, run
196 "dumpbin /headers wince-arm-pocket-wce400\perl.exe" from the win32/ folder
197 and look for "machine (ARM)" in the FILE HEADER VALUES and
198 "subsystem (Windows CE GUI)" in the OPTIONAL HEADER VALUES.
200 =head2 OLD BUILD INSTRUCTIONS
202 This section describes the steps to be performed to build PerlCE.
203 You may find additional information about building perl for WinCE
204 at L<http://perlce.sourceforge.net> and some pre-built binaries.
208 For compiling, you need following:
212 =item * Microsoft Embedded Visual Tools
214 =item * Microsoft Visual C++
216 =item * Rainer Keuchel's celib-sources
218 =item * Rainer Keuchel's console-sources
222 Needed source files can be downloaded at
223 L<http://perlce.sourceforge.net>
227 Normally you only need to edit F<./win32/ce-helpers/compile.bat>
228 to reflect your system and run it.
230 File F<./win32/ce-helpers/compile.bat> is actually a wrapper to call
231 C<nmake -f makefile.ce> with appropriate parameters and it accepts extra
232 parameters and forwards them to C<nmake> command as additional
233 arguments. You should pass target this way.
235 To prepare distribution you need to do following:
239 =item * go to F<./win32> subdirectory
241 =item * edit file F<./win32/ce-helpers/compile.bat>
251 F<Makefile.ce> has C<CROSS_NAME> macro, and it is used further to refer to
252 your cross-compilation scheme. You could assign a name to it, but this
253 is not necessary, because by default it is assigned after your machine
254 configuration name, such as "wince-sh3-hpc-wce211", and this is enough
255 to distinguish different builds at the same time. This option could be
256 handy for several different builds on same platform to perform, say,
257 threaded build. In a following example we assume that all required
258 environment variables are set properly for C cross-compiler (a special
259 *.bat file could fit perfectly to this purpose) and your F<compile.bat>
260 has proper "MACHINE" parameter set, to, say, C<wince-mips-pocket-wce300>.
264 compile.bat CROSS_NAME=mips-wce300-thr "USE_ITHREADS=define" ^
265 "USE_IMP_SYS=define" "USE_MULTI=define"
266 compile.bat CROSS_NAME=mips-wce300-thr "USE_ITHREADS=define" ^
267 "USE_IMP_SYS=define" "USE_MULTI=define" dist
269 If all goes okay and no errors during a build, you'll get two independent
270 distributions: C<wince-mips-pocket-wce300> and C<mips-wce300-thr>.
272 Target C<dist> prepares distribution file set. Target C<zipdist> performs
273 same as C<dist> but additionally compresses distribution files into zip
276 NOTE: during a build there could be created a number (or one) of F<Config.pm>
277 for cross-compilation ("foreign" F<Config.pm>) and those are hidden inside
278 F<../xlib/$(CROSS_NAME)> with other auxiliary files, but, and this is important to
279 note, there should be B<no> F<Config.pm> for host miniperl.
280 If you'll get an error that perl could not find Config.pm somewhere in building
281 process this means something went wrong. Most probably you forgot to
282 specify a cross-compilation when invoking miniperl.exe to Makefile.PL
283 When building an extension for cross-compilation your command line should
286 ..\miniperl.exe -I..\lib -MCross=mips-wce300-thr Makefile.PL
290 ..\miniperl.exe -I..\lib -MCross Makefile.PL
292 to refer a cross-compilation that was created last time.
294 All questions related to building for WinCE devices could be asked in
295 F<perlce-user@lists.sourceforge.net> mailing list.
297 =head1 Using Perl on WinCE
301 PerlCE is currently linked with a simple console window, so it also
302 works on non-hpc devices.
304 The simple stdio implementation creates the files F<stdin.txt>,
305 F<stdout.txt> and F<stderr.txt>, so you might examine them if your
306 console has only a limited number of cols.
308 When exitcode is non-zero, a message box appears, otherwise the
309 console closes, so you might have to catch an exit with
310 status 0 in your program to see any output.
312 stdout/stderr now go into the files F</perl-stdout.txt> and
315 PerlIDE is handy to deal with perlce.
319 No fork(), pipe(), popen() etc.
323 All environment vars must be stored in HKLM\Environment as
324 strings. They are read at process startup.
330 Usual perl lib path (semi-list).
334 Semi-list for executables.
342 - Root for accessing some special files, i.e. F</dev/null>, F</etc/services>.
346 - Rows/cols for console.
352 =item CONSOLEFONTSIZE
354 - Size for console font.
358 You can set these with cereg.exe, a (remote) registry editor
363 To start perl by clicking on a perl source file, you have
364 to make the according entries in HKCR (see F<ce-helpers/wince-reg.bat>).
365 cereg.exe (which must be executed on a desktop pc with
366 ActiveSync) is reported not to work on some devices.
367 You have to create the registry entries by hand using a
372 The following Win32-Methods are built-in:
374 newXS("Win32::GetCwd", w32_GetCwd, file);
375 newXS("Win32::SetCwd", w32_SetCwd, file);
376 newXS("Win32::GetTickCount", w32_GetTickCount, file);
377 newXS("Win32::GetOSVersion", w32_GetOSVersion, file);
378 newXS("Win32::IsWinNT", w32_IsWinNT, file);
379 newXS("Win32::IsWin95", w32_IsWin95, file);
380 newXS("Win32::IsWinCE", w32_IsWinCE, file);
381 newXS("Win32::CopyFile", w32_CopyFile, file);
382 newXS("Win32::Sleep", w32_Sleep, file);
383 newXS("Win32::MessageBox", w32_MessageBox, file);
384 newXS("Win32::GetPowerStatus", w32_GetPowerStatus, file);
385 newXS("Win32::GetOemInfo", w32_GetOemInfo, file);
386 newXS("Win32::ShellEx", w32_ShellEx, file);
390 Opening files for read-write is currently not supported if
391 they use stdio (normal perl file handles).
393 If you find bugs or if it does not work at all on your
394 device, send mail to the address below. Please report
395 the details of your device (processor, ceversion,
396 devicetype (hpc/palm/pocket)) and the date of the downloaded
401 Currently installation instructions are at L<http://perlce.sourceforge.net/>.
403 After installation & testing processes will stabilize, information will
406 =head1 ACKNOWLEDGEMENTS
408 The port for Win32 was used as a reference.
410 =head1 History of WinCE port
416 Initial port of perl to WinCE. It was performed in separate directory
417 named F<wince>. This port was based on contents of F<./win32> directory.
418 F<miniperl> was not built, user must have HOST perl and properly edit
419 F<makefile.ce> to reflect this.
423 wince port was kept in the same F<./wince> directory, and F<wince/Makefile.ce>
424 was used to invoke native compiler to create HOST miniperl, which then
425 facilitates cross-compiling process.
426 Extension building support was added.
430 Two directories F<./win32> and F<./wince> were merged, so perlce build
431 process comes in F<./win32> directory.
439 =item Rainer Keuchel <coyxc@rainer-keuchel.de>
441 provided initial port of Perl, which appears to be most essential work, as
442 it was a breakthrough on having Perl ported at all.
443 Many thanks and obligations to Rainer!
445 =item Vadim Konovalov
447 made further support of WinCE port.
451 updated the build process during the 5.19 development track.