1 |
solar 09/02/26 23:19:51 |
2 |
|
3 |
Added: Makefile cross-emerge cross-fix-root |
4 |
cross-pkg-config emerge-wrapper |
5 |
Log: |
6 |
- initial import into cvs. git what? git lost. |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 crossdev-wrappers/Makefile |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/Makefile?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/Makefile?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: Makefile |
15 |
=================================================================== |
16 |
# Copyright 2008-2009 Gentoo Foundation |
17 |
# Distributed under the terms of the GNU General Public License v2 |
18 |
# $Header: /var/cvsroot/gentoo-projects/crossdev-wrappers/Makefile,v 1.1 2009/02/26 23:19:51 solar Exp $ |
19 |
|
20 |
# -solar |
21 |
|
22 |
DESTDIR ?= / |
23 |
PREFIX ?= /usr/local |
24 |
|
25 |
PORTDIR ?= $(shell portageq envvar PORTDIR) |
26 |
FNAMES = cross-emerge cross-fix-root cross-pkg-config emerge-wrapper |
27 |
SITE = $(PREFIX)/share/crossdev/include/site |
28 |
TOPDIR= |
29 |
|
30 |
all: |
31 |
@: |
32 |
|
33 |
install: |
34 |
mkdir -p $(DESTDIR)/$(PREFIX)/bin/ $(DESTDIR)/$(SITE) |
35 |
cp $(FNAMES) $(DESTDIR)/$(PREFIX)/bin/ |
36 |
cp -a etc $(DESTDIR)/$(PREFIX)/share/crossdev/ |
37 |
cp -a site $(DESTDIR)/$(PREFIX)/share/crossdev/include/ |
38 |
sed -i -e s@__PREFIX__@$(PREFIX)@g $(DESTDIR)/$(PREFIX)/bin/emerge-wrapper |
39 |
sed -i -e s@__TOPDIR__@$(SITE)@g $(DESTDIR)/$(SITE)/config.site |
40 |
mv $(DESTDIR)/$(SITE)/config.site $(DESTDIR)/$(PREFIX)/share/ |
41 |
( cd $(DESTDIR)/$(PREFIX)/share/crossdev/etc && ln -sf $(PORTDIR)/profiles/embedded make.profile ) |
42 |
|
43 |
uninstall: |
44 |
@for x in $(FNAMES) ; do rm -f $(DESTDIR)/$(PREFIX)/bin/$$x ; done |
45 |
|
46 |
dist: |
47 |
cd ../ ; tar jcvf crossdev-wrappers-`date -u +%Y%m%d`.tar.bz2 crossdev-wrappers |
48 |
|
49 |
|
50 |
|
51 |
1.1 crossdev-wrappers/cross-emerge |
52 |
|
53 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-emerge?rev=1.1&view=markup |
54 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-emerge?rev=1.1&content-type=text/plain |
55 |
|
56 |
Index: cross-emerge |
57 |
=================================================================== |
58 |
#!/bin/bash |
59 |
# Copyright 2008-2009 Gentoo Foundation |
60 |
# Distributed under the terms of the GNU General Public License v2 |
61 |
# $Header: /var/cvsroot/gentoo-projects/crossdev-wrappers/cross-emerge,v 1.1 2009/02/26 23:19:51 solar Exp $ |
62 |
|
63 |
# -solar |
64 |
|
65 |
[[ $CHOST == "" ]] && { echo "CHOST is not set" ; exit 1 ; } |
66 |
|
67 |
export CBUILD=$(portageq envvar CBUILD) |
68 |
export SYSROOT="/usr/${CHOST}" |
69 |
export PORTAGE_CONFIGROOT="/usr/${CHOST}" |
70 |
|
71 |
FAKEROOT= |
72 |
if [[ $(id -u) != 0 ]]; then |
73 |
[[ $(type -p fakeroot) != "" ]] && FAKEROOT=fakeroot |
74 |
fi |
75 |
|
76 |
${FAKEROOT} emerge -q "$@" |
77 |
|
78 |
|
79 |
|
80 |
1.1 crossdev-wrappers/cross-fix-root |
81 |
|
82 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-fix-root?rev=1.1&view=markup |
83 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-fix-root?rev=1.1&content-type=text/plain |
84 |
|
85 |
Index: cross-fix-root |
86 |
=================================================================== |
87 |
#!/bin/bash |
88 |
# Copyright 2008-2009 Gentoo Foundation |
89 |
# Distributed under the terms of the GNU General Public License v2 |
90 |
# $Header: /var/cvsroot/gentoo-projects/crossdev-wrappers/cross-fix-root,v 1.1 2009/02/26 23:19:51 solar Exp $ |
91 |
|
92 |
# - solar |
93 |
|
94 |
CROSS_ROOT="" |
95 |
[[ $1 != "" ]] && [ -e /usr/$1 ] && CROSS_ROOT="/usr/$1" |
96 |
[[ -e ${CROSS_ROOT} ]] || exit 0 |
97 |
|
98 |
function strip_path() { |
99 |
echo $1 | grep -Eo "[^\/]+$" |
100 |
} |
101 |
|
102 |
function re_safe() { |
103 |
echo $1 | gawk '{ gsub("/","\\/"); print }' |
104 |
} |
105 |
|
106 |
fix_la_files() { |
107 |
count=0 |
108 |
for LA in $(find $CROSS_ROOT/usr/lib/ -iname *.la); do |
109 |
[ -e $LA ] || continue |
110 |
count=$(($count+1)) |
111 |
sed -i -e "s;libdir='/usr/lib';libdir='$CROSS_ROOT/usr/lib';" \ |
112 |
-e s@" /usr/lib"@" ${CROSS_ROOT}/usr/lib"@g $LA |
113 |
[[ $? != 0 ]] && printf "FAIL $LA or $CROSS_ROOT FAILED sucka\n" |
114 |
done |
115 |
return $count |
116 |
} |
117 |
|
118 |
fix_pc_files() { |
119 |
count=0 |
120 |
for PC in $CROSS_ROOT/usr/lib/pkgconfig/*.pc; do |
121 |
[ -e $PC ] || continue |
122 |
sed -i -e "s/^prefix\\=\\/usr$/prefix\=$(re_safe "$CROSS_ROOT")\\/usr/" $PC |
123 |
count=$(($count+1)) |
124 |
[[ $? != 0 ]] && printf "Fixing $PC for $CROSS_ROOT FAILED sucka\n" |
125 |
done |
126 |
return $count |
127 |
} |
128 |
|
129 |
fix_la_files ${CROSS_ROOT} |
130 |
la_count=$? |
131 |
fix_pc_files ${CROSS_ROOT} |
132 |
pc_count=$? |
133 |
: |
134 |
( . /sbin/functions.sh ; einfo "Scanned/Fixed $pc_count "'*'".pc and $la_count "'*'".la files" ) |
135 |
|
136 |
|
137 |
|
138 |
1.1 crossdev-wrappers/cross-pkg-config |
139 |
|
140 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-pkg-config?rev=1.1&view=markup |
141 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/cross-pkg-config?rev=1.1&content-type=text/plain |
142 |
|
143 |
Index: cross-pkg-config |
144 |
=================================================================== |
145 |
#!/bin/sh |
146 |
# Copyright 2008 Gentoo Foundation |
147 |
# Distributed under the terms of the GNU General Public License v2 |
148 |
# $Header: /var/cvsroot/gentoo-projects/crossdev-wrappers/cross-pkg-config,v 1.1 2009/02/26 23:19:51 solar Exp $ |
149 |
|
150 |
# -solar |
151 |
# Also uses vapier's code from uclinux-dist |
152 |
|
153 |
if [[ "x$ROOT" == "x" ]]; then |
154 |
exit 1 |
155 |
fi |
156 |
|
157 |
# Helper functions. So very helpful. |
158 |
# |
159 |
msg_to_stderr() { echo "cross-pkg-config: $*" 1>&2 ; } |
160 |
warn() { msg_to_stderr "warning: $*" ; } |
161 |
error() { |
162 |
msg_to_stderr "error: $*" |
163 |
exit 1 |
164 |
} |
165 |
|
166 |
|
167 |
SYSROOT="$ROOT" |
168 |
export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig" |
169 |
unset PKG_CONFIG_PATH PKG_CONFIG_ALLOW_SYSTEM_CFLAGS PKG_CONFIG_ALLOW_SYSTEM_LIBS |
170 |
#export PKG_CONFIG_DEBUG_SPEW="yes" #enable for debug |
171 |
|
172 |
# |
173 |
# Sanity check the output to catch common errors that do not |
174 |
# cause failures until much later on. |
175 |
# |
176 |
output=$(pkg-config "$@") |
177 |
ret=$? |
178 |
case " ${output} " in |
179 |
*" -L/usr/lib "*|*" -L/usr/local/lib "*|\ |
180 |
*" -L /usr/lib "*|*" -L /usr/local/lib "*|\ |
181 |
*" -L/usr/lib64 "*|*" -L/usr/local/lib64 "*|\ |
182 |
*" -L /usr/lib64 "*|*" -L /usr/local/lib64 "*) |
183 |
warn "### falling down so here is a dump state ######" |
184 |
pkg-config --debug "$@" 1>&2 |
185 |
warn "### end of dump ###############################" |
186 |
error "host -L paths detected: ${output}" |
187 |
;; |
188 |
*" -I/usr/include"*|*" -I/usr/local/include"*) |
189 |
warn "### falling down so here is a dump state ######" |
190 |
pkg-config --debug "$@" 1>&2 |
191 |
warn "### end of dump ###############################" |
192 |
error "host -I paths detected: ${output}" |
193 |
;; |
194 |
esac |
195 |
[ -n "${output}" ] && echo "${output}" |
196 |
exit ${ret} |
197 |
|
198 |
|
199 |
|
200 |
1.1 crossdev-wrappers/emerge-wrapper |
201 |
|
202 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/emerge-wrapper?rev=1.1&view=markup |
203 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/crossdev-wrappers/emerge-wrapper?rev=1.1&content-type=text/plain |
204 |
|
205 |
Index: emerge-wrapper |
206 |
=================================================================== |
207 |
#!/bin/bash |
208 |
# Copyright 2008-2009 Gentoo Foundation |
209 |
# Distributed under the terms of the GNU General Public License v2 |
210 |
# $Header: /var/cvsroot/gentoo-projects/crossdev-wrappers/emerge-wrapper,v 1.1 2009/02/26 23:19:51 solar Exp $ |
211 |
|
212 |
# - solar |
213 |
|
214 |
cross_wrap_etc() { |
215 |
local chost=$1 |
216 |
cp -a __PREFIX__/share/crossdev/etc /usr/$chost/ |
217 |
|
218 |
conf=/usr/$chost/etc/make.conf |
219 |
|
220 |
if [[ ${chost:0:1} == "i" ]] && [[ ${chost:3:4} == "86" ]]; then |
221 |
ARCH=x86 |
222 |
fi |
223 |
|
224 |
if [[ ${chost:0:3} == "arm" ]]; then |
225 |
E_MACHINE=EM_ARM |
226 |
ARCH=arm |
227 |
echo 'UCLIBC_CPU_DEFAULT="GENERIC_ARM"' >> ${conf} |
228 |
fi |
229 |
|
230 |
[[ $E_MACHINE != "" ]] && sed -i -e s/'#E_MACHINE=__E_MACHINE__'/E_MACHINE=${E_MACHINE}/g ${conf} |
231 |
[[ $ARCH != "" ]] && sed -i -e s/__ARCH__/${ARCH}/g ${conf} |
232 |
sed -i -e s/__CHOST__/${chost}/g -e s/__CBUILD__/${CBUILD}/g ${conf} |
233 |
echo MAKEOPTS=-j$(cat /proc/cpuinfo | grep processor| wc -l) >> ${conf} |
234 |
[[ ${overlay} != "" ]] && echo PORTDIR_OVERLAY=\"${overlay}\" >> ${conf} |
235 |
} |
236 |
|
237 |
cross_init() { |
238 |
bn=$(basename $0) |
239 |
[[ $bn != emerge-wrapper ]] && { echo "I wont understand things" ; exit 1; } |
240 |
dn=$(dirname $(readlink -f $0)) |
241 |
chosts=$(gcc-config -l | awk '{print $2}'| grep -- -| cut -d '-' -f 1-4| sort -u) |
242 |
cd $dn || { echo "Failed to cd to $dn" ; exit 1; } |
243 |
export overlay=$(portageq envvar PORTDIR_OVERLAY) |
244 |
|
245 |
for chost in $chosts; do |
246 |
[[ $chost == $CBUILD ]] && continue |
247 |
[[ $(type -p ${chost}-gcc) == "" ]] && continue |
248 |
echo " * Setting up symlinks for $chost" |
249 |
ln -sf emerge-wrapper emerge-${chost} |
250 |
ln -sf emerge-wrapper ${chost}-emerge |
251 |
ln -sf cross-pkg-config ${chost}-pkg-config |
252 |
if [ -d /usr/${chost} ] ; then |
253 |
if [[ ! -d /usr/${chost}/etc/ ]]; then |
254 |
echo " * Setting up cross basics in /usr/${chost}/etc" |
255 |
cross_wrap_etc $chost |
256 |
fi |
257 |
fi |
258 |
done |
259 |
} |
260 |
|
261 |
# CBUILD must be the first thing we export |
262 |
export CBUILD=$(portageq envvar CBUILD) |
263 |
|
264 |
if [[ $1 == "--init" ]]; then |
265 |
cross_init |
266 |
exit 0 |
267 |
fi |
268 |
|
269 |
CHOST=$(basename $0) |
270 |
CHOST=${CHOST/-emerge} |
271 |
CHOST=${CHOST/emerge-} |
272 |
export CHOST |
273 |
|
274 |
if [[ $CHOST == wrapper ]]; then |
275 |
if [[ $1 == "--target" ]]; then |
276 |
export CHOST=$2 |
277 |
shift 2 |
278 |
else |
279 |
echo "After running this program with the --init option as root" |
280 |
echo "you can call it directly like emerge-wrapper --target CHOST <emerge options>" |
281 |
echo "or using the emerge-CHOST wrappers" |
282 |
exit 1 |
283 |
fi |
284 |
fi |
285 |
|
286 |
[[ $(type -p ${CHOST}-gcc) == "" ]] && { echo "You need to 'crossdev $CHOST' first" ; exit 1; } |
287 |
|
288 |
cross-emerge "$@" |