#!/bin/bash
# test we are root
if [ "$(id -u)" != "0" ]; then
   exit 1
fi

export CFLAGS="-mtune=generic -Os -pipe"
export CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti"

P=scdoc
V=1.11.3
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://git.sr.ht/~sircmpwn/$P/archive/$V.tar.gz " $USER
tar xvf $V*gz
cd $SRC
make PREFIX=/usr/local # seconds
make check
# a number of tests.....all OK
make install DESTDIR=/tmp/$P # no strip possible 
cd /tmp

# dev
#####
mkdir -p $P-dev/usr/local/lib
mv $P/usr/local/share/pkgconfig $P-dev/usr/local/lib/

# doc
#####
mkdir -p $P-doc/usr/local/share
mv $P/usr/local/share/man $P-doc/usr/local/share/

# main
######
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/COPYING  $P/usr/local/share/doc/$P/
strip --strip-unneeded $P/usr/local/bin/$P

# TCE
#######
LIST="$P $P-doc $P-dev "
for Z in $LIST
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:          scdoc-dev.tcz 
Description:    dev file  
Version:        1.11.3
Author:         Drew DeVault
Original-site:  https://git.sr.ht/%7Esircmpwn/scdoc/
Copying-policy: Accompanied 
Size:           4.0K		
Extension_by:   aus9 @linuxquestions.org
Tags:           man 
Comments:       one pc file

Change-log:     2018/07/24 v 1.4.1 
                2019/04/04 v 1.9.4 on 10x 
                2019/04/25 add dev pkg
                2020/06/26 v 1.11.0 on 11x
Current:        2024/03/29 v 1.11.3 on 15x     ' > $P-dev.tcz.info
echo 'scdoc.tcz'  > $P-dev.tcz.dep

echo 'Title:          scdoc-doc.tcz 
Description:    man page  
Version:        1.11.3
Author:         Drew DeVault
Original-site:  https://git.sr.ht/%7Esircmpwn/scdoc/
Copying-policy: Accompanied 
Size:           4.0K		
Extension_by:   aus9 @linuxquestions.org 
Tags:           man 
Comments:       $ man  scdoc.1 is basic use 
                $ man scdoc.5 is how to write a manpage

Change-log:     2018/07/24 v 1.4.1 
                2019/04/04 v 1.9.4 on 10x 
                2019/04/25 add dev pkg
                2020/06/26 v 1.11.0 on 11x
Current:        2024/03/29 v 1.11.3 on 15x      ' > $P-doc.tcz.info
echo 'man-db.tcz' > $P-doc.tcz.dep

echo 'Title:          scdoc.tcz 
Description:    small man page generator 
Version:        1.11.3
Author:         Drew DeVault
Original-site:  https://git.sr.ht/%7Esircmpwn/scdoc/
Copying-policy: Accompanied 
Size:           356K	
Extension_by:   aus9 @linuxquestions.org 
Tags:           man 
Comments:       Simple man page generator 
                Input files must use the UTF-8 encoding

Change-log:     2018/07/24 v 1.4.1 
                2019/04/04 v 1.9.4 on 10x 
                2019/04/25 add dev pkg
                2020/06/26 v 1.11.0 on 11x
Current:        2024/03/29 v 1.11.3 on 15x      ' > $P.tcz.info


submitqc --libs
rm -rf *.zsync


readelf -d $P/usr/local/bin/$P | grep 'NEEDED'  # nothing so no dep





