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

# prev script xfconf 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=libxfce4ui
V=4.18.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc xfconf-dev libX11-dev gtk3-dev libICE-dev "
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.18/src/$SRC.tar.bz2  "  $USER
tar jxvf $SRC*bz2
cd $SRC
./configure --prefix=/usr/local --enable-introspection=no --disable-debug 
# Glade 3.0 UI Designer:     no
# Keyboard library support:  yes
# Startup notification:      no
# X11 session management:    yes
# Debug support:             no
# Build tests:               no
# GNU Visibility:            yes
# Vendor:                    none
# System Info (libgtop):     no
# System Info (epoxy):       no (assumes libgtop)
# System Info (gudev):       no (assumes libgtop)
# Manual website:            https://docs.xfce.org/help.php
make -j4 # 18 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:          libxfce4ui-dev.tcz
Description:    dev files
Version:        4.18.0
Author:         Benedikt Meurer, Brian Tarricone, Jannis Pohlmann,
                Jasper Huijsmans, Nick Schermer & Olivier Fourdan 
Original-site:  https://archive.xfce.org/xfce/4.18/src/
Copying-policy: LGPL v2
Size:           20K
Extension_by:   aus9
Tags:           xfce
Comments:       dev files

Change-log:     2020/10/22 v 4.14.1 on 12.x
Current:        2023/06/20 v 4.18.0 on 14.x    ' > $P-dev.tcz.info
echo 'libxfce4ui.tcz
xfconf-dev.tcz 
libX11-dev.tcz 
gtk3-dev.tcz
libICE-dev.tcz ' > $P-dev.tcz.dep

echo 'Title:          libxfce4ui-locale.tcz
Description:    dev files
Version:        4.18.0
Author:         Benedikt Meurer, Brian Tarricone, Jannis Pohlmann,
                Jasper Huijsmans, Nick Schermer & Olivier Fourdan 
Original-site:  https://archive.xfce.org/xfce/4.18/src/
Copying-policy: LGPL v2
Size:           456K
Extension_by:   aus9
Tags:           xfce
Comments:       dev files

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

echo 'Title:          libxfce4ui.tcz
Description:    gtk3 widgets for other xfce TCEs
Version:        4.18.0
Author:         Benedikt Meurer, Brian Tarricone, Jannis Pohlmann,
                Jasper Huijsmans & Nick Schermer & Olivier Fourdan 
Original-site:  https://archive.xfce.org/xfce/4.18/src/
Copying-policy: LGPL v2
Size:           148K
Extension_by:   aus9
Tags:           xfce
Comments:       xfce utility files

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

readelf -d $P/usr/local/bin/* | grep 'NEEDED' #  delete TCBS duplicates below
#[libxfce4ui-2.so.0]this TCE
#[libxfce4util.so.7]libxfce4util xfconf
#[libgtk-3.so.0]gtk3
#[libgobject-2.0.so.0]glib2 libxfce4util xfconf
#[libglib-2.0.so.0]glib2       "
readelf -d $P/usr/local/lib/*.so | grep 'NEEDED' 
#[libgdk-3.so.0]                gtk3
#[libpangocairo-1.0.so.0]pango   "
#[libpango-1.0.so.0]pango        "
#[libharfbuzz.so.0]harfbuzz
#[libatk-1.0.so.0]atk  gtk3
#[libcairo-gobject.so.2]cairo pango gtk3
#[libcairo.so.2]cairo          -> gtk3
#[libgdk_pixbuf-2.0.so.0]gdk-pixbuf "
#[libSM.so.6]libSM
#[libICE.so.6]libICE
#[libX11.so.6]libX11 gdk-pixbuf gtk3
#[libxfconf-0.so.3]xfconf
#[libgio-2.0.so.0]glib2 -> xfconf

echo 'xfconf.tcz
gtk3.tcz
harfbuzz.tcz
libSM.tcz
libICE.tcz' > $P.tcz.dep

submitqc --libs 
rm -rf *.zsync
# xfce4-about -> GUI opens looks correct
