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

# due to meson recreate missing la file
########################################
cat >> /usr/local/lib/libatk-1.0.la  <<'EOF'
# libatk-1.0.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-0.1
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libatk-1.0.so.0'

# Names of this library.
library_names='libatk-1.0.so.0.22810.1 libatk-1.0.so.0 libatk-1.0.so'

# The name of the static archive.
old_library=''

# Linker flags that cannot go in dependency_libs.
inherited_linker_flags=''

# Libraries that this one depends upon.
dependency_libs=' -L/usr/local/lib /usr/local/lib/libgobject-2.0.la /usr/local/lib/libffi.la /usr/local/lib/libglib-2.0.la /usr/local/lib/libpcre.la -lpthread'

# Names of additional weak libraries provided by this library
weak_library_names=''

# Version information for libatk-1.0.
current=22810
age=22810
revision=1

# Is this an already installed library?
installed=yes

# Should we warn about portability when linking against -modules?
shouldnotlink=no

# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''

# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
EOF

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

P=xfdesktop
V=4.12.4
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool libX11-dev glib2-dev gtk3-dev libwnck-2.30-dev \
libxfce4util-dev libxfce4ui-dev exo-dev libnotify-dev Thunar-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 \
http://archive.xfce.org/src/xfce/$P/4.12/$SRC.tar.bz2 " $USER
tar jxvf $P*bz2
cd $SRC
./configure --disable-debug --enable-thunarx 
#####################################
#    Build Configuration:

# Build desktop menu module:                    yes
# Build support for desktop icons:              yes
#     Include support for file/launcher icons:  yes
# Mount notification support:                   yes
#####################################################
make check
make install-strip DESTDIR=/tmp/$P
cd /tmp

# 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/man $P-doc/usr/local/share/
cp $SRC/AUTHORS $P-doc/usr/local/share/doc/$P
cp $SRC/COPYING $P-doc/usr/local/share/doc/$P

# dev
#####
# no devs

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

# tce.installed
##############
# gtk-update-icon-cache -f -t /usr/local/share/icons/hicolor
# not done this build as it has to be done for xfwm too

# TCZ them
#######
LIST="$P $P-doc $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 'man-db.tcz ' > $P-doc.tcz.dep

echo 'xfce4-session.tcz
libwnck-2.30.tcz
Thunar.tcz
xfce4-TC.tcz'  > $P.tcz.dep

echo 'Title:          xfdesktop.tcz  
Description:    xfce desktop manager
Version:        4.12.4
Author:         see doc for authors  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Xfdesktop sets the background image/color, 
                creates the right click menu and window list 
                and displays the file icons on the desktop 
                using Thunar libraries 

                The dependency xfce4-TC is needed as we need
                to use TC apps especially exittc.

                Compiled for 64 9.x
Change-log:     2018/04/22  First version 
Current:        2018/05/23 rebuilt for gtk3 issue ' > $P.tcz.info

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

                Compiled for 64 9.x
Change-log:     2018/04/22  First version 
Current:        2018/05/23 rebuilt for gtk3 issue  ' > $P-doc.tcz.info

echo 'Title:          xfdesktop-locale.tcz
Description:    locales
Version:        4.12.4
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL 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/04/22  First version 
Current:        2018/05/23 rebuilt for gtk3 issue ' > $P-locale.tcz.info

submitqc --libs
