summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2013-11-13 19:47:55 (GMT)
committer Jaromil <jaromil@dyne.org>2013-11-13 19:54:53 (GMT)
commit2bcefdb2a1633b5de63722cd6574285174a05020 (patch)
tree0600fc902f528c4c8e6decafe2bbd6cf56ef685a
parent03f04149af7ceecfa9be47dcf360990ad7f10f9b (diff)
new build system supporting multiple toolchains: android-ndk added
-rw-r--r--build/conf.zsh442
-rw-r--r--build/system/Sources7
-rw-r--r--build/system/Toolchain1
-rw-r--r--build/system/conf.zsh40
-rwxr-xr-xwrap/static-cc2
-rwxr-xr-xzmake292
6 files changed, 433 insertions, 351 deletions
diff --git a/build/conf.zsh b/build/conf.zsh
index a929ac3..f5e8384 100644
--- a/build/conf.zsh
+++ b/build/conf.zsh
@@ -2,62 +2,432 @@
# (C) 2012 Denis Roio - GNU GPL v3
# refer to zmake for license details
-# build packages in order
-pkgs=(
- busybox
- system
- media
- sound
- lang
- toys
-
-# daemons
-)
-
-{ test "$module" = "list" } && {
- notice "Build modules: $pkgs"; return 0 }
-
-{ test "$module" = "all" } || { pkgs=("$module") }
{ test -r $module } || {
error "Module not found: $module"
return 1 }
+
+typeset TARGET TOOLCHAIN PREFIX
+typeset CC CXX LD AR RANLIB OBJCOPY STRIP
+
+
+
+init-toolchain-crosstool() {
+
+notice "Initializing Crosstool-NG toolchain"
+
+# configure the target
+export TARGET=arm-dyne-linux-gnueabi
+
+# toolchain full path
+export TOOLCHAIN=$ZHOME/toolchains/crosstool-ng/x-tools
+
+# configure the install prefix
+export PREFIX=$ZHOME/system
+
+# configure the compilers
+export CC=${ZHOME}/wrap/static-cc
+export CXX=${ZHOME}/wrap/static-c++
+export LD=${ZHOME}/wrap/static-ld
+export AR=${TOOLCHAIN}/bin/${TARGET}-ar
+export RANLIB=${TOOLCHAIN}/bin/${TARGET}-ranlib
+export OBJCOPY=${TOOLCHAIN}/bin/${TARGET}-objcopy
+export STRIP=${TOOLCHAIN}/bin/${TARGET}-strip
+
+
+# configure the compile flags
+OPTIMIZATIONS="-Os -O2"
+CFLAGS=(-static -static-libgcc $OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include)
+#CFLAGS="$OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include $ANDROID_CFLAGS"
+CPPFLAGS=(-I$PREFIX/include)
+CXXFLAGS=$CFLAGS
+LDFLAGS=(-static -static-libgcc -L$TOOLCHAIN/$TARGET/sysroot/lib -L$TOOLCHAIN/$TARGET/sysroot/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib)
+# LDFLAGS="-L$TOOLCHAIN/$TARGET/sysroot/lib -L$TOOLCHAIN/$TARGET/sysroot/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib"
+# LDFLAGS="$ANDROID_LDFLAGS -L$PREFIX/lib -L$PREFIX/usr/lib"
+# PATH="$PATH:$ANDROID_NDK/toolchains/$ANDROID_TOOLCHAIN/bin"
+PATH=$TOOLCHAIN/bin:$ZHOME/wrap:/bin:/usr/bin
+
+export PATH
+export CFLAGS
+export CPPFLAGS
+export CXXFLAGS
+export LDFLAGS
+}
+
+
+init-toolchain-android() {
+
+notice "Initializing Android-NDK toolchain"
+
+# configure the target
+export TARGET=arm-linux-androideabi
+
+# toolchain full path
+export TOOLCHAIN=$ZHOME/toolchains/arm-linux-androideabi-4.6
+
+# NDK full path
+NDK=/android/android-ndk-r9b
+
+# SYSROOT=$NDK/platforms/android-8/arch-arm
+export SYSROOT=$TOOLCHAIN/sysroot
+
+# configure the install prefix
+export PREFIX=$ZHOME/system
+
+# configure the compilers
+export CC=${ZHOME}/wrap/static-cc
+export CXX=${ZHOME}/wrap/static-c++
+export LD=${ZHOME}/wrap/static-ld
+#CC=${TOOLCHAIN}/bin/${TARGET}-gcc
+#CXX=${TOOLCHAIN}/bin/${TARGET}-g++
+#LD=${TOOLCHAIN}/bin/${TARGET}-ld
+
+export AR=${TOOLCHAIN}/bin/${TARGET}-ar
+export RANLIB=${TOOLCHAIN}/bin/${TARGET}-ranlib
+export OBJCOPY=${TOOLCHAIN}/bin/${TARGET}-objcopy
+export STRIP=${TOOLCHAIN}/bin/${TARGET}-strip
+
+# configure the compile flags
+CFLAGS=(-I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include)
+CFLAGS+=(--sysroot=$SYSROOT)
+CFLAGS+=(-march=armv7-a -mfloat-abi=softfp) # -mfpu=neon) # architecture
+CFLAGS+=(-Os -O2) # optimization
+
+# some notes
+#ANDROID_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -fpic -fno-short-enums -fgcse-after-reload -frename-registers"
+#ANDROID_LDFLAGS="-L${ANDROID_NDK}/platforms/${ANDROID_PLATFORM}/usr/lib -Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined $ANDROID_NDK/platforms/$ANDROID_PLATFORM/usr/lib/crtbegin_dynamic.o $ANDROID_NDK/platforms/$ANDROID_PLATFORM/usr/lib/crtend_android.o -ldl -lm -lc -lgcc"
+
+
+CPPFLAGS=(-I$PREFIX/include)
+CPPFLAGS+=(--sysroot=$SYSROOT)
+
+CXXFLAGS=$CFLAGS
+LDFLAGS=(-L$SYSROOT/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib)
+LDFLAGS+=($ZHOME/wrap/libzshaolin.a)
+#LDFLAGS+=(-ldl -lm -lc -lgcc)
+LDFLAGS+=(--sysroot=$SYSROOT)
+LDFLAGS+=(-Wl,--fix-cortex-a8)
+# LDFLAGS="-L$TOOLCHAIN/$TARGET/sysroot/lib -L$TOOLCHAIN/$TARGET/sysroot/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib"
+# LDFLAGS="$ANDROID_LDFLAGS -L$PREFIX/lib -L$PREFIX/usr/lib"
+# PATH="$PATH:$ANDROID_NDK/toolchains/$ANDROID_TOOLCHAIN/bin"
+PATH=$TOOLCHAIN/bin:$ZHOME/wrap:/bin:/usr/bin
+
+# make sure we have the wrapper library for ndk crap
+#{ test -r $ZHOME/wrap/libzshaolin.a } || {
+ pushd $ZHOME/wrap
+ $TOOLCHAIN/bin/${TARGET}-gcc -c zshaolin.c -o zshaolin.o
+ $TOOLCHAIN/bin/${TARGET}-ar rcs libzshaolin.a zshaolin.o
+ popd
+#}
+
+export PATH
+export CFLAGS
+export CPPFLAGS
+export CXXFLAGS
+export LDFLAGS
+}
+
+
+init-toolchain() {
+
+case "$1" in
+ android) init-toolchain-android ;;
+ crosstool) init-toolchain-crosstool ;;
+ "") act "Unconfigured toolchain, default to crosstool"
+ init-toolchain-crosstool ;;
+ *) error "Unknown toolchain: $1"; return 1 ;;
+esac
+# make sure the toolchain exists in /usr
+if ! [ -r $TOOLCHAIN/bin/${TARGET}-gcc ]; then
+ error "error: toolchain not found: $TOOLCHAIN/bin/$TARGET-gcc"
+ error "first you need to bootstrap."
+# return 1
+fi
+
+notice "ZShaolin build system"
+act "Target: $TARGET"
+act "Toolchain: $TOOLCHAIN"
+act "Install: $PREFIX"
+func "CFLAGS: $CFLAGS"
+func "LDFLAGS: $LDFLAGS"
+func "Command: ${=@}"
+
+
+## make sure basic directories exist
+mkdir -p $PREFIX/sbin
+mkdir -p $PREFIX/bin
+
+return 0
+}
+
+
+# TODO: clean_sources
+prepare_sources() {
+ # look for a file names "Sources", download and decompress entries
+ # format of file: name version compression (complete filename when merged)
+ { test -r Sources } || {
+ error "Sources not found, nothing to build here"
+ return 1
+ }
+ for src in `cat Sources | awk '
+/^#/ {next}
+/^./ { print $1 ";" $2 ";" $3 }'`; do
+ name="${src[(ws:;:)1]}"
+ ver="${src[(ws:;:)2]}"
+ arch="${src[(ws:;:)3]}"
+ file="${name}${ver}${arch}"
+ func "preparing source for ${name}${ver}"
+ # download the file
+ { test -r ${file} } || {
+ act "downloading ${file}"
+ wget ${REPO}/${file}
+ }
+ # decompress the file
+ { test -r ${name} } || {
+ act "decompressing ${name}"
+ case $arch in
+ ## OPK
+ .opk)
+ mkdir -p extract
+ pushd extract
+ ln -sf ../${file} .
+ ar x ${file}
+ if [ -r data.tar.gz ]; then
+ tar xfz data.tar.gz
+ if [ $? = 0 ]; then
+ touch ../${name}.done
+ touch ../${name}.installed
+ else error "error decompressing tarred package"; fi
+ else error "data not found in package"; fi
+ popd
+ ;;
+
+ ## IPK
+ *.ipk)
+ mkdir -p extract
+ pushd extract
+ ln -sf ../${file} ${name}${ver}.tar.gz
+ tar xfz ${name}${ver}.tar.gz
+ if [ -r data.tar.gz ]; then
+ tar xfz data.tar.gz
+ if [ $? = 0 ]; then
+ touch ../${name}.done
+ touch ../${name}.installed
+ else error "error decompressing tarred package"; fi
+ else error "data not found in package"; fi
+ popd
+ ;;
+
+ ## BARE SOURCE
+ *.tar.gz) tar xfz ${file}; mv ${name}${ver} ${name} ;;
+ *.tar.bz2) tar xfj ${file}; mv ${name}${ver} ${name} ;;
+ *) error "compression not supported: $arch"
+ esac
+
+ }
+ act "${name} source ready"
+ done
+ LOGS="`pwd`/build.log"
+ { test -r $LOGS } && { rm -f $LOGS && touch $LOGS }
+}
+
+# array of args shifted around by compile()
+typeset -a compile_args
+
+
+zconfigure() {
+ func "zconfigure() : $@"
+ args=(${=@})
+
+ # configure the compile flags defaults
+# CFLAGS=${CFLAGS:-"-static -static-libgcc $OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include"}
+# CXXFLAGS=${CXXFLAGS:-$CFLAGS}
+
+ { test -r configure } || {
+ error "configure not found in `pwd`"
+ return 1 }
+
+ confflags=($=@)
+
+ { test "$args[1]" = "default" } && {
+ # expunge an array element
+ confflags=${confflags:#default}
+ confflags=(--host=arm-linux-gnueabi --prefix=$PREFIX $confflags)
+ }
+
+ func "CFLAGS = $CFLAGS"
+ func "configure = $confflags"
+
+ PATH=${PATH} \
+ CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
+ AR="${AR}" RANLIB="${RANLIB}" OBJCOPY="${OBJCOPY}" \
+ CFLAGS="$CFLAGS $extracflags" \
+ CPPFLAGS="$CPPFLAGS" \
+ CXXFLAGS="$CXXFLAGS" \
+ LDFLAGS="$LDFLAGS" \
+ PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" \
+ ./configure ${=confflags} | tee -a $LOGS
+ return $?
+}
+
+zmake() {
+
+ # pass extra arguments to make (for instance targets)
+ # check if logs don't exist print out to streen
+ if [ -r $LOGS ]; then
+ PATH=${PATH} \
+ CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
+ AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \
+ CFLAGS="$CFLAGS $extracflags" \
+ CPPFLAGS="$CPPFLAGS" \
+ CXXFLAGS="$CXXFLAGS" \
+ LDFLAGS="$LDFLAGS" \
+ make V=1 ${=@}
+ else
+ PATH=${PATH} \
+ CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
+ AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \
+ CFLAGS="$CFLAGS $extracflags" \
+ CPPFLAGS="$CPPFLAGS" \
+ CXXFLAGS="$CXXFLAGS" \
+ LDFLAGS="$LDFLAGS" \
+ make V=1 ${=@}
+ fi
+ { test $? = 0 } || {
+ error "error: make returns error value $?"
+ return 1
+ }
+ act "make was successful"
+ return 0
+}
+
+compile() {
+ notice "Building $1" | tee -a ${LOGS}
+ func "compile() : $@"
+ { test -r $1.done } && {
+ act "$1 already built, skipping compilation"
+ return 1 }
+
+
+ { test -r $1 } || {
+ error "source directory $1 not found, skipping compilation"
+ return 1 }
+
+ pushd $1
+
+ # eliminate path element from args
+ compile_args=(${=@}) && shift compile_args
+ # fancy search in array by zsh
+
+ { test "${compile_args[(r)nomake]}" -ge 1 } && {
+ # returns 1 if element with value nomake is found
+ compile_args=${compile_args:#nomake}
+ # eliminates element with value nomake from array
+ nomake=1
+ }
+
+
+ { test -r configure } && {
+ func "launching configure ${compile_args}"
+ zconfigure ${compile_args} | tee ${LOGS}
+
+ { test $? = 0 } || {
+ error "error: $1 cannot configure, build left incomplete"
+ popd; return 1 }
+ }
+
+ { test "$nomake" = "1" } || {
+
+ { test -r Makefile } && {
+ zmake # no arguments, use zmake directly from script if a
+ # customization is needed
+
+ { test $? = 0 } || {
+ error "error: make on $1 failed, build left incomplete"
+ popd; return 1 }
+ }
+
+ }
+ act "Build completed successfully for $1"
+ popd
+ touch $1.done
+ return 0
+}
+
+zinstall() {
+ func "zinstall() : $@"
+ { test ! -r $1.done } && {
+ error "$1 not yet built, skipping installation"
+ return 1 }
+
+ { test -r $1.installed } && { test "$FORCE" = "0" } && {
+ act "$1 is already installed, skipping"
+ return 1 }
+
+ target=install
+ { test "$2" = "" } || { target="$2" }
+
+ act "installing $1 (target ${target})" | tee -a ${LOGS}
+
+ PATH="${PATH}" PREFIX="$PREFIX" \
+ make -C $1 ${target}
+ { test $? = 0 } || {
+ error "error: $1 cannot make install, check permissions"
+ return 1
+ }
+
+ notice "$1 installed"
+ touch ${1}.installed
+ return 0
+}
+
+zndk-build() {
+ PATH="$NDK:$PATH"
+
+ pushd $1
+ ndk-build
+ popd
+
+ # { test ! -r $1.done } && {
+ # error "$1 not yet built, skipping installation"
+ # return 1 }
+
+ # { test -r $1.installed } && { test "$FORCE" = "0" } && {
+ # act "$1 is already installed, skipping"
+ # return 1 }
+}
+
+
case $operation in
clean)
- for i in $pkgs; do
- notice "Cleaning module: $i"
- pushd $i
+ notice "Cleaning module: $module"
+ pushd $module
for s in `cat Sources | awk '!/^#/ { print $1 }'`; do
act "clean $s"
rm -rf ${s} ${s}.done ${s}.installed
{ test -r extract } && { rm -rf extract }
done
popd
- done
notice "All clean now."
;;
*)
notice "Building module: $module"
- for i in $pkgs; do
- pushd $ZHOME/build
- enter $i ${=@}
- popd
- notice "Copying scripts and configurations present in module $i"
- { test -r ${i}/bin } && { rsync -dar ${i}/bin $PREFIX/ }
- { test -r ${i}/etc } && { rsync -dar ${i}/etc $PREFIX/ }
- { test -r ${i}/var } && { rsync -dar ${i}/var $PREFIX/ }
- { test -r ${i}/share } && { rsync -dar ${i}/share $PREFIX/ }
- done
-
+ pushd $ZHOME/build
+ init-toolchain `cat $module/Toolchain`
+ enter $module ${=@}
+ popd
+ notice "Copying scripts and configurations present in module $module"
+ { test -r ${module}/bin } && { rsync -dar ${module}/bin $PREFIX/ }
+ { test -r ${module}/etc } && { rsync -dar ${module}/etc $PREFIX/ }
+ { test -r ${module}/var } && { rsync -dar ${module}/var $PREFIX/ }
+ { test -r ${module}/share } && { rsync -dar ${module}/share $PREFIX/ }
notice "Build completed, summary:"
- for i in $pkgs; do
- notice "$i module"
- summary=`find $ZHOME/build/$i -name "*.done"`
+ notice "$module module"
+ summary=`find $ZHOME/build/$module -name "*.done"`
summary+="\n"
- summary+=`find $ZHOME/build/$i -name "*.installed"`
+ summary+=`find $ZHOME/build/$module -name "*.installed"`
echo ${summary} | sort
- done
;;
esac
diff --git a/build/system/Sources b/build/system/Sources
index ccb3594..fcfe8fa 100644
--- a/build/system/Sources
+++ b/build/system/Sources
@@ -1,20 +1,19 @@
# ZShaolin packages file
-
zlib -1.2.5 .tar.gz http://www.gnu.org
ncurses -5.9 .tar.gz
slang -2.2.4 .tar.bz2 http://www.jedsoft.org/slang/
zsh -4.3.15 .tar.bz2 http://www.zsh.org
-gawk -4.0.0 .tar.bz2 http://www.gnu.org
sed -4.2.1 .tar.bz2 http://www.gnu.org
+gawk -4.0.0 .tar.bz2 http://www.gnu.org
grep -2.9 .tar.gz http://www.gnu.org
diffutils -3.2 .tar.gz http://www.gnu.org
+file -5.11 .tar.gz
+less -451 .tar.gz
most -5.0.0a .tar.bz2 http://www.jedsoft.org/slang/
htop -1.0 .tar.gz
nano -2.2.6 .tar.gz
wipe -2.3.1 .tar.bz2
-file -5.11 .tar.gz
-less -451 .tar.gz
#libevent -2.0.21-stable .tar.gz http://libevent.org/
#tmux -1.7 .tar.gz http://tmux.sourceforge.net/
diff --git a/build/system/Toolchain b/build/system/Toolchain
new file mode 100644
index 0000000..60bb655
--- /dev/null
+++ b/build/system/Toolchain
@@ -0,0 +1 @@
+crosstool
diff --git a/build/system/conf.zsh b/build/system/conf.zsh
index 5150c4f..157b272 100644
--- a/build/system/conf.zsh
+++ b/build/system/conf.zsh
@@ -14,6 +14,7 @@ prepare_sources
###########################################
## COMPILE PACKAGES:
+
## zlib
compile zlib "--prefix=$PREFIX --static"
#zinstall zlib
@@ -26,21 +27,23 @@ touch zlib.installed
}
## ncurses
-compile ncurses default \
- "--enable-widec --enable-ext-colors --enable-ext-mouse --without-trace --without-tests --without-debug --disable-big-core"
+compile ncurses default "--enable-ext-mouse --without-trace --without-tests --without-debug --disable-big-core --enable-widec --enable-ext-colors"
zinstall ncurses
+# create ncurses symlinks in PREFIX
pushd $PREFIX/include
ln -sf ncursesw/* .
popd
pushd $PREFIX/lib
ln -sf libncursesw.a libncurses.a
+ln -sf libncursesw.a libcurses.a
popd
+
## s-lang
notice "Building S-Lang"
{ test -r slang.done } || {
pushd slang
- zconfigure default --disable-static
+ zconfigure default # --disable-static
{ test $? = 0 } && {
pushd src && make static >> $LOGS
{ test $? = 0 } && { touch ../../slang.done }
@@ -48,25 +51,27 @@ notice "Building S-Lang"
popd }
zinstall slang install-static
-## zsh
-compile zsh default
-zinstall zsh
-{test $? = 0 } && {
- # zcompile the grmlrc script to gain loading speed
- zcompile $PREFIX/etc/grmlrc }
-
-# awk
-compile gawk default
-zinstall gawk
## sed
compile sed default
zinstall sed
+# awk
+compile gawk default
+zinstall gawk
+
## grep
compile grep default
zinstall grep
+## file
+compile file default
+zinstall file
+
+# less pager
+compile less default
+zinstall less
+
## diff
compile diffutils default
zinstall diffutils
@@ -104,15 +109,6 @@ compile wipe default
act "Wipe installed."
}
-## file
-compile file default
-zinstall file
-
-# less pager
-compile less default
-zinstall less
-
-
## libevent
#compile libevent default
#zinstall libevent
diff --git a/wrap/static-cc b/wrap/static-cc
index df3c1e0..bea3c1c 100755
--- a/wrap/static-cc
+++ b/wrap/static-cc
@@ -29,7 +29,7 @@ typeset -a cflags cppflags ldflags
typeset -lA libraries # map (name, static|dynamic)
typeset -h argc
-QUIET=1 source ${ZHOME}/zmake source
+# QUIET=1 source ${ZHOME}/zmake source
case `basename $0`; in
static-cc|cc|gcc) cc=${TOOLCHAIN}/bin/${TARGET}-gcc ;;
diff --git a/zmake b/zmake
index 5a0a285..ef8eaf6 100755
--- a/zmake
+++ b/zmake
@@ -2,7 +2,7 @@
# {{{ LICENSE
-# Copyright (C) 2012 Denis Roio <jaromil@dyne.org>
+# Copyright (C) 2012-2013 Denis Roio <jaromil@dyne.org>
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Public License as published by
@@ -28,9 +28,6 @@ FORCE=${FORCE:-0}
QUIET=${QUIET:-0}
DEBUG=${DEBUG:-0}
-
-# configure the target
-TARGET=arm-dyne-linux-gnueabi
#TARGET=arm-linux-androideabi
# same value should be the bootstrap target
@@ -42,18 +39,10 @@ APKPATH=/data/data/org.dyne.zshaolin
LOGS=build.log
## Architecture compiler flags
-OPTIMIZATIONS="-Os -O2"
-ARCH="-mfloat-abi=softfp -march=armv7-a -mtune=cortex-a8"
+#ARCH="-mfloat-abi=softfp -march=armv7-a -mtune=cortex-a8"
# very old devices: ARCH="-march=armv5 -mfloat-abi=softfp"
REPO="http://files.dyne.org/zshaolin/sources"
-# }}}
-
-ANDROID_NDK="/srv/android/android-ndk-r8b"
-ANDROID_PLATFORM="android-8/arch-arm"
-ANDROID_TOOLCHAIN="arm-linux-androideabi-4.6/prebuilt/linux-x86"
-ANDROID_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -fpic -fno-short-enums -fgcse-after-reload -frename-registers"
-ANDROID_LDFLAGS="-L${ANDROID_NDK}/platforms/${ANDROID_PLATFORM}/usr/lib -Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined $ANDROID_NDK/platforms/$ANDROID_PLATFORM/usr/lib/crtbegin_dynamic.o $ANDROID_NDK/platforms/$ANDROID_PLATFORM/usr/lib/crtend_android.o -ldl -lm -lc -lgcc"
autoload colors; colors
@@ -72,9 +61,7 @@ act() {
fi
}
-typeset ZHOME TOOLCHAIN PREFIX
-typeset CC CXX LD AR RANLIB OBJCOPY STRIP
-
+typeset ZHOME
{ test "$ZHOME" = "" } && {
error "Set ZHOME environment to Zshaolin path"
@@ -85,57 +72,6 @@ typeset CC CXX LD AR RANLIB OBJCOPY STRIP
}
-# toolchain full path
-#TOOLCHAIN=$ZHOME/toolchains/google-ndk
-TOOLCHAIN=$ZHOME/toolchains/crosstool-ng/x-tools
-# configure the install prefix
-PREFIX=$ZHOME/system
-# configure the compilers
-CC=${ZHOME}/wrap/static-cc
-CXX=${ZHOME}/wrap/static-c++
-LD=${ZHOME}/wrap/static-ld
-AR=${TOOLCHAIN}/bin/${TARGET}-ar
-RANLIB=${TOOLCHAIN}/bin/${TARGET}-ranlib
-OBJCOPY=${TOOLCHAIN}/bin/${TARGET}-objcopy
-STRIP=${TOOLCHAIN}/bin/${TARGET}-strip
-
-
-# configure the compile flags
-CFLAGS=(-static -static-libgcc $OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include)
-#CFLAGS="$OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include $ANDROID_CFLAGS"
-CPPFLAGS=(-I$PREFIX/include)
-CXXFLAGS=$CFLAGS
-LDFLAGS=(-static -static-libgcc -L$TOOLCHAIN/$TARGET/sysroot/lib -L$TOOLCHAIN/$TARGET/sysroot/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib)
-# LDFLAGS="-L$TOOLCHAIN/$TARGET/sysroot/lib -L$TOOLCHAIN/$TARGET/sysroot/usr/lib -L$PREFIX/lib -L$PREFIX/usr/lib"
-# LDFLAGS="$ANDROID_LDFLAGS -L$PREFIX/lib -L$PREFIX/usr/lib"
-# PATH="$PATH:$ANDROID_NDK/toolchains/$ANDROID_TOOLCHAIN/bin"
-PATH=$TOOLCHAIN/bin:$ZHOME/wrap:$PATH
-
-
-
-
-
-# make sure the toolchain exists in /usr
-if ! [ -r $TOOLCHAIN/bin/${TARGET}-gcc ]; then
- error "error: toolchain not found: $TOOLCHAIN/bin/$TARGET-gcc"
- error "first you need to bootstrap."
-# return 1
-fi
-
-notice "ZShaolin build system"
-act "Target: $TARGET"
-act "Toolchain: $TOOLCHAIN"
-act "Install: $PREFIX"
-func "CFLAGS: $CFLAGS"
-func "LDFLAGS: $LDFLAGS"
-func "Command: ${=@}"
-
-
-## make sure basic directories exist
-mkdir -p $PREFIX/sbin
-mkdir -p $PREFIX/bin
-
-
enter() {
if ! [ -r $1/conf.zsh ]; then
error "build directory misses configuration file: $1/conf.zsh"
@@ -145,227 +81,7 @@ enter() {
act "Enter `pwd`"
shift
source conf.zsh
- popd
-}
-
-# TODO: clean_sources
-prepare_sources() {
- # look for a file names "Sources", download and decompress entries
- # format of file: name version compression (complete filename when merged)
- { test -r Sources } || {
- error "Sources not found, nothing to build here"
- return 1
- }
- for src in `cat Sources | awk '
-/^#/ {next}
-/^./ { print $1 ";" $2 ";" $3 }'`; do
- name="${src[(ws:;:)1]}"
- ver="${src[(ws:;:)2]}"
- arch="${src[(ws:;:)3]}"
- file="${name}${ver}${arch}"
- func "preparing source for ${name}${ver}"
- # download the file
- { test -r ${file} } || {
- act "downloading ${file}"
- wget ${REPO}/${file}
- }
- # decompress the file
- { test -r ${name} } || {
- act "decompressing ${name}"
- case $arch in
- ## OPK
- .opk)
- mkdir -p extract
- pushd extract
- ln -sf ../${file} .
- ar x ${file}
- if [ -r data.tar.gz ]; then
- tar xfz data.tar.gz
- if [ $? = 0 ]; then
- touch ../${name}.done
- touch ../${name}.installed
- else error "error decompressing tarred package"; fi
- else error "data not found in package"; fi
- popd
- ;;
-
- ## IPK
- *.ipk)
- mkdir -p extract
- pushd extract
- ln -sf ../${file} ${name}${ver}.tar.gz
- tar xfz ${name}${ver}.tar.gz
- if [ -r data.tar.gz ]; then
- tar xfz data.tar.gz
- if [ $? = 0 ]; then
- touch ../${name}.done
- touch ../${name}.installed
- else error "error decompressing tarred package"; fi
- else error "data not found in package"; fi
- popd
- ;;
-
- ## BARE SOURCE
- *.tar.gz) tar xfz ${file}; mv ${name}${ver} ${name} ;;
- *.tar.bz2) tar xfj ${file}; mv ${name}${ver} ${name} ;;
- *) error "compression not supported: $arch"
- esac
-
- }
- act "${name} source ready"
- done
- LOGS="`pwd`/build.log"
- { test -r $LOGS } && { rm -f $LOGS && touch $LOGS }
-}
-
-# array of args shifted around by compile()
-typeset -a compile_args
-
-
-zconfigure() {
- func "zconfigure() : $@"
- args=(${=@})
-
- # configure the compile flags defaults
-# CFLAGS=${CFLAGS:-"-static -static-libgcc $OPTIMIZATIONS $ARCH -I$TOOLCHAIN/$TARGET/sysroot/usr/include -I$PREFIX/include"}
-# CXXFLAGS=${CXXFLAGS:-$CFLAGS}
-
- { test -r configure } || {
- error "configure not found in `pwd`"
- return 1 }
-
- confflags=($=@)
-
- { test "$args[1]" = "default" } && {
- # expunge an array element
- confflags=${confflags:#default}
- confflags=(--host=$TARGET --prefix=$PREFIX $confflags)
- }
-
- func "CFLAGS = $CFLAGS"
- func "configure = $confflags"
-
- PATH=${PATH} \
- CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
- AR="${AR}" RANLIB="${RANLIB}" OBJCOPY="${OBJCOPY}" \
- CFLAGS="$CFLAGS $extracflags" \
- CPPFLAGS="$CPPFLAGS" \
- CXXFLAGS="$CXXFLAGS" \
- LDFLAGS="$LDFLAGS" \
- PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" \
- ./configure ${=confflags} >> $LOGS
- return $?
-}
-
-zmake() {
-
- # pass extra arguments to make (for instance targets)
- # check if logs don't exist print out to streen
- if [ -r $LOGS ]; then
- PATH=${PATH} \
- CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
- AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \
- CFLAGS="$CFLAGS $extracflags" \
- CPPFLAGS="$CPPFLAGS" \
- CXXFLAGS="$CXXFLAGS" \
- LDFLAGS="$LDFLAGS" \
- make V=1 ${=@} >> ${LOGS}
- else
- PATH=${PATH} \
- CC="${CC}" CXX="${CXX}" LD="${LD}" STRIP="${STRIP}" \
- AR="${TARGET}-ar" RANLIB="${TARGET}-ranlib" \
- CFLAGS="$CFLAGS $extracflags" \
- CPPFLAGS="$CPPFLAGS" \
- CXXFLAGS="$CXXFLAGS" \
- LDFLAGS="$LDFLAGS" \
- make V=1 ${=@}
- fi
- { test $? != 0 } && {
- error "error: make returns error value $?"
- return 1
- }
- act "make was successful"
- return 0
-}
-
-compile() {
- notice "Building $1" | tee -a ${LOGS}
- func "compile() : $@"
- { test -r $1.done } && {
- act "$1 already built, skipping compilation"
- return 1 }
-
-
- { test -r $1 } || {
- error "source directory $1 not found, skipping compilation"
- return 1 }
-
- pushd $1
-
- # eliminate path element from args
- compile_args=(${=@}) && shift compile_args
- # fancy search in array by zsh
-
- { test "${compile_args[(r)nomake]}" -ge 1 } && {
- # returns 1 if element with value nomake is found
- compile_args=${compile_args:#nomake}
- # eliminates element with value nomake from array
- nomake=1
- }
-
-
- { test -r configure } && {
- func "launching configure ${compile_args}"
- zconfigure ${compile_args} >> ${LOGS}
-
- { test $? = 0 } || {
- error "error: $1 cannot configure, build left incomplete"
- popd; return 1 }
- }
-
- { test "$nomake" = "1" } || {
-
- { test -r Makefile } && {
- zmake # no arguments, use zmake directly from script if a
- # customization is needed
-
- { test $? = 0 } || {
- error "error: make on $1 failed, build left incomplete"
- popd; return 1 }
- }
-
- }
- act "Build completed successfully for $1"
- popd
- touch $1.done
- return 0
-}
-
-zinstall() {
- func "zinstall() : $@"
- { test ! -r $1.done } && {
- error "$1 not yet built, skipping installation"
- return 1 }
-
- { test -r $1.installed } && { test "$FORCE" = "0" } && {
- act "$1 is already installed, skipping"
- return 1 }
-
- target=install
- { test "$2" = "" } || { target="$2" }
-
- act "installing $1 (target ${target})" | tee -a ${LOGS}
-
- PATH="${PATH}" PREFIX="$PREFIX" \
- make -C $1 ${target} >> ${LOGS}
- if [ $? != 0 ]; then
- error "error: $1 cannot make install, check permissions"
- return 1
- fi
-
- notice "$1 installed"
- touch ${1}.installed
- return 0
+# popd
}
list_sources() {