6252
|
1 |
--- /dev/null 2005-11-02 20:00:47.000000000 -0500
|
|
2 |
+++ python/pycc 2005-11-02 19:21:08.963427000 -0500
|
|
3 |
@@ -0,0 +1,128 @@
|
6215
|
4 |
+#!/bin/ksh
|
|
5 |
+#
|
|
6 |
+# Script for running the C/C++ compiler when building python modules
|
|
7 |
+#
|
|
8 |
+# CDDL HEADER START
|
|
9 |
+#
|
|
10 |
+# The contents of this file are subject to the terms of the
|
|
11 |
+# Common Development and Distribution License, Version 1.0 only
|
|
12 |
+# (the "License"). You may not use this file except in compliance
|
|
13 |
+# with the License.
|
|
14 |
+#
|
|
15 |
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
16 |
+# or http://www.opensolaris.org/os/licensing.
|
|
17 |
+# See the License for the specific language governing permissions
|
|
18 |
+# and limitations under the License.
|
|
19 |
+#
|
|
20 |
+# When distributing Covered Code, include this CDDL HEADER in each
|
|
21 |
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
22 |
+# If applicable, add the following below this CDDL HEADER, with the
|
|
23 |
+# fields enclosed by brackets "[]" replaced with your own identifying
|
|
24 |
+# information: Portions Copyright [yyyy] [name of copyright owner]
|
|
25 |
+#
|
|
26 |
+# CDDL HEADER END
|
|
27 |
+#
|
|
28 |
+#
|
|
29 |
+# Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
|
|
30 |
+# Use is subject to license terms.
|
|
31 |
+#
|
|
32 |
+
|
|
33 |
+MYNAME=`basename $0`
|
|
34 |
+
|
|
35 |
+# name of the compiler executable
|
|
36 |
+CCEXE='cc'
|
|
37 |
+# name of the GNU compiler executable
|
|
38 |
+GCCEXE='gcc'
|
|
39 |
+# name of the programming language
|
|
40 |
+CLANG='C'
|
|
41 |
+# name of the env variable for setting the compiler path
|
|
42 |
+CVAR='CC'
|
|
43 |
+
|
|
44 |
+if [ "x$MYNAME" = xpyCC ]; then
|
|
45 |
+ CCEXE='CC'
|
|
46 |
+ GCCEXE='g++'
|
|
47 |
+ CLANG='C++'
|
|
48 |
+ CC="$CXX"
|
|
49 |
+ CVAR='CXX'
|
|
50 |
+fi
|
|
51 |
+
|
|
52 |
+# check if the CC env variable is set
|
|
53 |
+if [ "x$CC" != x ]; then
|
6252
|
54 |
+ case "$CC" in
|
|
55 |
+ /* )
|
|
56 |
+ # $CC is an absolute path name
|
|
57 |
+ # check if $CC exists
|
|
58 |
+ if [ ! -e "$CC" ]; then
|
|
59 |
+ echo "WARNING: pycc: $CC not found" 1>&2
|
|
60 |
+ CC=
|
|
61 |
+ else
|
6215
|
62 |
+ # check if $CC is an executable
|
6252
|
63 |
+ if [ ! -x "$CC" -o ! -f "$CC" ]; then
|
|
64 |
+ echo "WARNING: pycc: $CC is not an executable" 1>&2
|
|
65 |
+ CC=
|
|
66 |
+ fi
|
|
67 |
+ fi
|
|
68 |
+ ;;
|
|
69 |
+ * )
|
|
70 |
+ # try to find $CC in the PATH
|
|
71 |
+ IFS=:
|
|
72 |
+ NEW_CC=
|
|
73 |
+ for dir in $PATH; do
|
|
74 |
+ if [ -x "$dir/$CC" ]; then
|
|
75 |
+ NEW_CC="$dir/$CC"
|
|
76 |
+ break
|
|
77 |
+ fi
|
|
78 |
+ done
|
|
79 |
+ if [ "x$NEW_CC" = x ]; then
|
|
80 |
+ echo "WARNING: pycc: $CC not found" 1>&2
|
|
81 |
+ CC=
|
|
82 |
+ else
|
|
83 |
+ CC="$NEW_CC"
|
|
84 |
+ fi
|
|
85 |
+ ;;
|
|
86 |
+ esac
|
6215
|
87 |
+fi
|
|
88 |
+
|
|
89 |
+if [ "x$CC" == x ]; then
|
|
90 |
+ # Look for the Sun Studio compiler in the PATH
|
|
91 |
+ IFS=:
|
|
92 |
+ for dir in $PATH; do
|
|
93 |
+ if [ -x "$dir/$CCEXE" ]; then
|
|
94 |
+ CC="$dir/$CCEXE"
|
|
95 |
+ break
|
|
96 |
+ fi
|
|
97 |
+ done
|
|
98 |
+fi
|
|
99 |
+
|
|
100 |
+if [ "x$CC" == x ]; then
|
|
101 |
+ # Look for gcc in the PATH
|
|
102 |
+ IFS=:
|
|
103 |
+ for dir in $PATH; do
|
|
104 |
+ if [ -x "$dir/$GCCEXE" ]; then
|
|
105 |
+ CC="$dir/$GCCEXE"
|
|
106 |
+ break
|
|
107 |
+ fi
|
|
108 |
+ done
|
|
109 |
+fi
|
|
110 |
+
|
|
111 |
+if [ "x$CC" == x ]; then
|
|
112 |
+ # Check for Sun Studio in /opt/SUNWspro (default install location)
|
|
113 |
+ if [ -x /opt/SUNWspro/bin/$CCEXE ]; then
|
|
114 |
+ CC=/opt/SUNWspro/bin/$CCEXE
|
|
115 |
+ fi
|
|
116 |
+fi
|
|
117 |
+
|
|
118 |
+if [ "x$CC" == x ]; then
|
|
119 |
+ # Check for the GNU compiler in /usr/sfw/bin
|
|
120 |
+ if [ -x /usr/sfw/bin/$GCCEXE ]; then
|
|
121 |
+ CC=/usr/sfw/bin/$GCCEXE
|
|
122 |
+ fi
|
|
123 |
+fi
|
|
124 |
+
|
|
125 |
+if [ "x$CC" == x ]; then
|
|
126 |
+ # Cannot continue without a C compiler
|
|
127 |
+ echo "ERROR: no $CLANG compiler not found; update your PATH or set the $CVAR env variable" 1>&2
|
|
128 |
+ exit 1
|
|
129 |
+fi
|
|
130 |
+
|
|
131 |
+exec "$CC" "${@}"
|