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

# first script cpanm this is next

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=libxfce4util
V=4.14.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc squashfs-tools wget zsync glib2-dev intltool"
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://archive.xfce.org/xfce/4.14/src/$SRC.tar.bz2"  $USER
mkdir $P
tar jxvf $SRC*bz2
cd $SRC
./configure --prefix=/usr/local --enable-introspection=no \
--disable-nls --disable-debug --enable-static=no
# Debug Support:  no
# GNU Visibility: yes
make -j5 # takes seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# dev
#####
mkdir -p $P-dev/usr/local/lib/
mv $P/usr/local/include $P-dev/usr/local/
mv $P/usr/local/lib/pkgconfig $P-dev/usr/local/lib/
mv $P/usr/local/lib/*a $P-dev/usr/local/lib/
chmod 644 $P-dev/usr/local/lib/*a 

# no locale or doc
#########
rm -rf $P/usr/local/share

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

ls -hal

echo 'Title:          libxfce4util-dev.tcz
Description:    dev files
Version:        4.14.0
Author:         Benedikt Meurer, Jasper Huijsmans, Olivier Fourdan 
                Maarten Boekhold Xfce Development Team 
Original-site:  https://archive.xfce.org/xfce/4.14/src/
Copying-policy: LGPL v2
Size:           16K
Extension_by:   aus9
Tags:           xfce
Comments:       dev files

Change-log:     2020/10/22 Original 4.14.0 on 12x
Current:        2020/10/22   ' > $P-dev.tcz.info

echo 'Title:          libxfce4util.tcz
Description:    utility library for the Xfce
Version:        4.14.0
Author:         Benedikt Meurer, Jasper Huijsmans, Olivier Fourdan 
                Maarten Boekhold Xfce Development Team 
Original-site:  https://archive.xfce.org/xfce/4.14/src/
Copying-policy: LGPL v2
Size:           28K
Extension_by:   aus9
Tags:           xfce
Comments:       xfce utility files

Change-log:     2020/10/22 Original 4.14.0 on 12x
Current:        2020/10/22   ' > $P.tcz.info

echo 'glib2.tcz' > $P.tcz.dep
echo 'libxfce4util.tcz
glib2-dev.tcz
intltool.tcz ' > $P-dev.tcz.dep

# xfce4-kiosk-query at this stage no useful test