#!/bin/sh
# test we are root
if [ "$USER" != "root" ] ; then
   echo "Run as root please, exiting." 
   exit 1                                                      
fi

export CFLAGS="-mtune=generic -Os -pipe"
export CXX="g++ -flto -fuse-linker-plugin -mtune=generic -Os -pipe "

P=libxfce4ui
V=4.13.4
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc gtk2-dev gtk3-dev xfconf-dev \
startup-notification-dev"
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

# later build scripts need gtk3

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
http://mirror.vinahost.vn/xfce/src/xfce/$P/4.13/$P-$V.tar.bz2  " $USER  
mkdir $P
tar jxvf $P*bz2
cd $P-$V
./configure --disable-debug --disable-gladeui --sysconfdir=/usr/local/etc  
##########################################################################
# Build Configuration:

# GTK2 support:                  yes
# Glade Interface Designer:      no
# Glade 3.0 Interface Designer:  no
# Keyboard library support:      yes
# Startup notification:          yes
# X11 session management:        yes
# Debug support:                 no
# Build tests:                   no
# GNU Visibility:               yes
# Vendor:                      none
* Manual website:            http://docs.xfce.org/help.php
##################################################################
make -j5
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/*a $P-dev/usr/local/lib/
mv $P/usr/local/lib/pkgconfig $P-dev/usr/local/lib/
chmod 644 $P-dev/usr/local/lib/*a

# locale
#########
mkdir -p $P-locale/usr/local/share
mv $P/usr/local/share/locale $P-locale/usr/local/share

# doc
#####
mkdir -p $P-doc/usr/local/share/doc/$P
mv $P/usr/local/share/gtk-doc $P-doc/usr/local/share/
cp $P-$V/AUTHORS $P-doc/usr/local/share/doc/$P
cp $P-$V/COPYING $P-doc/usr/local/share/doc/$P

# main
#####
# create copying file
mkdir -p $P/usr/local/share/doc/$P
echo 'see doc tcz for license' > $P/usr/local/share/doc/$P/COPYING 

# fix desktop
#############
# the filename must match the package name

KK=$P/usr/local/share/applications/$P.desktop
mv $P/usr/local/share/applications/xfce4-about.desktop $KK
# the icon name did not match the icon named in desktop file
mkdir -p $P/usr/local/share/pixmaps
cp $P/usr/local/share/icons/hicolor/48x48/apps/xfce4-logo.png  $P/usr/local/share/pixmaps/help-about.png
echo 'X-FullPathIcon=/usr/local/share/pixmaps/help-about.png ' \
>> $KK

# no wbar as its designed to run on XFCE
# desktop has entry show only in XFCE --OK


# TCZ them
#######
LIST="$P $P-doc $P-dev $P-locale"
for Z in $LIST
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

echo 'libxfce4ui.tcz
gtk3-dev.tcz
gtk2-dev.tcz
xfconf-dev.tcz
startup-notification-dev.tcz' > $P-dev.tcz.dep 

echo 'xfconf.tcz
gnome-icon-theme.tcz
gtk2.tcz
gtk3.tcz
startup-notification.tcz' > $P.tcz.dep

echo 'libxfce4ui.tcz' > $P-locale.tcz.dep

echo 'Title:          libxfce4ui.tcz  
Description:    xfce gtk2/3 widgets
Version:        4.13.4
Author:         see doc for authors  
Original-site:  xfce.org
Copying-policy: LGPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       shareable widgets across XFCE apps                    
 
                Compiled for 64 9.x
Change-log:     2018/01/03  First version 
Current:        2018/01/03
' > $P.tcz.info

echo 'Title:          libxfce4ui-doc.tcz
Description:    some docs
Version:        4.13.4
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: LGPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Some docs

                Compiled for 64 9.x
Change-log:     2018/01/03  First version 
Current:        2018/01/03 
' > $P-doc.tcz.info

echo 'Title:          libxfce4ui-dev.tcz
Description:    dev files for libxfce4ui
Version:        4.13.4
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: LGPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Development files

                Compiled for 64 9.x
Change-log:     2018/01/03  First version 
Current:        2018/01/03
' > $P-dev.tcz.info

echo 'Title:          libxfce4ui-locale.tcz
Description:    locales
Version:        4.13.4
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: LGPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       for non-english users untested

                Compiled for 64 9.x
Change-log:     2018/01/03  First version 
Current:        2018/01/03
' > $P-locale.tcz.info

submitqc --libs

# 
# in openbox command=xfce4-about GUI appears OK 
