]> git.proxmox.com Git - mirror_ovs.git/blame - build-aux/cccl
nroff: Fix style of names.
[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)
0d42597c 93 clopt="$clopt ${slash}Od ${slash}D_DEBUG"
b0e1bce5
GS
94 ;;
95
96 -O2)
97 clopt="$clopt ${slash}O2"
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
147 -W*)
148 #ignore warnings
149 ;;
150
dd92c616
AS
151 -Q*)
152 #ignore link warnings
153 ;;
154
c47bb435
AS
155 -fno-strict-aliasing*)
156 #ignore aliasing
157 ;;
158
c9b94429
GS
159 -isystem)
160 shift
161 clopt="$clopt -I$1"
162 ;;
163
164 -MT)
165 exit 0
166 ;;
167
168 -mno-cygwin)
169 ;;
170
171 *.cc | *.cxx | *.C)
172 # C++ source file with non .cpp extension, make sure cl understand
173 # that it is C++
174 clopt="$clopt ${slash}Tp$1"
175 ;;
176
177 *.o | *.obj | *.a | *.lib)
178 # Object files/libraries seen, this command will require link
179 # Switch the prog to link
180 linkopt="$linkopt $1"
181 prog="link"
182 ;;
183
184 *)
185 clopt="$clopt $1"
186 linkopt="$linkopt $1"
187 if test x$optarg != x ; then
188 clopt="$clopt=$optarg"
189 linkopt="$linkopt=$optarg"
190 fi
191 ;;
192
193 esac
194 shift
195done
196
197if test x$gotparam = x ; then
198 usage
199 exit 1
200fi
201
202# choose which opts we built up based on which program will actually run
203if test x$prog = xcl ; then
b73d3fe2 204 opts="$clopt $cl_linkopt"
c9b94429
GS
205else
206 opts=$linkopt
207fi
208
819e3cde
JS
209if test x$V = x1 ; then
210 echo "$prog $opts"
211fi
c9b94429
GS
212exec $prog $opts
213exit 0