Mercurial > ~dholland > hg > ag > index.cgi
comparison ibmscripts/cc @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | a4899cdfc2d6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 #!/bin/sh | |
2 # cc - wrap the IBM compiler to look sort of like a unix compiler | |
3 # (and also to tidy up its output) | |
4 # usage: cc [opts] sourcefile | |
5 # options: | |
6 # -g debug | |
7 # -O optimize | |
8 # -fPIC generate shared library code | |
9 # -Dsym define preprocessor symbol SYM | |
10 # -Idir add include path | |
11 # -c compile only and don't link (required and assumed) | |
12 # -v verbose | |
13 # | |
14 # Note that the behavior of -D is limited by the ability of the shell | |
15 # to handle embedded spaces. It's meant to be only used in the style | |
16 # "-DFOO". | |
17 # | |
18 | |
19 OPT=nil | |
20 SHLIB= | |
21 ADDINC= | |
22 FILE= | |
23 DEFS= | |
24 QUIET=1 | |
25 | |
26 while [ x"$1" != x ]; do | |
27 case "$1" in | |
28 -g) OPT=debug;; | |
29 -O*) OPT=opt;; | |
30 -fPIC) SHLIB=/Ge-;; | |
31 -I*) ADDINC="${ADDINC};`echo "$1" | sed 's/^-I//'`";; | |
32 -D*) DEFS="$DEFS `echo "$1" | sed 's,^-D,/D,'`";; | |
33 -c) ;; | |
34 -v) QUIET=0;; | |
35 -*) | |
36 echo "$0: unknown option $1" 1>&2 | |
37 exit 1 | |
38 ;; | |
39 *) FILE="$1";; | |
40 esac | |
41 shift | |
42 done | |
43 | |
44 if [ x"$FILE" = x ]; then | |
45 echo "$0: usage: $0 [options] sourcefile" 1>&2 | |
46 exit 1 | |
47 fi | |
48 | |
49 INCLUDE='I:\\ibmcppw\\bindings;I:\\ibmcppw\\include;I:\\ibmcppw\\sdk\\winh;I:\\ibmcppw\\sdk\\winh\\winnt;I:\\ibmcppw\\sdk\\winh\\win95;I:\\ibmcppw\\lib;I:\\ibmcppw\\sdk\\lib' | |
50 export INCLUDE | |
51 | |
52 case "$ADDINC" in | |
53 \;*) ADDINC=`echo "$ADDINC" | sed 's,^;,/I,'`;; | |
54 *) ;; | |
55 esac | |
56 | |
57 # | |
58 # Used to use /O /Oc to optimize for size instead of speed | |
59 # (doubtless because of the ship-on-a-floppy size limit) | |
60 # For now I'm going to leave that off. | |
61 # | |
62 case "$OPT" in | |
63 nil) OPT=;; | |
64 debug) OPT="/Ti";; | |
65 opt) OPT="/O /Oc /Ti-";; | |
66 esac | |
67 | |
68 | |
69 # try: | |
70 # all+cls+cmp+cnd+cns+cnv+cpy+dcl+eff+enu+ext+gen+gnr+inl+lan | |
71 # obs+ord+par+por+ppc+pro+trd+tru+und+vft | |
72 # | |
73 # /Wgot? | |
74 WARN='/Wini+rea+ret+uni+use' | |
75 | |
76 # /Sc seems like it would be a good idea but doesn't work... | |
77 | |
78 WINEPATH='I:\\ibmcppw\\bin' | |
79 export WINEPATH | |
80 | |
81 LOG=`basename $FILE | sed 's/\.[a-z]*$//;s/$/.log/'` | |
82 | |
83 if [ $QUIET = 0 ]; then | |
84 echo wine 'I:\\ibmcppw\\bin\\icc.exe' "$ADDINC" /qmakedep /qtune=pentium \ | |
85 /J- /Gl /Gm /Gu+ $DEFS $WARN $OPT $SHLIB \ | |
86 /C "$FILE" '|' tee "$LOG" | |
87 fi | |
88 | |
89 ( | |
90 wine 'I:\\ibmcppw\\bin\\icc.exe' "$ADDINC" /qmakedep /qtune=pentium \ | |
91 /J- /Gl /Gm /Gu+ $DEFS $WARN $OPT $SHLIB \ | |
92 /C "$FILE" | |
93 echo "@@@Exit $?" | |
94 ) 2>&1 | tr -d '\r' | tee "$LOG" | ( | |
95 if [ $QUIET = 1 ]; then | |
96 sed ' | |
97 /^IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3\.5$/d | |
98 /^- Licensed Materials - Program-Property of IBM$/d | |
99 /^(C) Copyright IBM Corp. 1991, 1996 - All Rights Reserved.$/d | |
100 ' | |
101 else | |
102 cat | |
103 fi | |
104 ) | awk ' | |
105 /^@@@Exit [0-9][0-9]*$/ { exit($2); } | |
106 | |
107 /^%0$/ { next; } | |
108 /^$/ { next; } | |
109 /%0$/ { sub("%0$", "", $0); printf "%s", $0; needeol=1; next; } | |
110 { print; needeol=0; } | |
111 END { if (needeol) printf "\n"; } | |
112 | |
113 ' "q=$QUIET" |