summaryrefslogtreecommitdiff
path: root/test/MakeWin32Make.pl
blob: 96e94b2f3ab188de0b309adc118022f5dfc80c24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use IO::File;

$srcfl = new IO::File "Makefile.in", "r" || die "failed to open .in file";
$dstfl = new IO::File "Makefile", "w" || die "failed to create Makefile";

while ($t = <$srcfl>) {

    if ($t =~ m|\@INCLUDE_RULES\@|) {
        $t = "ALL: \$(TARGETS)\n\n"
           . "CL = cl.exe\n"
           . "LINK = link.exe /nologo /debug /machine:I386 /subsystem:console /incremental:no \n\n"
           . "CFLAGS = /nologo /c /MDd /W3 /Gm /GX /Zi /Od /D _DEBUG /D WIN32 /D APR_DECLARE_STATIC /FD \n\n"
           . ".c.obj::\n"
           . "\t\$(CL) -c \$< \$(CFLAGS) \$(INCLUDES)\n";
    }
    if ($t =~ m|^ALL_LIBS=|) {
        $t = "";
    }
    if ($t =~ m|^LOCAL_LIBS=|) {
        $t = "LOCAL_LIBS=../LibD/apr.lib\n"
           . "ALL_LIBS=kernel32\.lib user32\.lib advapi32\.lib ws2_32\.lib wsock32\.lib ole32\.lib\n\n";
    }
    if ($t =~ s|\@CFLAGS\@||) {
        $t = "";
    }
    $t =~ s|\$\{LD_FLAGS\}||;
    $t =~ s|\.\./libapr\.la|../LibD/apr.lib|;

    $t =~ s|\@RM\@|del|;
    if ($t =~ s|(\$\(RM\)) -f|$1|) {
	$t =~ s|\*\.a|\*\.lib \*\.exp \*\.idb \*\.ilk \*\.pdb|;
	$t =~ s|(Makefile)|$1 \*\.ncb \*\.opt|;
    }
    $t =~ s|\@CC\@|cl|;
    $t =~ s|\@RANLIB\@||;
    $t =~ s|-I\$\(INCDIR\)|\/I "\$\(INCDIR\)"|;
    $t =~ s|\.\.\/libapr\.a|\.\./LibD/apr\.lib|;
    if ($t =~ s|\@EXEEXT\@|\.exe|) {
        while ($t =~ s|\@EXEEXT\@|\.exe|) {}
        $t =~ s|\$\(CC\) \$\(CFLAGS\)|\$\(LINK\) \/subsystem:console|;
        $t =~ s|-o (\S+)|\/out:\"$1\"|;
        $t =~ s|--export-dynamic ||; 
        $t =~ s|-fPIC ||;
    }
    if ($t =~ s|-shared|\/subsystem:windows \/dll|) {
        $t =~ s|-o (\S+)|\/out:\"$1\"|;
    }
    while ($t =~ s|\.a\b|\.lib|) {}
    while ($t =~ s|\.o\b|\.obj|) {}
    while ($t =~ s|\.lo\b|\.obj|) {}

    print $dstfl $t;

}

undef $srcfl;
undef $dstfl;

print "Generated Makefile from Makefile.in\n";