compress() {

for i in usr/lib lib ; do
  if [ -d $P/$i ]; then
    cd $P/$i
    for j in *.so ; do
      chk=`file $j | grep "not stripped"`
      if [ ! "$chk.x" = ".x" ]; then
           echo "strip -g $j"
           strip -g $j
      fi
    done
    for j in *.a ; do
       chk=`file $j | grep "ar archive"`
       if [ ! "$chk.x" = "." ]; then
           echo "ranlib and strip -g $j"
           ranlib $j
           strip -g $j
       fi
    done
  fi
done

for i in usr/bin usr/sbin bin sbin; do
  if [ -d $P/$i ]; then
  ( cd $P/$i 
    for j in * ; do
      chk=`file $j | grep "not stripped"`
      if [ ! "$chk.x" = ".x" ]; then
         echo "strip $j"
	 strip $j
      fi
    done
  )
  fi
done

for i in 1 2 3 4 5 6 7 8 ; do
  if [ -d $P/usr/share/man/man$i ]; then
     ( cd $P/usr/share/man/man$i ; 
       for j in *.$i ; do
         if [ -h $j ] ; then
           LN_TARGET=`ls -l $j | awk '{print $11}'`
           rm $j
           ln -sf $LN_TARGET.gz $j.gz
         else
           gzip $j
         fi
       done
     )
  fi
done

}

##################
# ftp://ftp.kddlabs.co.jp
src=time-1.7
pkgbase=time
vers=1.7
arch=i386
build=P1
pkg=`echo $pkgbase"-"$vers"-"$arch"-"$build".tgz"`

###################

P=`pwd`/work
rm -rf $P
mkdir -p $P/usr

make clean
rm -rf config.cache config.log
./configure --prefix=/usr 
make

# make install prefix=$P/usr

compress

mkdir -p $P/usr/bin
 cp time $P/usr/bin
mkdir -p $P/usr/share/info
 cp *.info $P/usr/share/info
mkdir -p $P/usr/share/doc/$src
for i in ../PlamoBuild.time-1.7 AUTHORS COPYING ChangeLog NEWS INSTALL README ; do
  cp $i $P/usr/share/doc/$src
  gzip -f $P/usr/share/doc/$src/$i
done

cd $P
/sbin/makepkg $pkg << EOF
y
EOF

