Cygwin (a linux emulation layer and toolset for Windows) is capable of building a very unix-like perl, but also bundles parts of
MinGW to build windows programs that don't use the emulation layer (invoked by using a -mno-cygwin switch to gcc). While there are instructions and support for building a win32 perl using MinGW proper, doing so with cygwin's MinGW wasn't so straightforward. I'm posting here for posterity what I had to do to get it to work.
First of all, the obvious change to makefile.mk. I didn't bother setting CCHOME (so left it set to the nonexistent C:\MinGW). the concept of having to tell a compiler where the standard include files and libraries are seems a little odd to me. If you really had MinGW and cygwin both installed, you would probably need to change it to prevent conflicts.
--- perlwin32/win32/makefile.mk.orig 2004-11-27 09:26:09.000000000
+-0800
+++ perlwin32/win32/makefile.mk 2005-01-03 11:48:40.477425600 -0800
@@ -394,8 +394,8 @@ LINK_FLAGS += -L"$(CCLIBDIR)\Release"
.ELIF "$(CCTYPE)" == "GCC"
-CC = gcc
-LINK32 = g++
+CC = gcc -mno-cygwin
+LINK32 = g++ -mno-cygwin
LIB32 = ar rc
IMPLIB = dlltool
RSC = windres
After that, I had problems with the gcc command line for compiling the c files for extensions. gcc would report "no input files". This change to makemaker fixed it. I'd be curious to know if it causes any harm on any other platform. It's possible that this is a bug in cygwin's gcc, since presumably the regular mingw gcc doesn't have this problem.
--- perlwin32/lib/ExtUtils/MM_Unix.pm.orig 2004-12-15 05:11:11.0000
+00000 -0800
+++ perlwin32/lib/ExtUtils/MM_Unix.pm 2005-01-03 12:23:05.206360000
+ -0800
@@ -366,8 +366,8 @@ sub const_cccmd {
return $self->{CONST_CCCMD} =
q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
$(CCFLAGS) $(OPTIMIZE) \\
- $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
- $(XS_DEFINE_VERSION)};
+ $(PERLTYPE) $(MPOLLUTE) "$(DEFINE_VERSION)" \\
+ "$(XS_DEFINE_VERSION)"};
}
=item const_config (o)
Final problem was the building of Errno, which failed for
two completely different reasons. First, config.sh didn't have the required compiler settings. I'd be interested to see the output of
perl -V:ccname from a regular mingw build, since there may be a problem there also.
Second, the preprocessor was outputing the include file names in as cygwin's posix filenames. To find them, the Errno build script needed to convert to windows filenames.
(Presumably h2ph may need a similar change, but I've never had need to use h2ph.)
--- perlwin32/win32/config.gc.orig 2005-01-03 12:44:00.261040000 -0
+800
+++ perlwin32/win32/config.gc 2005-01-03 12:58:26.436539200 -0800
@@ -41,12 +41,12 @@ byteorder='1234'
c=''
castflags='0'
cat='type'
-cc='~CC~'
+cc='~cc~'
cccdlflags=' '
ccdlflags=' '
ccflags='-MD -DWIN32'
ccflags_uselargefiles=''
-ccname='~CC~'
+ccname='~cc~'
ccsymbols=''
ccversion=''
cf_by='nobody'
@@ -62,14 +62,14 @@ compress=''
contains='grep'
cp='copy'
cpio=''
-cpp='gcc -E'
+cpp='~cc~ -E'
cpp_stuff='42'
cppccsymbols=''
cppflags='-DWIN32'
cpplast=''
cppminus='-'
-cpprun='gcc -E'
-cppstdin='gcc -E'
+cpprun='~cc~ -E'
+cppstdin='~cc~ -E'
cppsymbols=''
crypt_r_proto='0'
cryptlib=''
@@ -672,7 +672,7 @@ ivsize='4'
ivtype='long'
known_extensions='~static_ext~ ~dynamic_ext~ ~nonxs_ext~'
ksh=''
-ld='gcc'
+ld='~cc~'
lddlflags='-mdll ~LINK_FLAGS~'
ldflags='~LINK_FLAGS~'
ldflags_uselargefiles=''
--- perlwin32/ext/Errno/Errno_pm.PL.orig 2004-12-01 06:11:10.000000
+000 -0800
+++ perlwin32/ext/Errno/Errno_pm.PL 2005-01-03 14:38:44.269758400 -
+0800
@@ -20,6 +20,12 @@ unlink "errno.c" if -f "errno.c";
sub process_file {
my($file) = @_;
+ # for win32 perl under cygwin, we need to get a windows pathname
+ if ($^O eq 'MSWin32' && $Config{cc} =~ /\B-mno-cygwin\b/ &&
+ defined($file) && !-f $file) {
+ chomp($file = `cygpath -w "$file"`);
+ }
+
return unless defined $file and -f $file;
# warn "Processing $file\n";
Test results, which I haven't had time to look into yet:
Failed Test Stat Wstat Total Fail Failed List of Fail
+ed
----------------------------------------------------------------------
+---------
../lib/Config/Extensions.t 9 2304 88 9 10.23% 11 17 19 23
+41 67 71
73 77