diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ibmscripts/cc	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,113 @@
+#!/bin/sh
+# cc - wrap the IBM compiler to look sort of like a unix compiler
+#      (and also to tidy up its output)
+# usage: cc [opts] sourcefile
+# options:
+#     -g	debug
+#     -O	optimize
+#     -fPIC	generate shared library code
+#     -Dsym	define preprocessor symbol SYM
+#     -Idir	add include path
+#     -c	compile only and don't link (required and assumed)
+#     -v	verbose
+#
+# Note that the behavior of -D is limited by the ability of the shell
+# to handle embedded spaces. It's meant to be only used in the style
+# "-DFOO".
+#
+
+OPT=nil
+SHLIB=
+ADDINC=
+FILE=
+DEFS=
+QUIET=1
+
+while [ x"$1" != x ]; do
+    case "$1" in
+	-g) OPT=debug;;
+	-O*) OPT=opt;;
+	-fPIC) SHLIB=/Ge-;;
+	-I*) ADDINC="${ADDINC};`echo "$1" | sed 's/^-I//'`";;
+	-D*) DEFS="$DEFS `echo "$1" | sed 's,^-D,/D,'`";;
+	-c) ;;
+	-v) QUIET=0;;
+	-*)
+	    echo "$0: unknown option $1" 1>&2
+	    exit 1
+	;;
+	*) FILE="$1";;
+    esac
+shift
+done
+
+if [ x"$FILE" = x ]; then
+    echo "$0: usage: $0 [options] sourcefile" 1>&2
+    exit 1
+fi
+
+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'
+export INCLUDE
+
+case "$ADDINC" in
+    \;*) ADDINC=`echo "$ADDINC" | sed 's,^;,/I,'`;;
+    *) ;;
+esac
+
+#
+# Used to use /O /Oc to optimize for size instead of speed
+# (doubtless because of the ship-on-a-floppy size limit)
+# For now I'm going to leave that off.
+#
+case "$OPT" in
+    nil) OPT=;;
+    debug) OPT="/Ti";;
+    opt) OPT="/O /Oc /Ti-";;
+esac
+
+
+# try:
+#     all+cls+cmp+cnd+cns+cnv+cpy+dcl+eff+enu+ext+gen+gnr+inl+lan
+#     obs+ord+par+por+ppc+pro+trd+tru+und+vft
+#
+# /Wgot?
+WARN='/Wini+rea+ret+uni+use'
+
+# /Sc seems like it would be a good idea but doesn't work...
+
+WINEPATH='I:\\ibmcppw\\bin'
+export WINEPATH
+
+LOG=`basename $FILE | sed 's/\.[a-z]*$//;s/$/.log/'`
+
+if [ $QUIET = 0 ]; then
+    echo wine 'I:\\ibmcppw\\bin\\icc.exe' "$ADDINC" /qmakedep /qtune=pentium \
+	/J- /Gl /Gm /Gu+ $DEFS $WARN $OPT $SHLIB \
+	/C "$FILE" '|' tee "$LOG"
+fi
+
+(
+    wine 'I:\\ibmcppw\\bin\\icc.exe' "$ADDINC" /qmakedep /qtune=pentium \
+	/J- /Gl /Gm /Gu+ $DEFS $WARN $OPT $SHLIB \
+	/C "$FILE"
+    echo "@@@Exit $?"
+) 2>&1 | tr -d '\r' | tee "$LOG" | (
+    if [ $QUIET = 1 ]; then
+      sed '
+        /^IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3\.5$/d
+        /^- Licensed Materials - Program-Property of IBM$/d
+        /^(C) Copyright IBM Corp. 1991, 1996 - All Rights Reserved.$/d
+      '
+    else
+      cat
+    fi
+) | awk '
+    /^@@@Exit [0-9][0-9]*$/ { exit($2); }
+
+    /^%0$/ { next; }
+    /^$/ { next; }
+    /%0$/ { sub("%0$", "", $0); printf "%s", $0; needeol=1; next; }
+    { print; needeol=0; }
+    END { if (needeol) printf "\n"; }
+
+' "q=$QUIET"