#!/bin/sh
#
######################################################
# Build script for TinyCore 2.x                     					  #
#                                                    						  	  #
# See .info for details                              					  #
#                                                    							  #
# December 28, 2009                                   					  #
######################################################
# Build dependency list
# compiletc
# Xorg-7.4-dev
# glib2-dev
# glib2
# gtk2-dev
# gtk2
# dbus
# dbus-glib
# libxfcegui4-dev
# libxfcegui4
# libxfce4util-dev
# libxfce4util
# libxfconf-dev
# libxfconf
# libxml2-dev
# libxml2
# libstartup-notification
# libnotify
# gettext
######################################################
# Configure extension creation parameters           				  #
######################################################

SRCNAM=xfce4-power-manager-0.8.4.2.tar.bz2
WRKDIR=xfce4-power-manager
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

# 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
