| 1 |
#!perl |
| 2 |
use Cwd; |
| 3 |
use Config; |
| 4 |
use File::Copy; |
| 5 |
#warn __FILE__." in ".getcwd()."\n"; |
| 6 |
if ($^O eq 'MSWin32') |
| 7 |
{ |
| 8 |
my $file; |
| 9 |
chmod(0666,'Makefile'); |
| 10 |
if ($Config{'cc'} =~ /gcc/) |
| 11 |
{ |
| 12 |
$file = "win32/Makefile.gcc"; |
| 13 |
} |
| 14 |
else |
| 15 |
{ |
| 16 |
$file = 'win32/Makefile.msc'; |
| 17 |
warn "Assuming ".$Config{'cc'}." is visual C of some kind\n"; |
| 18 |
} |
| 19 |
copy($file,"Makefile") |
| 20 |
|| die "Cannot copy $file to Makefile: $!"; |
| 21 |
|
| 22 |
# overwrite zconf.h with original zconf.in.h |
| 23 |
copy("zconf.in.h", "zconf.h") |
| 24 |
|| die "Cannot copy zconf.in.h to zconf.h: $!"; |
| 25 |
} |
| 26 |
else |
| 27 |
{ |
| 28 |
$ENV{CC} = $Config{cc}; |
| 29 |
local $ENV{CFLAGS} = "$Config{ccflags} $Config{cccdlflags}"; |
| 30 |
system(sh => "./configure"); |
| 31 |
} |
| 32 |
|
| 33 |
my $seen_empty_rule; |
| 34 |
open my $fh, '<', 'Makefile' or die "Error opening Makefile: $!"; |
| 35 |
while(<$fh>) |
| 36 |
{ |
| 37 |
if (/# Empty rule needed/) |
| 38 |
{ |
| 39 |
$seen_empty_rule = 1; |
| 40 |
last; |
| 41 |
} |
| 42 |
} |
| 43 |
if (!$seen_empty_rule) |
| 44 |
{ |
| 45 |
open my $ofh, '>>', 'Makefile' or die "Error appending to Makefile: $!"; |
| 46 |
print $ofh <<'EOF'; |
| 47 |
|
| 48 |
# Empty rule needed since ExtUtils::MakeMaker 7.18 (see https://rt.cpan.org/Ticket/Display.html?id=117800) |
| 49 |
test_dynamic: |
| 50 |
|
| 51 |
EOF |
| 52 |
close $ofh or die "Error closing Makefile: $!"; |
| 53 |
} |
| 54 |
|
| 55 |
1; |