[r142]: do-libc.sh Maximize Restore History

Download this file

do-libc.sh    110 lines (87 with data), 2.8 kB

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
# This work is partially financed by the European Commission under the
# Framework 6 Information Society Technologies Project
# "Wirelessly Accessible Sensor Populations (WASP)".
set -eu
. ./buildgcc.subr
INITIAL_DIR="$(pwd)"
BUILD_DIR=build
FETCH_ONLY=0
if [ $# -lt 1 ]; then
echo "Usage: do-libc.sh <toolchain target dir> [<build dir>] [--fetch-only] [URL]"
echo "Example: do-libc.sh /opt/msp430-gcc-latest"
exit 1
fi
TARGET_LOCATION="$1"
shift
if [ $# -ge 1 ] ; then
BUILD_DIR="$1"
shift
fi
if [ $# -ge 1 ] && [ "_$1" = "_--fetch-only" ]; then
FETCH_ONLY=1
shift
fi
OVERRIDE_URL=
if [ $# -ge 1 ] ; then
OVERRIDE_URL="$1"
shift
fi
INSTALL_LAUNCHER="$(sh do-detect-sudo.sh "$TARGET_LOCATION")"
GNUMAKE=$(find_gnumake)
if [ -z "$GNUMAKE" ] ; then
echo >&2 "GNU make not found, aborting!"
exit 1
fi
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
export PATH="$TARGET_LOCATION/bin:$PATH"
TARGET_LOCATION_SED="$(echo "$TARGET_LOCATION" | sed -e "s,/,\\\\/,g")"
mkdir -p mspgcc
cd mspgcc
if [ "$OVERRIDE_URL" = "" ] ; then
cvs -z3 -d:pserver:anonymous@mspgcc.cvs.sourceforge.net:/cvsroot/mspgcc co -n -A -P -d msp430-libc.pristine msp430-libc
rm -rf msp430-libc
mkdir msp430-libc
cd msp430-libc
( cd ../msp430-libc.pristine && tar cf - .) | ( tar xpf - )
if [ -e "$INITIAL_DIR/msp430-libc.patch" ] ; then
patch -p1 -N -i "$INITIAL_DIR/msp430-libc.patch"
fi
mkdir -p src/msp1 src/msp2
cd ../../mspgcc
cd msp430-libc/src
sed -e "s/\/usr\/local\/msp430/$TARGET_LOCATION_SED/" Makefile > Makefile.new
mv Makefile.new Makefile
else
ARCHIVE_NAME=$(echo $OVERRIDE_URL | sed s/^.*\\\/\\\([^\\\/]*\\\)\$/\\\1/;)
ARCHIVE_BASE=$(echo $OVERRIDE_URL | sed s/^.*\\\/\\\([^\\\/.]*\\\)\\..*\$/\\\1/;)
wget -c "$OVERRIDE_URL"
test -e $ARCHIVE_BASE && rm -rf $ARCHIVE_BASE
tar xjf $ARCHIVE_NAME
cd $ARCHIVE_BASE/src
fi
if [ "_$FETCH_ONLY" = _1 ]; then
echo "msp430 libc downloaded successfully"
exit 0
fi
# some versions of libc fail the parallel build; so retry
# a serial build if the parallel build fails.
$GNUMAKE -j$(num_cpus) PREFIX=$TARGET_LOCATION || \
$GNUMAKE PREFIX=$TARGET_LOCATION
# Ensure updated path is provided to sudo
if [ -n "${INSTALL_LAUNCHER}" ] ; then
$INSTALL_LAUNCHER PATH="$PATH" $GNUMAKE install PREFIX=$TARGET_LOCATION
else
$GNUMAKE install PREFIX=$TARGET_LOCATION
fi
echo '!<arch>' > 0lib.tmp
$INSTALL_LAUNCHER cp 0lib.tmp "$TARGET_LOCATION/lib/libstdc++.a"
rm 0lib.tmp
$INSTALL_LAUNCHER cp "$TARGET_LOCATION/msp430/include/sys/inttypes.h" "$TARGET_LOCATION/msp430/include/inttypes.h"
#cd "$TARGET_LOCATION/msp430/lib/ldscripts"
#$INSTALL_LAUNCHER tar xjf "$INITIAL_DIR/ports/ldscripts-new.tar.bz2"
cd "$INITIAL_DIR"
if [ -z "${SUPPRESS_CLEAN+""}" ] ; then
rm -rf "$BUILD_DIR/mspgcc"
fi