#!/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.18.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc glib2-dev intltool"
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

# list may have more than loaded
cd /usr/local/lib
rm -rf *.la
rm -rf gcc/aarch64-unknown-linux-gnu/12.2.0/plugin/*.la
rm -rf gcc/aarch64-unknown-linux-gnu/12.2.0/*.la
rm -rf gprofng/*.la 
rm -rf python3.8/site-packages/*.la
rm -rf pkcs11/*.la
rm -rf cairo/*.la
rm -rf gtk-2.0/modules/*.la
rm -rf gtk-2.0/2.10.0/printbackends/*.la
rm -rf gtk-2.0/2.10.0/immodules/*.la
rm -rf gtk-2.0/2.10.0/engines/*.la
rm -rf imlib2/loaders/*.la
rm -rf imlib2/filters/*.la
rm -rf gdk-pixbuf-2.0/2.10.0/loaders/*.la
rm -rf libnl/cli
cd /tmp
rm -rf /usr/lib/*.la

su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://archive.xfce.org/xfce/4.18/src/$SRC.tar.bz2"  $USER
tar jxvf $SRC*bz2
cd $SRC
./configure --prefix=/usr/local --enable-introspection=no --disable-debug --enable-static=no --enable-nls
# Debug Support:  no
# GNU Visibility: yes
make -j4 # 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/
rm -rf  $P/usr/local/lib/*.la 

# 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/gtk-doc
mkdir -p $P/usr/local/share/doc/$P
echo 'LGPL v2' > $P/usr/local/share/doc/$P/COPYING

# TCZ them
###########
LIST2="$P $P-dev $P-locale"
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
done

ls -hal

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

Change-log:     2020/10/22 v 4.14.0 on 12.x
Current:        2023/06/20 v 4.18.0 on 14.x   ' > $P-dev.tcz.info
echo 'libxfce4util.tcz
glib2-dev.tcz
intltool.tcz ' > $P-dev.tcz.dep

echo 'Title:          libxfce4util-locale.tcz
Description:    language files
Version:        4.18.0
Author:         Benedikt Meurer, Jasper Huijsmans, Olivier Fourdan 
                Maarten Boekhold Xfce Development Team 
Original-site:  https://archive.xfce.org/xfce/4.18/src/
Copying-policy: LGPL v2
Size:           176K
Extension_by:   aus9
Tags:           xfce
Comments:       untested by me

Change-log:     2020/10/22 v 4.14.0 on 12.x
Current:        2023/06/20 v 4.18.0 on 14.x   ' > $P-locale.tcz.info
echo 'libxfce4util.tcz ' > $P-locale.tcz.dep

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

Change-log:     2020/10/22 v 4.14.0 on 12.x
Current:        2023/06/20 v 4.18.0 on 14.x ' > $P.tcz.info

readelf -d $P/usr/local/lib/* | grep 'NEEDED' # delete TCBs duplicates below
#[libgio-2.0.so.0]    glib2
#[libgobject-2.0.so.0] "
#[libglib-2.0.so.0]    "
readelf -d $P/usr/local/sbin/* | grep 'NEEDED'
#[libxfce4util.so.7] this TCE

echo 'glib2.tcz' > $P.tcz.dep

submitqc --libs 

rm -rf *.zsync



