14032N/A--- /dev/null 2007-01-09 14:33:27.000000000 -0500
14032N/A+++ Python-2.4.4-new/pycc 2007-01-09 14:34:30.248866916 -0500
14032N/A@@ -0,0 +1,172 @@
14032N/A+#!/bin/ksh
14032N/A+#
14032N/A+# Script for running the C/C++ compiler when building python modules
14032N/A+#
14032N/A+# CDDL HEADER START
14032N/A+#
14032N/A+# The contents of this file are subject to the terms of the
14032N/A+# Common Development and Distribution License, Version 1.0 only
14032N/A+# (the "License"). You may not use this file except in compliance
14032N/A+# with the License.
14032N/A+#
14032N/A+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14032N/A+# or http://www.opensolaris.org/os/licensing.
14032N/A+# See the License for the specific language governing permissions
14032N/A+# and limitations under the License.
14032N/A+#
14032N/A+# When distributing Covered Code, include this CDDL HEADER in each
14032N/A+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14032N/A+# If applicable, add the following below this CDDL HEADER, with the
14032N/A+# fields enclosed by brackets "[]" replaced with your own identifying
14032N/A+# information: Portions Copyright [yyyy] [name of copyright owner]
14032N/A+#
14032N/A+# CDDL HEADER END
14032N/A+#
14032N/A+#
14032N/A+# Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
14032N/A+# Use is subject to license terms.
14032N/A+#
14032N/A+
14032N/A+MYNAME=`basename $0`
14032N/A+
14032N/A+# name of the compiler executable
14032N/A+CCEXE='cc'
14032N/A+# name of the GNU compiler executable
14032N/A+GCCEXE='gcc'
14032N/A+# name of the programming language
14032N/A+CLANG='C'
14032N/A+# name of the env variable for setting the compiler path
14032N/A+CVAR='CC'
14032N/A+
14032N/A+if [ "x$PYCC_CC" != x ]; then
14032N/A+ CC="$PYCC_CC"
14032N/A+fi
14032N/A+
14032N/A+if [ "x$MYNAME" = xpyCC ]; then
14032N/A+ CCEXE='CC'
14032N/A+ GCCEXE='g++'
14032N/A+ CLANG='C++'
14032N/A+ CC="$CXX"
14032N/A+ CVAR='CXX'
14032N/A+ if [ "x$PYCC_CXX" != x ]; then
14032N/A+ CC="$PYCC_CXX"
14032N/A+ fi
14032N/A+fi
14032N/A+
14032N/A+SAVED_IFS="$IFS"
14032N/A+IFS=:
14032N/A+
14032N/A+# check if the CC env variable is set
14032N/A+if [ "x$CC" != x ]; then
14032N/A+ # verify that it doesn't point to this script
14032N/A+ if /usr/bin/cmp -s "$CC" $0; then
14032N/A+ echo "WARNING: "$CVAR" is set to this script; ignoring this value to avoid an infinite loop"
14032N/A+ CC=
14032N/A+ fi
14032N/A+fi
14032N/A+
14032N/A+# check again if the CC env variable is set
14032N/A+if [ "x$CC" != x ]; then
14032N/A+ case "$CC" in
14032N/A+ /* )
14032N/A+ # $CC is an absolute path name
14032N/A+ # check if $CC exists
14032N/A+ if [ ! -e "$CC" ]; then
14032N/A+ echo "WARNING: pycc: $CC not found" 1>&2
14032N/A+ CC=
14032N/A+ else
14032N/A+ # check if $CC is an executable
14032N/A+ if [ ! -x "$CC" -o ! -f "$CC" ]; then
14032N/A+ echo "WARNING: pycc: $CC is not an executable" 1>&2
14032N/A+ CC=
14032N/A+ fi
14032N/A+ fi
14032N/A+ ;;
14032N/A+ * )
14032N/A+ # try to find $CC in the PATH
14032N/A+ NEW_CC=
14032N/A+ for dir in $PATH; do
14032N/A+ if [ -x "$dir/$CC" ]; then
14032N/A+ NEW_CC="$dir/$CC"
14032N/A+ break
14032N/A+ fi
14032N/A+ done
14032N/A+ if [ "x$NEW_CC" = x ]; then
14032N/A+ echo "WARNING: pycc: $CC not found" 1>&2
14032N/A+ CC=
14032N/A+ else
14032N/A+ CC="$NEW_CC"
14032N/A+ fi
14032N/A+ ;;
14032N/A+ esac
14032N/A+fi
14032N/A+
14032N/A+if [ "x$CC" = x ]; then
14032N/A+ # Look for the Sun Studio compiler in the PATH
14032N/A+ for dir in $PATH; do
14032N/A+ if [ -x "$dir/$CCEXE" ]; then
14032N/A+ CC="$dir/$CCEXE"
14032N/A+ break
14032N/A+ fi
14032N/A+ done
14032N/A+fi
14032N/A+
14032N/A+if [ "x$CC" = x ]; then
14032N/A+ # Look for gcc in the PATH
14032N/A+ for dir in $PATH; do
14032N/A+ if [ -x "$dir/$GCCEXE" ]; then
14032N/A+ CC="$dir/$GCCEXE"
14032N/A+ break
14032N/A+ fi
14032N/A+ done
14032N/A+fi
14032N/A+
14032N/A+if [ "x$CC" = x ]; then
14032N/A+ # Check for Sun Studio in /opt/SUNWspro (default install location)
14032N/A+ if [ -x /opt/SUNWspro/bin/$CCEXE ]; then
14032N/A+ CC=/opt/SUNWspro/bin/$CCEXE
14032N/A+ fi
14032N/A+fi
14032N/A+
14032N/A+if [ "x$CC" = x ]; then
14032N/A+ # Check for the GNU compiler in /usr/sfw/bin
14032N/A+ if [ -x /usr/sfw/bin/$GCCEXE ]; then
14032N/A+ CC=/usr/sfw/bin/$GCCEXE
14032N/A+ fi
14032N/A+fi
14032N/A+
14032N/A+if [ "x$CC" = x ]; then
14032N/A+ # Cannot continue without a C compiler
14032N/A+ echo "ERROR: no $CLANG compiler not found; update your PATH or set the $CVAR env variable" 1>&2
14032N/A+ exit 1
14032N/A+fi
14032N/A+
14032N/A+IFS="$SAVED_IFS"
14032N/A+
14032N/A+# We need to make some modifications to adapt correctly to compiler options
14032N/A+# that differ between GCC and Studio.
14032N/A+
14032N/A+extra_flags=
14032N/A+
14032N/A+is_gcc=no
14032N/A+
14032N/A+$CC --version >/dev/null 2>&1 && is_gcc=yes
14032N/A+
14032N/A+if [ "$is_gcc" = yes ]; then
14032N/A+ for flag in "${@}"; do
14032N/A+ # need -shared to link shared objects properly
14032N/A+ if [ "$flag" = "-G" ]; then
14032N/A+ extra_flags="$extra_flags -shared"
14032N/A+ fi
14032N/A+ # workaround for 6223255
14032N/A+ if [ "$flag" = "-m64" ]; then
14032N/A+ extra_flags="$extra_flags -R/usr/sfw/lib/amd64"
14032N/A+ fi
14032N/A+ done
14032N/A+ # force PIC compilation
14032N/A+ extra_flags="$extra_flags -fPIC -DPIC"
14032N/A+else
14032N/A+ extra_flags="$extra_flags -KPIC"
14032N/A+fi
14032N/A+
14032N/A+exec "$CC" $extra_flags "${@}"