Gentoo Archives: gentoo-commits

From: "Friedrich Oslage (bluebird)" <bluebird@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-devel/icecream/files: icecream-create-env 0.9.0-dont-create-symlinks.patch 0.9.0-create-env-multilib.patch 0.9.0-conf.d-verbosity.patch 0.9.0-run-march-native-locally.patch
Date: Sat, 02 Aug 2008 15:12:16
Message-Id: E1KPImD-00014x-Vp@stork.gentoo.org
1 bluebird 08/08/02 15:12:13
2
3 Added: icecream-create-env
4 Removed: 0.9.0-dont-create-symlinks.patch
5 0.9.0-create-env-multilib.patch
6 0.9.0-conf.d-verbosity.patch
7 0.9.0-run-march-native-locally.patch
8 Log:
9 Add helper script to make cross-compiling easier, remove old.
10 (Portage version: 2.1.4.4)
11
12 Revision Changes Path
13 1.1 sys-devel/icecream/files/icecream-create-env
14
15 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-devel/icecream/files/icecream-create-env?rev=1.1&view=markup
16 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-devel/icecream/files/icecream-create-env?rev=1.1&content-type=text/plain
17
18 Index: icecream-create-env
19 ===================================================================
20 #!/bin/bash
21 #
22 # icecream-create-env - helper script to create icecc environments(mostly for cross-compiling)
23 #
24 # Copyright 1999-2008 Gentoo Foundation
25 # Distributed under the terms of the GNU General Public License v2
26 #
27 # Please note, this script has been designed to work with Gentoo's crossdev, it may or may
28 # not work with cross-toolchains that were build differently.
29 #
30 #
31 # Usage: "./icecream-create-env" creates a native environment(similar to icecc --build-native)
32 # "./icecream-create-env CHOST" creates a cross-compile environment using the cross-toolchain created by crossdev
33 # Example:
34 # "emerge crossdev && crossdev -t sparc-unknown-linux-gnu && icecream-create-env sparc-unknown-linux"
35
36 if [ `id -u` -ne 0 ]
37 then
38 echo "Only the superuser can execute this script."
39 exit 1
40 fi
41
42 # param 1 = CHOST
43 prefix="${1}"
44
45 if [ -z "${prefix}" ]
46 then
47 prefix="`gcc -dumpmachine`"
48 fi
49
50 gccbin=`which ${prefix}-gcc 2>/dev/null`
51 if [ ! -e "${gccbin}" ]
52 then
53 echo "Can't find ${prefix}-gcc!"
54 exit 1
55 fi
56
57 version="`${prefix}-gcc -dumpversion`"
58
59 tmpdir=`mktemp -d`
60 tmpfile=`mktemp`
61
62 echo "Creating icecc environment for ${prefix}..."
63
64 mkdir -p ${tmpdir}/usr/bin
65
66 echo "Adding `which ${prefix}-as`... as /usr/bin/as"
67 cp -p `which ${prefix}-as` ${tmpdir}/usr/bin/as
68
69 if [ "`gcc -dumpmachine`" = "${prefix}" ]
70 then
71 echo "Adding /usr/${prefix}/gcc-bin/${version}/g++ as /usr/bin/g++..."
72 cp -p /usr/${prefix}/gcc-bin/${version}/g++ ${tmpdir}/usr/bin
73 echo "Adding /usr/${prefix}/gcc-bin/${version}/gcc as /usr/bin/gcc..."
74 cp -p /usr/${prefix}/gcc-bin/${version}/gcc ${tmpdir}/usr/bin
75 else
76 echo "Adding /usr/${CHOST}/${prefix}/gcc-bin/${version}/${prefix}-g++ as /usr/bin/g++..."
77 cp -p /usr/${CHOST}/${prefix}/gcc-bin/${version}/${prefix}-g++ ${tmpdir}/usr/bin/g++
78 echo "Adding /usr/${CHOST}/${prefix}/gcc-bin/${version}/${prefix}-gcc as /usr/bin/gcc..."
79 cp -p /usr/${CHOST}/${prefix}/gcc-bin/${version}/${prefix}-gcc ${tempdir}/usr/bin/gcc
80 fi
81
82 echo "Adding /usr/libexec/gcc/${prefix}/${version}/cc1 as /usr/bin/cc1..."
83 cp -p /usr/libexec/gcc/${prefix}/${version}/cc1 ${tmpdir}/usr/bin/
84
85 echo "Adding /usr/libexec/gcc/${prefix}/${version}/cc1plus as /usr/bin/cc1plus.."
86 cp -p /usr/libexec/gcc/${prefix}/${version}/cc1plus ${tmpdir}/usr/bin/
87
88 # binaries are there, now copy libs
89 for binary in `ls ${tmpdir}/usr/bin/`
90 do
91 for library in `ldd ${tmpdir}/usr/bin/${binary} | tr '=>' ' ' | awk '{print $1" "$2}'`
92 do
93 if [ ! -e "${tmpdir}/${library}" ] && [ -e "${library}" ]
94 then
95 echo "Adding ${library}..."
96 cp --parents "${library}" ${tmpdir}/
97 fi
98 done
99 done
100
101 # rebuild ld.so.cache
102 echo "Creating /etc/ld.so.cache..."
103 cp --parents /etc/ld.so.conf ${tmpdir}/
104 ldconfig -r ${tmpdir}
105 rm ${tmpdir}/etc/ld.so.conf
106
107 echo "Testing icecc environment..."
108 touch ${tmpdir}/empty.c
109 chroot ${tmpdir}/ /usr/bin/gcc -c /empty.c
110 tested=${?}
111 rm ${tmpdir}/empty.c
112
113 if [ "${tested}" -ne 0 ]
114 then
115 echo ""
116 echo "Creating icecc environment failed. Please see error message(s) above! The temporary directory is: ${tmpdir}/"
117 else
118 # pack
119 echo "Compressing files..."
120 tar -c -z -C ${tmpdir} -f ${tmpfile} `ls ${tmpdir}/`
121
122 newname="`md5sum ${tmpfile} | awk '{print $1}'`.tar.gz"
123 mv ${tmpfile} ${newname}
124
125 # cleanup
126 rm -rf ${tmpdir}
127
128 echo ""
129 echo "Icecc environment has been created. It has been saved as ${newname}!"
130 fi