123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #!/bin/bash
- SCRIPTDIR=$( cd $(dirname $0) ; pwd -L )
- usage()
- {
- cat << EOF
- usage: $0 [OPTIONS]
- Create Tizen development tools for certain Tizen profile (gbs sysroot)
- OPTIONS:
- -h Show this message
- -p toolchain installation prefix (binutils will be installed there)
- -s gbs sysroot PATH
- -r source rpm repository url
- -i do not clean temporary build directories and try to start from last error
- examples:
- $0 -p ~/toolchains \
- -s ~/GBS_ROOT/local/BUILD-ROOTS/scratch.armv7l.0 \
- -r http://download.tizen.org/snapshots/tizen/common/latest/repos/x86_64-wayland/source
- EOF
- exit
- }
- insufficientDependencies() {
- echo "Missing $1"
- echo Insufficient dependecies: you need to install:
- echo sudo apt-get install flex bison rpm2cpio cpio texinfo libncurses5-dev
- exit 1
- }
- checkExecutableIfExists() {
- if ! type $1 &> /dev/null; then
- insufficientDependencies $1
- fi
- }
- checkHeaderIfExists() {
- __HEADER=$(find /usr/include/ /usr/local/include/ -name $1)
- if [ "$__HEADER" == "" ]; then
- insufficientDependencies "$1 in /usr/include/ or /usr/local/include/"
- fi
- }
- checkExecutableIfExists rpm2cpio
- checkExecutableIfExists cpio
- checkHeaderIfExists termcap.h
- set -e
- SYSROOT=""
- TOOLCHAIN_PREFIX=""
- SOURCE_RPM_REPOSITORY_URL=""
- INCREMENTAL="0"
- while getopts ":hip:r:s:" opt; do
- case $opt in
- h)
- usage
- ;;
- i)
- INCREMENTAL="1"
- ;;
- p)
- TOOLCHAIN_PREFIX=$(mkdir -p $OPTARG; cd $OPTARG; pwd -L)
- ;;
- s)
- SYSROOT=$(cd $OPTARG; pwd -L)
- ;;
- r)
- SOURCE_RPM_REPOSITORY_URL=${OPTARG}
- ;;
- ?)
- echo "Invalid option: -$OPTARG"
- usage
- ;;
- esac
- done
- if [ "$TOOLCHAIN_PREFIX" == "" ]; then
- echo "Set toolchain prefix with -p option. Cross compiler will be installed there"
- exit 1
- fi
- if [ "$SYSROOT" == "" ]; then
- echo "Set gbs sysroot path with -s option"
- exit 1
- fi
- if [ "$SOURCE_RPM_REPOSITORY_URL" == "" ]; then
- echo "Set source rpm repository url with -r option"
- exit 1
- fi
- BUILD_DIR=/tmp/crosscompilerbuild/gdb
- TARGET=$(echo "/usr/bin/gcc -dumpmachine" | gbs chroot $SYSROOT | grep -v "info: chroot" )
- GDB_SRCRPM=$(echo "rpm -qif \$(readlink -f /usr/bin/gdb) | grep 'Source RPM' | sed 's/.*Source\s*RPM\s*:\s*//g'" | gbs chroot $SYSROOT| grep -v "info: chroot")
- if [ "$INCREMENTAL" == "0" ]; then
- rm -rf $BUILD_DIR
- fi
- mkdir -p $BUILD_DIR
- cd $BUILD_DIR
- if ! [ -e $GDB_SRCRPM -a "$INCREMENTAL" == "1" ]; then
- echo "Downloading gdb source rpm: $GDB_SRCRPM"
- wget ${SOURCE_RPM_REPOSITORY_URL}/$GDB_SRCRPM
- fi
- GDB_SOURCE_ARCHIVE=$(ls | grep *.tar.* || :)
- if ! [ "$GDB_SOURCE_ARCHIVE" != "" -a "$INCREMENTAL" == "1" ]; then
- rpm2cpio $GDB_SRCRPM 2>&1 | cpio -imdv 2>&1
- GDB_SOURCE_ARCHIVE=$(ls | grep *.tar.*)
- fi
- GDB_NAME=$(echo $GDB_SOURCE_ARCHIVE | sed "s/\.tar\..*//gi")
- echo extracting $GDB_SOURCE_ARCHIVE ...
- tar -xf $GDB_SOURCE_ARCHIVE
- cd $GDB_NAME
- for tupple in $(cat ../*.spec| grep -Pi "^patch" | sed "s/^patch//gi" | sed "s/\s*\:\s*/|/gi" | sort); do\
- tupple=(${tupple/|/ })
- echo applying patch number ${tupple[0]} ${tupple[1]}
- PATCH_PARAMS=$(grep -P "^\s*%patch${tupple[0]}" ../*.spec | sed "s/%patch[0-9]\+\s*//gi" | sed "s/-b\s\+\S\+/ /g")
- if [ "$PATCH_PARAMS" == "" ]; then
- continue
- fi
- patch $PATCH_PARAMS < ../${tupple[1]}
- done
- cd ..
- GDB_BUILD_DIR=${GDB_NAME}-build
- mkdir -p $GDB_BUILD_DIR
- cd $GDB_BUILD_DIR
- ../$GDB_NAME/configure \
- --with-sysroot=$SYSROOT \
- --prefix=$TOOLCHAIN_PREFIX \
- --target=$TARGET \
- --with-expat \
- --without-lzma \
- --without-guile \
- --without-zlib \
- --without-babeltrace
- make -j$(cat /proc/cpuinfo | grep -c "^proc") all
- make install
- if [ "$INCREMENTAL" == "0" ]; then
- rm -rf $BUILD_DIR
- fi
|