1 #!/bin/bash |
|
2 |
|
3 # |
|
4 # CDDL HEADER START |
|
5 # |
|
6 # The contents of this file are subject to the terms of the |
|
7 # Common Development and Distribution License (the "License"). |
|
8 # You may not use this file except in compliance with the License. |
|
9 # |
|
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
11 # or http://www.opensolaris.org/os/licensing. |
|
12 # See the License for the specific language governing permissions |
|
13 # and limitations under the License. |
|
14 # |
|
15 # When distributing Covered Code, include this CDDL HEADER in each |
|
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
17 # If applicable, add the following below this CDDL HEADER, with the |
|
18 # fields enclosed by brackets "[]" replaced with your own identifying |
|
19 # information: Portions Copyright [yyyy] [name of copyright owner] |
|
20 # |
|
21 # CDDL HEADER END |
|
22 # |
|
23 # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
|
24 # |
|
25 |
|
26 PROTODIR="" |
|
27 PYTHON="" |
|
28 INSTALLDIR="" |
|
29 LIBGCCDIR="" |
|
30 MACH="`uname -p`" |
|
31 SED="/usr/gnu/bin/sed" |
|
32 STRIP="/usr/bin/strip -x" |
|
33 # Solaris 11 uname does not support -o |
|
34 UNAME="/usr/gnu/bin/uname" |
|
35 GCC_FULL_VERSION="" |
|
36 |
|
37 UNKNOWN_ARG=yes |
|
38 PRINT_HELP=no |
|
39 |
|
40 while [ "$#" -gt 0 ] ; do |
|
41 UNKNOWN_ARG=no |
|
42 case "$1" in |
|
43 -protodir=*) |
|
44 export PROTODIR=`echo $1 | ${SED} "s,^-protodir=\(.*\),\1,"` |
|
45 ;; |
|
46 -python=*) |
|
47 export PYTHON=`echo $1 | ${SED} "s,^-python=\(.*\),\1,"` |
|
48 ;; |
|
49 -gccversion=*) |
|
50 export GCC_FULL_VERSION=`echo $1 | ${SED} "s,^-gccversion=\(.*\),\1,"` |
|
51 ;; |
|
52 *) |
|
53 UNKNOWN_ARG=yes |
|
54 ;; |
|
55 esac |
|
56 |
|
57 if [ "$UNKNOWN_ARG" = "yes" ] ; then |
|
58 echo "$1: Invalid argument" |
|
59 PRINT_HELP=yes |
|
60 shift |
|
61 continue |
|
62 fi |
|
63 shift |
|
64 done |
|
65 |
|
66 if [ "$PRINT_HELP" = "yes" ] || [ "$UNKNOWN_ARG" = "yes" ] ; then |
|
67 echo "" |
|
68 echo "Usage: `basename $0` -protodir=[ build area prototype directory ]" |
|
69 echo " -python=[ Python interpreter to use ]" |
|
70 echo "" |
|
71 exit 1 |
|
72 fi |
|
73 |
|
74 if [ ${MACH} = "i386" ] ; then |
|
75 export MACH64="amd64" |
|
76 export VENDOR="pc" |
|
77 else |
|
78 export MACH64="sparcv9" |
|
79 export VENDOR="sun" |
|
80 fi |
|
81 |
|
82 gcc_maj="`echo ${GCC_FULL_VERSION} | cut -d . -f 1`" |
|
83 gcc_min="`echo ${GCC_FULL_VERSION} | cut -d . -f 2`" |
|
84 GCC_VERSION="${gcc_maj}.${gcc_min}" |
|
85 |
|
86 export RELEASE="`${UNAME} -r | cut -d . -f 2`" |
|
87 export OS="`${UNAME} -o | /usr/gnu/bin/tr -s '[:upper:]' '[:lower:]'`" |
|
88 export GCC_TRIPLE="${MACH}-${VENDOR}-${OS}2.${RELEASE}" |
|
89 |
|
90 export MACH MACH64 SED STRIP GCC_VERSION GCC_FULL_VERSION PYTHON |
|
91 |
|
92 export BINDIR="${PROTODIR}/usr/gcc/${GCC_VERSION}/bin" |
|
93 export LIBDIR="${PROTODIR}/usr/gcc/${GCC_VERSION}/lib" |
|
94 export LIB64DIR="${PROTODIR}/usr/gcc/${GCC_VERSION}/lib/${MACH64}" |
|
95 export GCCSHAREDIR="${PROTODIR}/usr/gcc/${GCC_VERSION}/share" |
|
96 export GCCUSRSHAREDIR="${PROTODIR}/usr/share/gcc-${GCC_FULL_VERSION}" |
|
97 export GDBSHAREDIR="${PROTODIR}/usr/share/gdb" |
|
98 export LIBGCCDIR="${PROTODIR}/usr/gcc/${GCC_VERSION}/lib/gcc" |
|
99 export GCCTRIPLEDIR="${LIBGCCDIR}/${GCC_TRIPLE}/${GCC_FULL_VERSION}" |
|
100 export LIBTRIPLEDIR="${LIBDIR}/gcc/${GCC_TRIPLE}/${GCC_FULL_VERSION}" |
|
101 |
|
102 echo "Stripping GCC binaries ... " |
|
103 |
|
104 for file in \ |
|
105 c++ \ |
|
106 cpp \ |
|
107 g++ \ |
|
108 gcc \ |
|
109 gcc-ar \ |
|
110 gcc-nm \ |
|
111 gcc-ranlib \ |
|
112 gcov \ |
|
113 gfortran \ |
|
114 ${GCC_TRIPLE}-c++ \ |
|
115 ${GCC_TRIPLE}-g++ \ |
|
116 ${GCC_TRIPLE}-gcc \ |
|
117 ${GCC_TRIPLE}-gcc-${GCC_FULL_VERSION} \ |
|
118 ${GCC_TRIPLE}-gcc-ar \ |
|
119 ${GCC_TRIPLE}-gcc-nm \ |
|
120 ${GCC_TRIPLE}-gcc-ranlib \ |
|
121 ${GCC_TRIPLE}-gfortran |
|
122 do |
|
123 ${STRIP} ${BINDIR}/${file} |
|
124 done |
|
125 |
|
126 for file in \ |
|
127 libgfortran.so.3.0.0 \ |
|
128 libgomp.so.1.0.0 \ |
|
129 libitm.so.1.0.0 \ |
|
130 libobjc.so.4.0.0 \ |
|
131 libssp.so.0.0.0 |
|
132 do |
|
133 ${STRIP} ${LIBDIR}/${file} |
|
134 ${STRIP} ${LIB64DIR}/${file} |
|
135 done |
|
136 |
|
137 # libquadmath is not available on SPARC. |
|
138 if [ "${MACH}" = "i386" ] ; then |
|
139 ${STRIP} ${LIBDIR}/libquadmath.so.0.0.0 |
|
140 ${STRIP} ${LIB64DIR}/libquadmath.so.0.0.0 |
|
141 fi |
|
142 |
|
143 for file in \ |
|
144 cc1 \ |
|
145 cc1obj \ |
|
146 cc1plus \ |
|
147 collect2 \ |
|
148 f951 \ |
|
149 liblto_plugin.so.0.0.0 \ |
|
150 lto-wrapper \ |
|
151 lto1 |
|
152 do |
|
153 ${STRIP} ${GCCTRIPLEDIR}/${file} |
|
154 done |
|
155 |
|
156 echo "... Done." |
|
157 echo "" |
|
158 echo "Copying GCC's gdb Python files ... " |
|
159 |
|
160 mkdir -p ${GDBSHAREDIR}/auto-load/usr/lib/${MACH64} |
|
161 mkdir -p ${GCCUSRSHAREDIR}/python/libstdcxx/v6 |
|
162 |
|
163 cp -p ${LIBDIR}/libstdc++.so.6.0.17-gdb.py ${GDBSHAREDIR}/auto-load/usr/lib/ |
|
164 cp -p ${LIB64DIR}/libstdc++.so.6.0.17-gdb.py ${GDBSHAREDIR}/auto-load/usr/lib/${MACH64} |
|
165 cp -p ${GCCSHAREDIR}/gcc-${GCC_FULL_VERSION}/python/libstdcxx/__init__.py \ |
|
166 ${GCCUSRSHAREDIR}/python/libstdcxx/ |
|
167 cp -p ${GCCSHAREDIR}/gcc-${GCC_FULL_VERSION}/python/libstdcxx/v6/__init__.py \ |
|
168 ${GCCUSRSHAREDIR}/python/libstdcxx/v6/ |
|
169 cp -p ${GCCSHAREDIR}/gcc-${GCC_FULL_VERSION}/python/libstdcxx/v6/printers.py \ |
|
170 ${GCCUSRSHAREDIR}/python/libstdcxx/v6/printers.py |
|
171 |
|
172 cd ${GDBSHAREDIR}/auto-load/usr/lib/ |
|
173 ${PYTHON} -m compileall . |
|
174 |
|
175 cd ${GCCUSRSHAREDIR}/python/libstdcxx/ |
|
176 ${PYTHON} -m compileall . |
|
177 |
|
178 cd ${GCCUSRSHAREDIR}/python/libstdcxx/v6/ |
|
179 ${PYTHON} -m compileall . |
|
180 |
|
181 echo "... Done." |
|
182 echo"" |
|
183 exit 0 |
|