#!/bin/sh

SRCNAM=libarchive-2.7.0.tar.gz
WRKDIR=libarchive-2.7.0
TMPDIR=/tmp/libarchive

rm -r -f $WRKDIR

rm -r -f $TMPDIR

mkdir -p $TMPDIR

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:/usr/local/share/pkgconfig

tar -xf $SRCNAM

cd $WRKDIR

./configure --prefix=/usr/local

make

make install DESTDIR=$TMPDIR

cd ..

rm -r -f $WRKDIR

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

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
