don't work yet - suspect __declspec() non-implemented issues.
p4raw-id: //depot/ansiperl@329
#define XS(name) void name(cv) CV* cv;
#endif
+#if defined(WIN32) && defined(__GNUC__)
+#define FORCE_ARG_STRING(x) #x
+#else
+#define FORCE_ARG_STRING(x) x
+#endif
+
#define dXSARGS \
dSP; dMARK; \
I32 ax = mark - stack_base + 1; \
#ifdef XS_VERSION
# define XS_VERSION_BOOTCHECK \
STMT_START { \
+ char *xs_version = FORCE_ARG_STRING(XSVERSION); \
char *vn = "", *module = SvPV(ST(0),na); \
if (items >= 2) /* version supplied as bootstrap arg */ \
Sv = ST(1); \
Sv = perl_get_sv(form("%s::%s", module, \
vn = "VERSION"), FALSE); \
} \
- if (Sv && (!SvOK(Sv) || strNE(XS_VERSION, SvPV(Sv, na)))) \
+ if (Sv && (!SvOK(Sv) || strNE(xs_version, SvPV(Sv, na)))) \
croak("%s object version %s does not match $%s::%s %_", \
- module, XS_VERSION, module, vn, Sv); \
+ module, xs_version, module, vn, Sv); \
} STMT_END
#else
# define XS_VERSION_BOOTCHECK
sub touch
{
expand_wildcards();
+ my $t = time;
while (@ARGV)
{
my $file = shift(@ARGV);
open(FILE,">>$file") || die "Cannot write $file:$!";
close(FILE);
+ utime($t,$t,$file);
}
}
exit !-f shift(@ARGV);
}
+
1;
__END__
unshift @MM::ISA, 'ExtUtils::MM_Win32';
$BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
+$GCC = 1 if $Config{'cc'} =~ /^gcc/i;
$DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
$NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
$self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
$self->{'LD'} = $Config{'ld'} || 'link';
$self->{'AR'} = $Config{'ar'} || 'lib';
- $self->{'LDLOADLIBS'}
- ||= ( $BORLAND
- ? 'import32.lib cw32mti.lib '
- : 'msvcrt.lib oldnames.lib kernel32.lib comdlg32.lib winspool.lib gdi32.lib '
- .'advapi32.lib user32.lib shell32.lib netapi32.lib ole32.lib '
- .'oleaut32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib '
- ) . ' odbc32.lib odbccp32.lib';
+ if ($GCC)
+ {
+ $self->{'LDLOADLIBS'} ||= ' ';
+ }
+ else
+ {
+ $self->{'LDLOADLIBS'}
+ ||= ( $BORLAND
+ ? 'import32.lib cw32mti.lib '
+ : 'msvcrt.lib oldnames.lib kernel32.lib comdlg32.lib winspool.lib gdi32.lib '
+ .'advapi32.lib user32.lib shell32.lib netapi32.lib ole32.lib '
+ .'oleaut32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib '
+ ) . ' odbc32.lib odbccp32.lib';
+ }
$self->{'DEV_NULL'} = '> NUL';
# $self->{'NOECHO'} = ''; # till we have it working
}
$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
');
-
- push(@m, $BORLAND ?
-q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,),$(RESFILES)} :
-q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}
+ if ($GCC) {
+ push(@m,
+ q{ $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
+ dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
+ $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
+ } else {
+ push(@m, $BORLAND ?
+ q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) $(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,),$(RESFILES)} :
+ q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)}
);
+ }
push @m, '
$(CHMOD) 755 $@
';
=cut
+
open(DEF,">$data->{FILE}.def")
or croak("Can't create $data->{FILE}.def: $!\n");
# put library name in quotes (it could be a keyword, like 'Alias')
- print DEF "LIBRARY \"$data->{DLBASE}\"\n";
- print DEF "CODE LOADONCALL\n";
- print DEF "DATA LOADONCALL NONSHARED MULTIPLE\n";
+ if ($Config::Config{'cc'} !~ /^gcc/i) {
+ print DEF "LIBRARY \"$data->{DLBASE}\"\n";
+ print DEF "CODE LOADONCALL\n";
+ print DEF "DATA LOADONCALL NONSHARED MULTIPLE\n";
+ }
print DEF "EXPORTS\n ";
my @syms;
# Export public symbols both with and without underscores to
archlibexp='~INST_TOP~\lib'
archname='MSWin32'
-cc='cl'
-ccflags='-MD -DWIN32'
+cc='gcc'
+ccflags='-DWIN32'
cppflags='-DWIN32'
dlsrc='dl_win32.xs'
dynamic_ext='Socket IO Fcntl Opcode SDBM_File attrs Thread'
installarchlib='~INST_TOP~\lib'
installprivlib='~INST_TOP~\lib'
libpth=''
-libs=''
+libs=' '
osname='MSWin32'
osvers='4.0'
prefix='~INST_DRV~'
c=''
castflags='0'
cat='type'
-cccdlflags=' '
+cccdlflags='-dll'
ccdlflags=' '
cf_by='nobody'
cf_email='nobody@no.where.net'
cpp='cpp'
cpp_stuff='42'
cpplast=''
-cppminus=''
-cpprun='cl -E'
-cppstdin='cl -E'
+cppminus='-'
+cpprun='gcc -E'
+cppstdin='gcc -E'
cryptlib=''
csh='undef'
d_Gconvert='sprintf((b),"%.*g",(n),(x))'
known_extensions='DB_File Fcntl GDBM_File NDBM_File ODBM_File Opcode POSIX SDBM_File Socket IO attrs Thread'
ksh=''
large=''
-ld='link'
+ld='gcc'
lddlflags='-dll'
-ldflags='-nologo -subsystem:windows'
+ldflags=''
less='less'
lib_ext='.lib'
libc='msvcrt.lib'
libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
line='line'
lint=''
-lkflags=''
+lkflags=' '
ln=''
lns='copy'
locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include'
lseektype='off_t'
mail=''
mailx=''
-make='nmake'
+make='dmake'
mallocobj='malloc.o'
mallocsrc='malloc.c'
malloctype='void *'
nm_so_opt=''
nroff=''
o_nonblock='O_NONBLOCK'
-obj_ext='.obj'
+obj_ext='.o'
oldarchlib=''
oldarchlibexp=''
-optimize='-O'
+optimize='-O2'
orderlib='false'
package='perl5'
pager='more /e'
OPTIMIZE = -g -O2 $(RUNTIME)
LINK_DBG = -g
.ELSE
-OPTIMIZE = -O2 $(RUNTIME)
+OPTIMIZE = -g -O2 $(RUNTIME)
LINK_DBG =
.ENDIF
# Rules
#
.SUFFIXES :
-.SUFFIXES : .c .obj .dll .lib .exe
+.SUFFIXES : .c .o .dll .lib .exe
-.c.obj:
+.c.o:
$(CC) -c $(CFLAGS) $(OBJOUT_FLAG) $@ $<
.c.i:
$(CC) -E $(CFLAGS) $(OBJOUT_FLAG) $@ $<
-.obj.dll:
+.o.dll:
$(LINK32) -o $@ $(LINK_FLAGS) $< $(LIBFILES),
$(IMPLIB) -def $(*B).def $(*B).lib $@
..\util.c \
..\malloc.c
-CORE_OBJ= ..\av.obj \
- ..\deb.obj \
- ..\doio.obj \
- ..\doop.obj \
- ..\dump.obj \
- ..\globals.obj \
- ..\gv.obj \
- ..\hv.obj \
- ..\mg.obj \
- ..\op.obj \
- ..\perl.obj \
- ..\perlio.obj \
- ..\perly.obj \
- ..\pp.obj \
- ..\pp_ctl.obj \
- ..\pp_hot.obj \
- ..\pp_sys.obj \
- ..\regcomp.obj \
- ..\regexec.obj \
- ..\run.obj \
- ..\scope.obj \
- ..\sv.obj \
- ..\taint.obj \
- ..\toke.obj \
- ..\universal.obj\
- ..\util.obj \
- ..\malloc.obj
+CORE_OBJ= ..\av.o \
+ ..\deb.o \
+ ..\doio.o \
+ ..\doop.o \
+ ..\dump.o \
+ ..\globals.o \
+ ..\gv.o \
+ ..\hv.o \
+ ..\mg.o \
+ ..\op.o \
+ ..\perl.o \
+ ..\perlio.o \
+ ..\perly.o \
+ ..\pp.o \
+ ..\pp_ctl.o \
+ ..\pp_hot.o \
+ ..\pp_sys.o \
+ ..\regcomp.o \
+ ..\regexec.o \
+ ..\run.o \
+ ..\scope.o \
+ ..\sv.o \
+ ..\taint.o \
+ ..\toke.o \
+ ..\universal.o\
+ ..\util.o \
+ ..\malloc.o
WIN32_C = perllib.c \
win32.c \
win32sck.c \
win32thread.c
-WIN32_OBJ = win32.obj \
- win32sck.obj \
- win32thread.obj
+WIN32_OBJ = win32.o \
+ win32sck.o \
+ win32thread.o
-PERL95_OBJ = perl95.obj \
- win32mt.obj \
- win32sckmt.obj
+PERL95_OBJ = perl95.o \
+ win32mt.o \
+ win32sckmt.o
-DLL_OBJ = perllib.obj $(DYNALOADER).obj
+DLL_OBJ = perllib.o $(DYNALOADER).o
CORE_H = ..\av.h \
..\cop.h \
all: $(PERLEXE) $(PERL95EXE) $(GLOBEXE) $(DYNALOADMODULES) $(MINIMOD) $(GLOBBAT)
-$(DYNALOADER).obj : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c
+$(DYNALOADER).o : $(DYNALOADER).c $(CORE_H) $(EXTDIR)\DynaLoader\dlutils.c
#------------------------------------------------------------
-$(GLOBEXE): perlglob.obj
+$(GLOBEXE): perlglob.o
$(LINK32) $(LINK_FLAGS) -o $@ \
- perlglob.obj $(LIBFILES)
+ perlglob.o $(LIBFILES)
$(GLOBBAT) : ..\lib\File\DosGlob.pm $(MINIPERL)
$(MINIPERL) $(PL2BAT) - < ..\lib\File\DosGlob.pm > $(GLOBBAT)
-perlglob.obj : perlglob.c
+perlglob.o : perlglob.c
-..\miniperlmain.obj : ..\miniperlmain.c $(CORE_H)
+..\miniperlmain.o : ..\miniperlmain.c $(CORE_H)
config.w32 : $(CFGSH_TMPL)
copy $(CFGSH_TMPL) config.w32
LKPRE = INPUT (
LKPOST = )
-linkscript : ..\miniperlmain.obj $(CORE_OBJ) $(WIN32_OBJ)
- type $(mktmp $(LKPRE) ..\miniperlmain.obj \
+linkscript : ..\miniperlmain.o $(CORE_OBJ) $(WIN32_OBJ)
+ type $(mktmp $(LKPRE) ..\miniperlmain.o \
$(CORE_OBJ:s,\,\\) $(WIN32_OBJ:s,\,\\) $(LIBFILES) $(LKPOST))
-$(MINIPERL) : ..\miniperlmain.obj $(CORE_OBJ) $(WIN32_OBJ)
+$(MINIPERL) : ..\miniperlmain.o $(CORE_OBJ) $(WIN32_OBJ)
$(LINK32) -v -o $@ $(LINK_FLAGS) \
- $(mktmp $(LKPRE) ..\miniperlmain.obj \
+ $(mktmp $(LKPRE) ..\miniperlmain.o \
$(CORE_OBJ:s,\,\\) $(WIN32_OBJ:s,\,\\) $(LIBFILES) $(LKPOST))
$(WIN32_OBJ) : $(CORE_H)
perlmain.c : runperl.c
copy runperl.c perlmain.c
-perlmain.obj : perlmain.c
+perlmain.o : perlmain.c
$(CC) $(CFLAGS) -UPERLDLL -o $@ -c perlmain.c
-$(PERLEXE): $(PERLDLL) $(CONFIGPM) perlmain.obj
+$(PERLEXE): $(PERLDLL) $(CONFIGPM) perlmain.o
$(LINK32) -o perl.exe $(LINK_FLAGS) \
- perlmain.obj $(WINIOMAYBE) $(PERLIMPLIB) $(LIBFILES)
+ perlmain.o $(WINIOMAYBE) $(PERLIMPLIB) $(LIBFILES)
copy perl.exe $@
del perl.exe
copy splittree.pl ..
-del /f perl95.c
.ENDIF
-del /f bin\*.bat
- -cd $(EXTDIR) && del /s *.lib *.def *.map *.bs Makefile *.obj pm_to_blib
+ -cd $(EXTDIR) && del /s *.lib *.def *.map *.bs Makefile *.o pm_to_blib
-rmdir /s /q ..\lib\auto
-rmdir /s /q ..\lib\CORE
cd ..\t && $(PERLEXE) -I.\lib harness
clean :
- -@erase miniperlmain.obj
+ -@erase miniperlmain.o
-@erase $(MINIPERL)
- -@erase perlglob.obj
- -@erase perlmain.obj
+ -@erase perlglob.o
+ -@erase perlmain.o
-@erase config.w32
-@erase /f config.h
-@erase $(GLOBEXE)
-@erase $(CORE_OBJ)
-@erase $(WIN32_OBJ)
-@erase $(DLL_OBJ)
- -@erase ..\*.obj ..\*.lib ..\*.exp *.obj *.lib *.exp
+ -@erase ..\*.o ..\*.lib ..\*.exp *.o *.lib *.exp
-@erase ..\t\*.exe ..\t\*.dll ..\t\*.bat
-@erase *.ilk
-@erase *.pdb
/* Say NO to CPP! Hallelujah! */
#ifdef __GNUC__
+/*
+ * GNU C does not do __declspec()
+ */
#define __declspec(foo)
+
+/* Mingw32 defaults to globing command line
+ * This is inconsistent with other Win32 ports and
+ * seems to cause trouble with passing -DXSVERSION=\"1.6\"
+ * So we turn it off like this:
+ */
+int _CRT_glob = 0;
+
#endif
+
__declspec(dllimport) int RunPerl(int argc, char **argv, char **env, void *ios);
int
#include "XSUB.h"
#include <fcntl.h>
#include <sys/stat.h>
+#ifndef __GNUC__
+/* assert.h conflicts with #define of assert in perl.h */
#include <assert.h>
+#endif
#include <string.h>
#include <stdarg.h>
#include <float.h>
+#ifdef __GNUC__
+/* Mingw32 defaults to globing command line
+ * So we turn it off like this:
+ */
+int _CRT_glob = 0;
+#endif
+
#define EXECF_EXEC 1
#define EXECF_SPAWN 2
#define EXECF_SPAWN_NOWAIT 3
DllExport FILE*
win32_popen(const char *command, const char *mode)
{
-#ifdef __GNUC__
- return NULL;
-#else
return _popen(command, mode);
-#endif
}
DllExport int
win32_pclose(FILE *pf)
{
-#ifdef __GNUC__
- return fclose(pf);
-#else
return _pclose(pf);
-#endif
}
DllExport int
DllExport int
win32_flushall(void)
{
-#ifndef __GNUC__
return flushall();
-#endif
}
DllExport int
win32_fcloseall(void)
{
-#ifndef __GNUC__
return fcloseall();
-#endif
}
DllExport char*
#define perror win32_perror
#define setbuf win32_setbuf
#define setvbuf win32_setvbuf
+#undef flushall
#define flushall win32_flushall
+#undef fcloseall
#define fcloseall win32_fcloseall
#define fgets win32_fgets
#define gets win32_gets