author | lp117937 |
Mon, 18 Sep 2006 23:09:23 +0000 | |
changeset 8162 | ab63e00d2219 |
parent 6252 | 847e00ae80d8 |
child 8944 | a63e00e81443 |
permissions | -rw-r--r-- |
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
1 |
--- /dev/null 2006-08-24 06:34:26.000000000 -0700 |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
2 |
+++ Python-2.4.2-new/pycc 2006-08-24 06:37:41.077704000 -0700 |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
3 |
@@ -0,0 +1,156 @@ |
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 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
52 |
+SAVED_IFS="$IFS" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
53 |
+IFS=: |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
54 |
+ |
6215 | 55 |
+# check if the CC env variable is set |
56 |
+if [ "x$CC" != x ]; then |
|
6252 | 57 |
+ case "$CC" in |
58 |
+ /* ) |
|
59 |
+ # $CC is an absolute path name |
|
60 |
+ # check if $CC exists |
|
61 |
+ if [ ! -e "$CC" ]; then |
|
62 |
+ echo "WARNING: pycc: $CC not found" 1>&2 |
|
63 |
+ CC= |
|
64 |
+ else |
|
6215 | 65 |
+ # check if $CC is an executable |
6252 | 66 |
+ if [ ! -x "$CC" -o ! -f "$CC" ]; then |
67 |
+ echo "WARNING: pycc: $CC is not an executable" 1>&2 |
|
68 |
+ CC= |
|
69 |
+ fi |
|
70 |
+ fi |
|
71 |
+ ;; |
|
72 |
+ * ) |
|
73 |
+ # try to find $CC in the PATH |
|
74 |
+ NEW_CC= |
|
75 |
+ for dir in $PATH; do |
|
76 |
+ if [ -x "$dir/$CC" ]; then |
|
77 |
+ NEW_CC="$dir/$CC" |
|
78 |
+ break |
|
79 |
+ fi |
|
80 |
+ done |
|
81 |
+ if [ "x$NEW_CC" = x ]; then |
|
82 |
+ echo "WARNING: pycc: $CC not found" 1>&2 |
|
83 |
+ CC= |
|
84 |
+ else |
|
85 |
+ CC="$NEW_CC" |
|
86 |
+ fi |
|
87 |
+ ;; |
|
88 |
+ esac |
|
6215 | 89 |
+fi |
90 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
91 |
+if [ "x$CC" = x ]; then |
6215 | 92 |
+ # Look for the Sun Studio compiler in the PATH |
93 |
+ for dir in $PATH; do |
|
94 |
+ if [ -x "$dir/$CCEXE" ]; then |
|
95 |
+ CC="$dir/$CCEXE" |
|
96 |
+ break |
|
97 |
+ fi |
|
98 |
+ done |
|
99 |
+fi |
|
100 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
101 |
+if [ "x$CC" = x ]; then |
6215 | 102 |
+ # Look for gcc in the PATH |
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 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
111 |
+if [ "x$CC" = x ]; then |
6215 | 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 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
118 |
+if [ "x$CC" = x ]; then |
6215 | 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 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
125 |
+if [ "x$CC" = x ]; then |
6215 | 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 |
+ |
|
8162
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
131 |
+IFS="$SAVED_IFS" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
132 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
133 |
+# We need to make some modifications to adapt correctly to compiler options |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
134 |
+# that differ between GCC and Studio. |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
135 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
136 |
+extra_flags= |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
137 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
138 |
+is_gcc=no |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
139 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
140 |
+$CC --version >/dev/null 2>&1 && is_gcc=yes |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
141 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
142 |
+if [ "$is_gcc" = yes ]; then |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
143 |
+ for flag in "${@}"; do |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
144 |
+ # need -shared to link shared objects properly |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
145 |
+ if [ "$flag" = "-G" ]; then |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
146 |
+ extra_flags="$extra_flags -shared" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
147 |
+ fi |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
148 |
+ # workaround for 6223255 |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
149 |
+ if [ "$flag" = "-m64" ]; then |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
150 |
+ extra_flags="$extra_flags -R/usr/sfw/lib/amd64" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
151 |
+ fi |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
152 |
+ done |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
153 |
+ # force PIC compilation |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
154 |
+ extra_flags="$extra_flags -fPIC -DPIC" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
155 |
+else |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
156 |
+ extra_flags="$extra_flags -KPIC" |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
157 |
+fi |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
158 |
+ |
ab63e00d2219
2006-09-18 Laszlo (Laca) Peter <[email protected]>
lp117937
parents:
6252
diff
changeset
|
159 |
+exec "$CC" $extra_flags "${@}" |