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

Download this file

do-gdb.sh    124 lines (97 with data), 3.1 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
# This work is partially financed by the European Commission under the
# Framework 6 Information Society Technologies Project
# "Wirelessly Accessible Sensor Populations (WASP)".
#The following versions of BINUTILS have been tested:
# 6.8
# 7.0
# insight 6.8-1
# Note that insight 6.8-1 doesn't compile on Cygwin 1.7.1.
# Workaround that let us proceed a bit:
# make CC="gcc -D__USE_W32_SOCKETS" -C tcl/win
# make CC="gcc -include winsock2.h" -C tk/win # this is insufficient.
# HELP SOLICITED!
set -eu
# source utilities
. ./buildgcc.subr
PKG_VERSION=7.0
PKG_NAME=gdb #can also be insight
GNU_MIRROR=http://ftp.uni-kl.de
INSIGHT_MIRROR=http://gd.tuwien.ac.at/gnu/sourceware/insight/releases/
BUILD_DIR=build
INITIAL_DIR="$(pwd)"
FETCH_ONLY=0
if [ $# -lt 1 ]; then
echo "Usage: do-gdb.sh <toolchain target dir> [<gdb_version>] [<GNU mirror site>] [<build dir>] [gdb/insight] [--fetch-only]"
echo "Example: do-gdb.sh /opt/msp430-gcc-latest $PKG_VERSION $GNU_MIRROR build"
exit 1
fi
TARGET_LOCATION="$1"
shift
if [ $# -ge 1 ] && [ -n "$1" ]; then PKG_VERSION="$1" ; shift ; fi
if [ $# -ge 1 ] && [ -n "$1" ]; then GNU_MIRROR="$1" ; shift ; fi
if [ $# -ge 1 ] && [ -n "$1" ]; then BUILD_DIR="$1" ; shift ; fi
if [ $# -ge 1 ] && [ -n "$1" ]; then PKG_NAME="$1" ; shift ; fi
while [ $# -ge 1 ] ; do
case "$1" in
--fetch-only) FETCH_ONLY=1 ;;
*) echo >&2 "Ambiguous options $@." ; exit 1 ;;
esac
shift
done
case "$PKG_NAME" in
gdb)
PKG_SRC_URL="$GNU_MIRROR/pub/gnu/gdb/gdb-$PKG_VERSION.tar.bz2"
GDB_CFG_EXTRA_FLAGS=
;;
insight)
PKG_SRC_URL="$INSIGHT_MIRROR/insight-$PKG_VERSION.tar.bz2"
GDB_CFG_EXTRA_FLAGS="--enable-gdbtk"
;;
*)
echo "Package name must be either gdb or insight."
exit 1
;;
esac
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
cat >&2 <<_EOF
==============================================================
Note that you must have libcurses developer headers installed.
If missing, building GDBTUI will be skipped later on.
==============================================================
_EOF
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
export PATH="$PATH:$TARGET_LOCATION/bin"
wget -c "$PKG_SRC_URL" -O "$PKG_NAME-$PKG_VERSION.tar.bz2"
echo "Unpacking $PKG_NAME..."
tar xjf "$PKG_NAME-$PKG_VERSION.tar.bz2"
cd "$PKG_NAME-$PKG_VERSION"
cp -rf "$INITIAL_DIR"/ports/gdb-6-and-7/* .
if [ $FETCH_ONLY = 1 ]; then
echo "$PKG_NAME $PKG_VERSION downloaded successfully"
exit 0
fi
if test -e "$INITIAL_DIR/$PKG_NAME-$PKG_VERSION.patch" ; then
patch -p1 < "$INITIAL_DIR/$PKG_NAME-$PKG_VERSION.patch"
fi
cd ..
mkdir -p "$PKG_NAME-$PKG_VERSION-build"
cd "$PKG_NAME-$PKG_VERSION-build"
"$(pwd)/../$PKG_NAME-$PKG_VERSION/configure" \
"--prefix=$TARGET_LOCATION" \
--target=msp430 \
--disable-werror $GDB_CFG_EXTRA_FLAGS
$GNUMAKE -j$(num_cpus) MAKE=$GNUMAKE -e
$INSTALL_LAUNCHER $GNUMAKE install MAKE=$GNUMAKE -e
if [ -z "${SUPPRESS_CLEAN+""}" ] ; then
cd ..
rm -rf "$PKG_NAME-$PKG_VERSION-build"
rm -rf "$PKG_NAME-$PKG_VERSION"
fi
cd "$INITIAL_DIR"