forked from tmm1/matzruby
-
Notifications
You must be signed in to change notification settings - Fork 4
/
arminstall
executable file
·92 lines (81 loc) · 2.59 KB
/
arminstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# install ruby 1.8.7p352 build for arm-linux -- 9/1/15 brent@mbari.org
# also install modules needed for ESP unless
# coreOnly environment variable is set
#
# remove all fields $1 from list delminited by $2 starting with $3
# send the filtered version of $2 to stdout
remove ()
{
toDelete=$1
IFS=$2
shift 2
[ "$@" ] && {
set $@
unset separator
for field; do
if [ "$field" != "$toDelete" ]; then
echo -n "$separator$field"
separator=$IFS
fi
done
}
}
startDir=$PWD
: ${HOSTTOP:=$HOME/armHost}
: ${ARMGCC:=/arm}
: ${ARMPREFIX:=$ARMGCC/usr}
: ${ARMSTRIP:=$ARMGCC/bin/strip}
: ${TARGETTOP:=/opt/mbari}
: ${TOP:=$HOSTTOP$TARGETTOP}
export DESTDIR=$HOSTTOP
echo "Installing in $HOSTTOP"
echo " for execution at $TARGETTOP on the ARM target"
PATH=`remove . : $PATH` #remove current directory from PATH
srctop=$PWD
echo Building ruby for $ARMHOST target
rbcfg=rbconfig.rb
make RUBYLIB=$srctop/lib -o miniruby fake.rb ./.rbconfig.time
#This is required so that ruby's extmk.rb script will look in the target
#libs when checking dependencies.
export prefix=$ARMPREFIX
rm -rf $TOP/bin/ruby $TOP/lib/ruby &&
mkdir -p $TOP &&
make RUBYLIB=$srctop/lib EXTLDFLAGS="$EXTLDFLAGS" -o miniruby -j4 prefix=$prefix all &&
make RUBYLIB=$srctop/lib EXTLDFLAGS="$EXTLDFLAGS" -o miniruby install || exit 1
[ -n "$coreOnly" ] || {
echo " Installing extensions required by MBARI ESP:"
cd $startDir
PATH=.:$PATH
buildUtils clean install || exit 9
}
echo "Changing prefix from $ARMGCC to $TARGETTOP in $rbcfg"
cd $srctop &&
sed -e "s:+ \"$prefix\":+ \"$TARGETTOP\":" $rbcfg >$rbcfg.patched &&
mv -f $rbcfg.patched $rbcfg || {
echo "Failed to patch $rbcfg"
exit 2
}
cd $TOP || exit 2
echo "Stripping, Deleting docs, intermediate files and empty directories"
rm -rf share lib/ruby/1.8/rdoc lib/ruby/1.8/test/unit/ui
rm -f lib/libruby*.a
rm -f `find lib/ruby -name "*.[aoh]"` #remove all development intermediate files
find lib/ruby/1.8 -depth -type d \
-exec rmdir {} --ignore-fail-on-non-empty \;
objs="bin/ruby `find lib/ruby -name "*.so*"`"
chmod +w $objs &&
$ARMSTRIP $objs &&
chmod -w $objs || exit 8
librt=`echo $ARMGCC/lib/librt-*.so`
[ -r $librt ] && {
echo "Copying and stripping librt and libpthread from $ARMGCC/lib"
$ARMSTRIP $librt -o $DESTDIR/lib/`basename $librt` &&
cp -a $ARMGCC/lib/librt.so* $DESTDIR/lib || exit 7
}
libpthread=`echo $ARMGCC/lib/libpthread-*.so`
[ -r $libpthread ] && {
$ARMSTRIP $libpthread -o $DESTDIR/lib/`basename $libpthread` &&
cp -a $ARMGCC/lib/libpthread.so* $DESTDIR/lib || exit 8
}
echo "Successfully Installed Ruby environment at $TOP"