#!/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 "

P=doxygen
V=1.8.14
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc cmake python "
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 \
ftp://ftp.stack.nl/pub/$P/$SRC.src.tar.gz  " $USER
tar xvf $SRC*gz
mkdir $P
cd $SRC
mkdir build
cd build
cmake -G "Unix Makefiles" ../
make install DESTDIR=/tmp/$P
# install-strip no work
cd /tmp

# no dev TCZ
##############

# main
#####
mkdir -p  $P/usr/local/share/doc/$P
echo 'see http://www.stack.nl/~dimitri/doxygen/ for license' >  $P/usr/local/share/doc/$P/COPYING
cd $P
find . | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
cd /tmp

# 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



echo 'Title:          doxygen.tcz
Description:    make docs from source code 
Version:        1.8.14
Author:         Dimitri van Heesch
Original-site:  http://www.stack.nl/~dimitri/doxygen/
Copying-policy: GPL v2
Size:		
Extension_by:   aus9 at gmx dot com
Tags:           documentation 
Comments:       Doxygen is the de facto standard tool for generating 
                documentation from annotated C++ sources

                compiled for 9x 
Change-log:     2018/07/08 first version 
Current:        2018/07/08 ' > $P.tcz.info

submitqc --libs
