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

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

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

P=xfce4-battery-plugin
V=1.1.2
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc intltool gtk3-dev libxfce4util-dev libxfce4ui-dev  \
xfce4-panel-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/panel-plugins/$P/1.1/$SRC.tar.bz2   " $USER 
mkdir $P
tar jxvf $SRC*2
cd $SRC
./configure --disable-debug --enable-static
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
cp $SRC/AUTHORS $P-doc/usr/local/share/doc/$P
cp $SRC/COPYING $P-doc/usr/local/share/doc/$P

# main
#####
rm -rf $P/usr/local/lib/xfce4/panel/plugins/*a

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

ls -hal

echo 'xfce4-battery-plugin.tcz' > $P-locale.tcz.dep

echo 'xfce4-panel.tcz 
libxfce4util.tcz 
libxfce4ui.tcz     ' > $P.tcz.dep

echo 'Title:          xfce4-battery-plugin.tcz  
Description:    battery plugin for Xfce
Version:        1.1.2
Author:         9 see doc/AUTHORS
Original-site:  xfce.org
Copying-policy: GPL v2
Size:           96K		
Extension_by:   aus9 at gmx dot com
Tags:           xfce battery plugin
Comments:       Runs on Xfce only for laptops.   For a RH mouse user,  
                RH click empty space on panel and click add new items. 
                Search for battery entry -select it click add button.
                Then RH click plugin and select properties to alter display options.

               Dark gtk3 themes and icon themes can affect colour outputs
               if you like colour changing plugin. If power (AC) indicator remains on
               when discharging, exit to prompt and startx to reset plugin please.
                
                Compiled for 10.x
Change-log:     2019/01/30  First version 
Current:        2019/01/30           ' > $P.tcz.info

echo 'Title:          xfce4-battery-plugin-locale.tcz
Description:    locales
Version:        1.1.2
Author:         9 see doc/AUTHORS 
Original-site:  xfce.org
Copying-policy: GPL v2
Size:           96K		
Extension_by:   aus9 at gmx dot com
Tags:           xfce locales
Comments:       for non-english users untested

                Compiled for 10.x
Change-log:     2019/01/30  First version 
Current:        2019/01/30' >  $P-locale.tcz.info

echo 'Title:          xfce4-battery-plugin-doc.tcz
Description:    docs
Version:        1.1.2
Author:         9 see doc/AUTHORS  
Original-site:  xfce.org
Copying-policy: GPL v2
Size:           12K		
Extension_by:   aus9 at gmx dot com
Tags:           xfce 
Comments:       no man pages

                Compiled for 10.x
Change-log:     2019/01/30  First version 
Current:        2019/01/30' >  $P-doc.tcz.info

submitqc --libs