#!/bin/sh
# 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=l3afpad
V=0.8.18.1.11
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc perl5 gtk3-dev automake intltool gettext-dev"
    for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
URL=http://tinycorelinux.net/14.x/x86_64/tcz/src/l3afpad
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/stevenhoneyman/l3afpad/archive/refs/tags/v$V.tar.gz "  $USER
tar xvf v$V*gz
cd $SRC

./autogen.sh
./autogen.sh autoupdate
./configure --prefix=/usr/local --enable-print
make -j5 # takes secondss
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
#######
rm -rf $P/usr/local/share/pixmaps/l3afpad.xpm
APP=$P/usr/local/share/applications/$P.desktop
echo 'X-FullPathIcon=/usr/local/share/pixmaps/l3afpad.png' >> $APP

mkdir -p $P/usr/local/share/doc/$P
echo 'LGPL v 2.1' > $P/usr/local/share/doc/$P/COPYING

# 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 . -not -type d | cut -c 2- | sort > /tmp/$Z.tcz.list
	cd /tmp
done

ls -hal

echo 'Title:          l3afpad-locale.tcz
Description:    language files
Version:        0.8.18.1.11
Author:         Steven Honeyman
Original-site:  https://github.com/stevenhoneyman/l3afpad
Copying-policy: LGPL v 2.1
Size:           80K
Extension_by:   aus9 @linuxquestions.org
Tags:           gtk3 text editor
Comments:       not tested 

Change-log:     2025/01/01 v 0.8.18.1.11 on 15x
Current:        2025/03/20 rebuilt on 16x - add missing glyph font dep' > $P-locale.tcz.info
echo 'l3afpad.tcz' > $P-locale.tcz.dep

echo 'Title:          l3afpad.tcz
Description:    gtk3 text editor
Version:        0.8.18.1.11
Author:         Steven Honeyman
Original-site:  https://github.com/stevenhoneyman/l3afpad
Copying-policy: LGPL v 2.1
Size:           112K
Extension_by:   aus9 @linuxquestions.org
Tags:           gtk3 text editor
Comments:       fork of leafpad to gtk3...Features:
                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-J Jump To
Ctrl-H (Ctrl-R) Replace..............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 mupdf is much smaller than evince for print preview
                1) choose print to file will default to ~/output.pdf 
                unless you change it.....then click on print to create file
                2) $ mupdf /pathway2/output.pdf 

Change-log:     2025/01/01 v 0.8.18.1.11 on 15x
Current:        2025/03/20 rebuilt on 16x - add missing glyph font dep' > $P.tcz.info

readelf -d $P/usr/local/bin/$P | grep 'NEEDED'
#libgtk-3.so.0]#libgdk-3.so.0]gtk3
#libpangocairo-1.0.so.0]#libpango-1.0.so.0]pango gtk3
#libharfbuzz.so.0]harfbuzz gtk3
#libatk-1.0.so.0]at-spi2-core gtk3
#libcairo-gobject.so.2]libcairo.so.2]cairo pango gtk3
#libgdk_pixbuf-2.0.so.0]gdk-pixbuf2 gtk3
#libgio-2.0.so.0]libgobject-2.0.so.0]libglib-2.0.so.0]glib2 gtk3
echo 'gtk3.tcz
dejavu-fonts-ttf.tcz' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

# test printer ok
# about l3afpad will display ugly font as it needs a font....dejavu


