Modify MSVC wrapper script
[git/dscho.git] / compat / vcbuild / scripts / clink.pl
blob3f51886e4c74004e48824573ab641d38504e7616
1 #!/usr/bin/perl -w
2 ######################################################################
3 # Compiles or links files
5 # This is a wrapper to facilitate the compilation of Git with MSVC
6 # using GNU Make as the build system. So, instead of manipulating the
7 # Makefile into something nasty, just to support non-space arguments
8 # etc, we use this wrapper to fix the command line options
10 # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
11 ######################################################################
12 use strict;
13 my @args = ();
14 my @cflags = ();
15 my @lflags = ();
16 my $is_linking = 0;
17 my %linkflag = ( '-DEBUG' => 1, '-MAP' => 1 );
18 while (@ARGV) {
19 my $arg = shift @ARGV;
20 if ($linkflag{$arg}) {
21 push(@lflags, $arg);
22 } elsif ("$arg" =~ /^-[DIMGOWZ]/) {
23 push(@cflags, $arg);
24 } elsif ("$arg" eq "-o") {
25 my $file_out = shift @ARGV;
26 if ("$file_out" =~ /exe$/) {
27 $is_linking = 1;
28 push(@args, "-OUT:$file_out");
29 } else {
30 push(@args, "-Fo$file_out");
32 } elsif ("$arg" eq "-lz") {
33 push(@args, "zlib.lib");
34 } elsif ("$arg" eq "-liconv") {
35 push(@args, "iconv.lib");
36 } elsif ("$arg" eq "-lcrypto") {
37 push(@args, "libeay32.lib");
38 } elsif ("$arg" eq "-lssl") {
39 push(@args, "ssleay32.lib");
40 } elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
41 $arg =~ s/^-L/-LIBPATH:/;
42 push(@args, $arg);
43 } elsif ("$arg" =~ /^-R/) {
44 # eat
45 } else {
46 push(@args, $arg);
49 if ($is_linking) {
50 unshift(@args, "link.exe");
51 push(@args, @lflags);
52 } else {
53 unshift(@args, "cl.exe");
54 push(@args, @cflags);
56 #printf("**** @args\n");
57 exit (system(@args) != 0);