#!/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=leafpad
V=0.8.17
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc squashfs-tools zsync gettext perl5 gtk2-dev "   
    for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
su -c "wget http://savannah.nongnu.org/download/$P/$SRC.tar.gz"  $USER
mkdir $P
tar xvf $SRC*gz
cd $SRC
./configure --prefix=/usr/local	
make -j5 # takes 10 secs
make install-strip DESTDIR=/tmp/$P
cd /tmp

# locale
#########
mkdir -p $P-locale/usr/local/share
mv $P/usr/local/share/locale $P-locale/usr/local/share

# main
#######
APP=$P/usr/local/share/applications/$P.desktop
echo 'X-FullPathIcon=/usr/local/share/pixmaps/leafpad.png' >> $APP

# TCZ them
###########
LIST="$P $P-locale "
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
        zsyncmake $Z.tcz
done

ls -hal

echo 'Title:          leafpad-locale.tcz  
Description:    locales
Version:        0.8.17
Author:         Tarot Osuji
Original-site:  http://tarot.freeshell.org/leafpad/
Copying-policy: GPL v2
Size:           44K		
Extension_by:   aus9
Tags:           gtk2 text editor locale
Comments:       locales untested by me

Change-log:     2020/09/06 original v 0.8.17 on 12x 
Current:        2020/09/06
'> leafpad-locale.tcz.info


echo 'Title:          leafpad.tcz  
Description:    gtk2 GUI text editor
Version:        0.8.17
Author:         Tarot Osuji
Original-site:  http://tarot.freeshell.org/leafpad/
Copying-policy: GPL v2
Size:           52K		
Extension_by:   aus9
Tags:           gtk2 text editor 
Comments:       May support UTF-8...Keybindings
                Ctrl-N New ....Ctrl-O Open
                Ctrl-S Save...Shift-Ctrl-S Save As
                Ctrl-W Close....Ctrl-P Print
                Ctrl-Q Quit...Ctrl-Z Undo
                Shift-Ctrl-Z (Ctrl-Y) Redo
                Ctrl-X Cut...Ctrl-C Copy
                Ctrl-V Paste..Ctrl-A Select All
                Ctrl-F Find..Ctrl-G (F3) Find Next
                Shift-Ctrl-G (Shift-F3) Find Previous
                Ctrl-H (Ctrl-R) Replace
                Ctrl-J Jump To
                Ctrl-T Always on Top
                Ctrl-Tab toggle tab width
                Tab with selection bound  multi-line indent
                Shift-Tab with selection bound multi-line unindent 

                Optional TCE   mononoki-ttf-fonts.tcz if you like zero with a slash       
 
Change-log:     2020/09/06 original v 0.8.17 on 12x 
Current:        2020/09/06
'> leafpad.tcz.info

echo 'gtk2.tcz' > $P.tcz.dep
echo 'leafpad.tcz' > $P-locale.tcz.dep
