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

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

L=libwnck
P=libwnck-2.30
V=2.30.7
SRC=$L-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool gtk2-dev startup-notification-dev libXres-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://ftp.gnome.org/pub/gnome/sources/$L/2.30/$SRC.tar.xz" $USER
mkdir $P
xz -d $L*xz && tar xvf $L*tar
cd $SRC
./configure --enable-introspection=no
# libwnck 2.30.7 ###################################################################
# prefix:                       /usr/local
# exec_prefix:                  ${prefix}
# libdir:                       ${exec_prefix}/lib
# bindir:                       ${exec_prefix}/bin
# sbindir:                      ${exec_prefix}/sbin
# sysconfdir:                   ${prefix}/etc
# localstatedir:                ${prefix}/var
# datadir:                      ${datarootdir}
# source code location:         .
# compiler:                     gcc
# cflags:                       -mtune=generic -Os -pipe -Wall
# Maintainer mode:              no
# Use *_DISABLE_DEPRECATED:     no
# Startup notification support: yes
# XRes support:                 yes
# Build introspection support:  no (disabled, use --enable-introspection to enable)
# Build gtk-doc documentation:  no
###################################################################################
make check
make install-strip DESTDIR=/tmp/$P

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

# doc...there is no libwnck doc  
#####
mkdir -p $P-doc/usr/local/share/doc/$P
cp $SRC/AUTHORS $P-doc/usr/local/share/doc/$P
cp $SRC/COPYING $P-doc/usr/local/share/doc/$P
mv $P/usr/local/share/gtk-doc $P-doc/usr/local/share/

# 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 

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

# 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 'libwnck-2.30.tcz
intltool.tcz
gtk2-dev.tcz
startup-notification-dev.tcz 
libXres-dev.tcz' > $P-dev.tcz.dep


echo 'Title:          libwnck-2.30.tcz  
Description:    windows navigation construction kit
Version:        2.30.7
Author:         see doc for authors  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Used to compile xfdesktop while it still 
                looks for an older libwnck than our 
                repo.                   
 
                Compiled for 64 9.x
Change-log:     2018/04/22  First version 
Current:        2018/04/22 ' > $P.tcz.info

echo 'Title:          libwnck-2.30-doc.tcz
Description:    docs
Version:        2.30.7
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/04/22 ' > $P-doc.tcz.info

echo 'Title:          libwnck-2.30-dev.tcz
Description:    dev files for xfce4-panel
Version:        2.30.7
Author:         see doc for authors 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       Development files

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


echo 'Title:          libwnck-2.30-locale.tcz
Description:    locales
Version:        2.30.7
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/04/22 ' > $P-locale.tcz.info

submitqc --libs