#!/bin/sh
#
######################################################
# Build script for TinyCore 2.x                     					  #
#                                                    						  	  #
# See .info for details                              					  #
#                                                    							  #
# December 23, 2009                                   					  #
######################################################
# Build dependency list
# compiletc
# Xorg-7.4-dev.tcz
# gtk2-dev.tcz
# gtk2.tczl
# glib2-dev.tcz
# glib2.tczl
# icu.tcz
# libxslt.tczl
# libsoup-dev.tcz
# libsoup.tczl
# openssl-0.9.8h-dev.tcz
# openssl-0.9.8h.tczl
# sqlite3-dev
# sqlite3.tczl
# gstreamer.tczl
# gst-plugins-base.tczl
# enchant-dev.tcz
# enchant.tczl
# webkit.tczl
# webkit-dev.tcz
# libxml2.tczl
# libxml2.tcz
# librsvg.tczl
# libnotify.tczl
# gettext
######################################################
# Configure extension creation parameters           				  #
######################################################

SRCNAM=midori-0.2.2.tar.bz2
WRKDIR=midori-0.2.2
TMPDIR=/tmp/package


######################################################
# Prepare extension creation                         					  #
######################################################

# Remove dirs and files left from previous creation

rm -r -f $WRKDIR

rm -r -f $TMPDIR

# Create temporary directory

mkdir -p $TMPDIR

######################################################
# Compile extension                                  					  #
######################################################

# Export variables needed for compilation

export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig

# Unpack source in current directory

tar -xf $SRCNAM

# Configure it

cd $WRKDIR
./configure --prefix=/usr/local --disable-unique --enable-libnotify --enable-sqlite --disable-hildon \
--disable-libidn --enable-nls --enable-addons

# Compile

make

# Install in base temp dir

make install DESTDIR=$TMPDIR

cd ..
rm -r -f $WRKDIR

# Adjust directory access rigths

find $TMPDIR/ -type d | xargs chmod -v 755;

# Strip executables

cd $TMPDIR

find . | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

find . | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null
