Subject: | [PATCH] Fix build on Win32/VC++ |
The current version (1.012) of PAR-Packer does not build on Win32 with
VC++. There are two problems: myldr/boot.c attempts to include unistd.h
which VC++ does not provide (MinGW/gcc does, but VC++ should include
io.h for write() instead), and myldr/Makefile.PL wrongly uses $(CC)
rather than $(LD) to link boot.exe.
The attached patch fixes these problems.
There is still a warning (not an error that stops the build) from
myldr/mktmpdir.c which I'm not sure how best to solve:
myldr\mktmpdir.c(45) : warning C4013: 'getuid' undefined; assuming
extern returning int
The problem is that Win32/VC++ doeesn't have a getuid(), hence the
compiler's warning. The linker is happy, though, presumably because perl
provides a dummy function in win32/win32.c:
#define ROOT_UID ((uid_t)0)
uid_t getuid(void) { return ROOT_UID; }
but adding a declaration like
extern uid_t getuid(void);
to myldr/mktmpdir.h doesn't work at all.
Subject: | win32.patch |
diff -ruN PAR-Packer-1.012.orig\myldr\boot.c PAR-Packer-1.012\myldr\boot.c
--- PAR-Packer-1.012.orig\myldr\boot.c Mon Nov 14 17:13:56 2011
+++ PAR-Packer-1.012\myldr\boot.c Tue Feb 21 13:55:55 2012
@@ -1,6 +1,10 @@
#undef readdir
+#if !defined(WIN32) || defined(__GNUC__)
#include <unistd.h>
+#else
+#include <io.h>
+#endif
typedef struct my_chunk
{
diff -ruN PAR-Packer-1.012.orig\myldr\Makefile.PL PAR-Packer-1.012\myldr\Makefile.PL
--- PAR-Packer-1.012.orig\myldr\Makefile.PL Mon Nov 28 15:06:36 2011
+++ PAR-Packer-1.012\myldr\Makefile.PL Tue Feb 21 14:03:07 2012
@@ -315,7 +315,7 @@
boot$o: \$(MKTMP_STUFF) $my_stuff
$boot_exe: boot$o
- \$(CC) boot$o \$(STATIC_LDFLAGS) $res $out$boot_exe_link
+ \$(LD) boot$o \$(STATIC_LDFLAGS) $res $out$boot_exe_link
$mt_cmd
my_par.c: $par_exe