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

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

P=libfm-extra
V=1.3.1
SRC=libfm-$V
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc intltool glib2-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 \
https://downloads.sourceforge.net/pcmanfm/$SRC.tar.xz   "  $USER
mkdir $P
xz -d libfm*xz && tar xvf libfm*tar
cd $SRC
./configure  --disable-static --disable-nls --disable-exif --sysconfdir=/etc --with-extra-only 
##################################
# prefix:            /usr/local
# sysconfdir:   /etc
# Enable compiler flags and other support for debugging:  no
# Build udisks support (Linux only, experimental):              no
# Build with libexif for faster thumbnail loading:                   no
# Build demo program src/demo/libfm-demo:                     no
# Build with custom actions support (requires Vala):         no
# Large file support:                                                              yes
# GIO module for preferred apps (for glib < 2.28 only):     not required
# Build libfm-gtk for Gtk+ version:                                          none
# Build API doc with gtk-doc (recommended for make dist): no
####################################################   takes seconds below
make check
make install-strip DESTDIR=/tmp/$P
cd /tmp

# ignores --enable-static=no and disable-static
rm -rf $P/usr/local/include/libfm
chmod 644 $P/usr/local/lib/*a

# tce.install
#############
mkdir -p $P/usr/local/tce.installed
cat >> $P/usr/local/tce.installed/$P <<'EOF'
#!/bin/sh
INC=/usr/local/include
LOOP=/tmp/tcloop/libfm-extra$INC/libfm-1.0 
[  -d $INC/libfm ] || ln -s $LOOP $INC/libfm
EOF
chown -R tc:staff $P/usr/local/tce.installed
chmod -R 755 $P/usr/local/tce.installed

# 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 'intltool.tcz 
glib2-dev.tcz      '> $P.tcz.dep

echo 'Title:          libfm-extra.tcz
Description:    building dep for menu-cache only 
Version:        1.3.1
Author:         https://github.com/lxde/libfm/blob/master/AUTHORS
Original-site:  https://downloads.sourceforge.net/pcmanfm
Copying-policy: GPL v2
Size:           16K          		
Extension_by:   aus9
Tags:           none      
Comments:       Building dep for menu-cache. 
                No need to download this unless you are
                re-compiling please
                
                compiled for 10x
Change-log:     2019/02/11 first version
Current:        2019/02/11  ' > $P.tcz.info

submitqc --libs
