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

# pref script was libxfce4util 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=xfconf
V=4.14.1
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc squashfs-tools wget zsync libxfce4util-dev dbus-glib-dev cpanm  "
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

cpanm ExtUtils::Depends ExtUtils::PkgConfig Glib
# takes about 1m 25s

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-checks --disable-nls --disable-debug
# GSettings Backend:         no
# GObject Introspection:     no
# Vala support:              no
# Debug:                     no
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
#########
rm -rf $P/usr/local/share/locale 

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

# 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:          xfconf-dev.tcz
Description:    dev files
Version:        4.14.1
Author:         Brian J. Tarricone & Stephan Arts 
Original-site:  https://archive.xfce.org/xfce/4.14/src/
Copying-policy: GPL v2
Size:           8K
Extension_by:   aus9
Tags:           xfce
Comments:       dev files

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

echo 'Title:          xfconf.tcz
Description:    configuration storage system for Xfce
Version:        4.14.1
Author:         Brian J. Tarricone & Stephan Arts  
Original-site:  https://archive.xfce.org/xfce/4.14/src/
Copying-policy: GPL v2
Size:           80K
Extension_by:   aus9
Tags:           xfce
Comments:       configuration storage system for Xfce

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

echo 'libxfce4util.tcz' > $P.tcz.dep
echo 'xfconf.tcz
libxfce4util-dev.tcz
perl5.tcz
dbus-glib.tcz ' > $P-dev.tcz.dep

# xfconf-query -l -- at this stage no useful test