#!/bin/bash
# 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 CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti "
 
P=menumaker
V=0.99.14
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc python3.6  "
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://sourceforge.net/projects/menumaker/files/$SRC.tar.gz  " $USER
tar xvf $SRC*gz
cd $SRC
./configure --prefix=/usr/local
make -j5 # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# python complains if I remove debian 
######
rm -rf $P/usr/local/share/info

# main add 
######
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/COPYING  $P/usr/local/share/doc/$P/

# TCZ them
#######
LIST="$P "
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 'Title:          menumaker.tcz 
Description:    menu generator for some desktops
Version:        0.99.14
Author:         Oleg A. Khlybov, Steve Fullenwider & David Niklas 
Original-site:  https://menumaker.sourceforge.net/
Copying-policy: accompanied
Size:           148K
Extension_by:   aus9 
Tags:           menu
Comments:       for JWM, IceWM, OpenBox, FluxBox & WindowMaker    
                  
                Due to desktop syntax errors please run first
                $ mmaker -h # as some desktops have variants
                You may lack icons in menus, a known issue
                for icewm
                $ mmaker -f -s GNOME,Xfce -v IceWM
                                
                Repeat your command if you load more TCEs 
                Consider a ~/.local/bin/command for it eg
                $ echo '#!/bin/sh
tce-load -i menumaker               
mmaker -f -s GNOME,Xfce -v IceWM' > ~/.local/bin/menumaker
                $ chmod 755 ~/.local/bin/menumaker
                
Change-log:     2023/03/18 Original 0.99.14 on 14x uses python3.6 
Current:        2023/03/18 ' > $P.tcz.info  

echo 'python3.6.tcz' > $P.tcz.dep

submitqc --libs
