4 # Wrapper around MS's cl.exe and link.exe to make them act more like
7 # Copyright (C) 2000-2003 Geoffrey Wossum (gwossum@acm.org)
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 cccl is a wrapper around Microsoft's cl.exe and link.exe. It translates
30 parameters that Unix cc's and ld's understand to parameters that cl and link
36 # Put /usr/bin last in the path, to avoid clashes with MSVC's link
37 # Ugly workaround, but should work
38 PATH=`echo $PATH | sed -e "s#/usr/bin:##" | sed -e "s#/bin:##"`:/usr/bin
48 # prog specifies the program that should be run (cl.exe or link.exe)
49 # We'll assume cl to start out
51 # opts specifies the command line to pass to the MSVC program
52 clopt="${slash}nologo"
53 linkopt="${slash}nologo"
54 # gotparam is 0 if we didn't ever see a param, in which case we show usage()
58 clopt="$clopt ${slash}EHsc"
60 ### Run through every option and convert it to the proper MS one
61 while test $# -gt 0; do
64 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
74 Copyright 2000-2003 Geoffrey Wossum
75 This is free software; see the source for copying conditions. There is NO
76 waranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
82 clopt="$clopt ${slash}Za"
86 # -c (compile only) is actually the same, but for clarity...
87 clopt="$clopt ${slash}c"
91 # cl only supports one debugging level
92 clopt="$clopt ${slash}Zi"
93 linkopt="$linkopt ${slash}DEBUG"
97 path=`echo "$1" | sed 's/-L//'`
98 linkopt="$linkopt /LIBPATH:$path"
102 lib=`echo "$1" | sed 's/-l//'`
103 if [ $lib != "dnsapi" -a $lib != "ws2_32" -a $lib != "wsock32" ]; then
110 linkopt="$linkopt $lib"
114 clopt="$clopt ${slash}G3"
118 clopt="$clopt ${slash}G4"
122 clopt="$clopt ${slash}G5"
126 clopt="$clopt ${slash}G6"
130 # specifying output file, is it an object or an executable
134 clopt="$clopt ${slash}Fo$1"
137 clopt="$clopt ${slash}Fe$1";
138 linkopt="$linkopt ${slash}out:$1"
163 # C++ source file with non .cpp extension, make sure cl understand
165 clopt="$clopt ${slash}Tp$1"
168 *.o | *.obj | *.a | *.lib)
169 # Object files/libraries seen, this command will require link
170 # Switch the prog to link
171 linkopt="$linkopt $1"
177 linkopt="$linkopt $1"
178 if test x$optarg != x ; then
179 clopt="$clopt=$optarg"
180 linkopt="$linkopt=$optarg"
188 if test x$gotparam = x ; then
193 # choose which opts we built up based on which program will actually run
194 if test x$prog = xcl ; then