#!/bin/sh
#
######################################################
# Build script for TinyCore 2.x                     					  #
#                                                    						  	  #
# See .info for details                              					  #
#                                                    							  #
# December 21, 2009                                   					  #
######################################################
# Build dependency list
# compiletc
# glib2.tczl
# glib2-dev.tcz
######################################################
# Configure extension creation parameters           				  #
######################################################

SRCNAM=enchant-1.5.0.tar.gz
WRKDIR=enchant-1.5.0
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-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 --enable-ispell --with-ispell-dir=/usr/local/lib --enable-aspell --with-aspell-prefix=/usr/local \
--disable-myspell --disable-zemberek --disable-voikko --disable-hspell

# 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
