1#!/usr/bin/perl -w 2###################################################################### 3# Compiles or links files 4# 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 9# 10# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> 11###################################################################### 12use strict; 13my@args= (); 14my@cflags= (); 15my$is_linking=0; 16while(@ARGV) { 17my$arg=shift@ARGV; 18if("$arg"=~/^-[DIMGO]/) { 19push(@cflags,$arg); 20}elsif("$arg"eq"-o") { 21my$file_out=shift@ARGV; 22if("$file_out"=~/exe$/) { 23$is_linking=1; 24push(@args,"-OUT:$file_out"); 25}else{ 26push(@args,"-Fo$file_out"); 27} 28}elsif("$arg"eq"-lz") { 29push(@args,"zlib.lib"); 30}elsif("$arg"eq"-liconv") { 31push(@args,"iconv.lib"); 32}elsif("$arg"eq"-lcrypto") { 33push(@args,"libeay32.lib"); 34}elsif("$arg"eq"-lssl") { 35push(@args,"ssleay32.lib"); 36}elsif("$arg"=~/^-L/&&"$arg"ne"-LTCG") { 37$arg=~s/^-L/-LIBPATH:/; 38push(@args,$arg); 39}elsif("$arg"=~/^-R/) { 40# eat 41}else{ 42push(@args,$arg); 43} 44} 45if($is_linking) { 46unshift(@args,"link.exe"); 47}else{ 48unshift(@args,"cl.exe"); 49push(@args,@cflags); 50} 51#printf("**** @args\n"); 52exit(system(@args) !=0);