]> git.proxmox.com Git - mirror_ovs.git/blame - build-aux/cccl
ovs-fields: Correct ideas about which OXM classes are official.
[mirror_ovs.git] / build-aux / cccl
CommitLineData
c9b94429
GS
1#!/bin/sh
2
3# cccl
4# Wrapper around MS's cl.exe and link.exe to make them act more like
5# Unix cc and ld
6#
7# Copyright (C) 2000-2003 Geoffrey Wossum (gwossum@acm.org)
8#
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.
13#
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.
18#
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.
22#
23
24usage()
25{
26 cat <<EOF
27Usage: cccl [OPTIONS]
28
29cccl is a wrapper around Microsoft's cl.exe and link.exe. It translates
30parameters that Unix cc's and ld's understand to parameters that cl and link
31understand.
32EOF
33 exit $1
34}
35
c9b94429
GS
36case $MACHTYPE in
37 *-msys)
f4e0e094 38 slash="-"
c9b94429
GS
39 ;;
40 *)
41 slash="/"
42 ;;
43esac
44# prog specifies the program that should be run (cl.exe or link.exe)
45# We'll assume cl to start out
46prog=cl
47# opts specifies the command line to pass to the MSVC program
6b846da9 48clopt="${slash}nologo ${slash}FS"
c9b94429
GS
49linkopt="${slash}nologo"
50# gotparam is 0 if we didn't ever see a param, in which case we show usage()
51gotparam=
52
53# We want exceptions
54clopt="$clopt ${slash}EHsc"
55
56### Run through every option and convert it to the proper MS one
57while test $# -gt 0; do
58 case "$1" in
59 -D*) optarg= ;;
60 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
61 *) optarg= ;;
62 esac
63 gotparam=1
64
65 case "$1" in
66 --version)
67 cat <<EOF
68cccl 0.03
69
70Copyright 2000-2003 Geoffrey Wossum
71This is free software; see the source for copying conditions. There is NO
72waranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
73EOF
74 exit 1;
75 ;;
76
77 -ansi)
78 clopt="$clopt ${slash}Za"
79 ;;
80
81 -c)
82 # -c (compile only) is actually the same, but for clarity...
83 clopt="$clopt ${slash}c"
84 ;;
85
86 -g[0-9] | -g)
87 # cl only supports one debugging level
88 clopt="$clopt ${slash}Zi"
df85c520 89 linkopt="$linkopt ${slash}DEBUG"
c9b94429
GS
90 ;;
91
b0e1bce5 92 -O0)
6ad62eff 93 clopt="$clopt ${slash}Od ${slash}D_DEBUG ${slash}MTd"
b0e1bce5
GS
94 ;;
95
96 -O2)
6ad62eff 97 clopt="$clopt ${slash}O2 ${slash}MT"
b0e1bce5
GS
98 ;;
99
c9b94429
GS
100 -L*)
101 path=`echo "$1" | sed 's/-L//'`
94887cf4 102 linkopt="$linkopt ${slash}LIBPATH:$path"
b73d3fe2 103 cl_linkopt="${slash}link ${slash}LIBPATH:\"$path\""
c9b94429
GS
104 ;;
105
106 -l*)
107 lib=`echo "$1" | sed 's/-l//'`
278aa4c5 108 lib="$lib.lib"
c9b94429
GS
109
110 clopt="$clopt $lib"
111 linkopt="$linkopt $lib"
112 ;;
113
114 -m386)
115 clopt="$clopt ${slash}G3"
116 ;;
117
118 -m486)
119 clopt="$clopt ${slash}G4"
120 ;;
121
122 -mpentium)
123 clopt="$clopt ${slash}G5"
124 ;;
125
126 -mpentiumpro)
127 clopt="$clopt ${slash}G6"
128 ;;
129
130 -o)
131 # specifying output file, is it an object or an executable
132 shift
133 case "$1" in
134 *.o | *.obj)
135 clopt="$clopt ${slash}Fo$1"
136 ;;
137 *)
138 clopt="$clopt ${slash}Fe$1";
139 linkopt="$linkopt ${slash}out:$1"
140 ;;
141 esac;;
142
143 -pedantic)
144 #ignore pedantic
145 ;;
146
c8995761
AS
147 -Wall)
148 # not all warnings are implemented
149 # the following is equivalent to
150 # Wimplicit-function-declaration but we will issue a compiler
151 # error
152 clopt="$clopt ${slash}we4013"
153 ;;
154
c9b94429
GS
155 -W*)
156 #ignore warnings
157 ;;
158
dd92c616
AS
159 -Q*)
160 #ignore link warnings
161 ;;
162
c47bb435
AS
163 -fno-strict-aliasing*)
164 #ignore aliasing
165 ;;
166
c9b94429
GS
167 -isystem)
168 shift
169 clopt="$clopt -I$1"
170 ;;
171
172 -MT)
173 exit 0
174 ;;
175
176 -mno-cygwin)
177 ;;
178
179 *.cc | *.cxx | *.C)
180 # C++ source file with non .cpp extension, make sure cl understand
181 # that it is C++
182 clopt="$clopt ${slash}Tp$1"
183 ;;
184
185 *.o | *.obj | *.a | *.lib)
186 # Object files/libraries seen, this command will require link
187 # Switch the prog to link
188 linkopt="$linkopt $1"
189 prog="link"
190 ;;
191
192 *)
193 clopt="$clopt $1"
194 linkopt="$linkopt $1"
195 if test x$optarg != x ; then
196 clopt="$clopt=$optarg"
197 linkopt="$linkopt=$optarg"
198 fi
199 ;;
200
201 esac
202 shift
203done
204
205if test x$gotparam = x ; then
206 usage
207 exit 1
208fi
209
210# choose which opts we built up based on which program will actually run
211if test x$prog = xcl ; then
b73d3fe2 212 opts="$clopt $cl_linkopt"
c9b94429
GS
213else
214 opts=$linkopt
215fi
216
819e3cde
JS
217if test x$V = x1 ; then
218 echo "$prog $opts"
219fi
c9b94429
GS
220exec $prog $opts
221exit 0