#!/bin/sh
# test we are root
if [ "$(id -u)" != "0" ]; then
   echo "run as root now exitting"
   exit 1
fi

export CFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe"
export CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a72 -Os -pipe -fno-exceptions -fno-rtti"

P=lzip
V=1.23
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc  "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp 
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://mirror.freedif.org/GNU-Sa/$P/$SRC.tar.gz"  $USER
tar xvf $SRC*gz
cd $SRC
./configure --prefix=/usr/local 
make -j5 # about 18 secs
make install-strip DESTDIR=/tmp/$P
cd /tmp

# main- remove man and info in one command
#######
rm -rf  $P/usr/local/share
mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v2 ' >  $P/usr/local/share/doc/$P/COPYING	

# TCZ them
###########
LIST2="$P "
for Z in $LIST2
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find usr -not -type d > /tmp/$Z.tcz.list
        sed 's|usr|/usr|g' -i /tmp/$Z.tcz.list
	cd /tmp
done

ls -hal

echo 'Title:          lzip.tcz
Description:    lossless data compressor  
Version:        1.23
Author:         Antonio Diaz Diaz
Original-site:  https://mirror.freedif.org/GNU-Sa/lzip/
Copying-policy: GPL v2 
Size:           64K
Extension_by:   aus9
Tags:           compression lzma
Comments:       online man page https://manpages.org/lzip
                
Change-log:     2020/09/01 v 1.21 on 12x was 32 bit 
Current:        2023/06/03 v 1.23 on 14x' > $P.tcz.info

readelf -d /usr/local/bin/$P | grep 'NEEDED'
#[libstdc++.so.6]  [libm.so.6]  [libgcc_s.so.1]  [libc.so.6] all TCB

submitqc --libs

rm -rf *.zsync*


