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

export CFLAGS="-mtune=generic -Os -pipe"
export CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti"


P=fdkaac
V=1.0.6
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`

LIST="compiletc submitqc automake fdk-aac-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://github.com/nu774/$P/archive/refs/tags/v$V.tar.gz"  $USER
tar xvf v$V*.gz
cd $SRC
autoreconf -i
./configure --prefix=/usr/local
make -j4  # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

# doc
##########
mkdir -p $P-doc/usr/local/
mv  $P/usr/local/share $P-doc/usr/local/

# main
######
mkdir -p $P/usr/local/share/doc/$P
cp $SRC/COPYING $P/usr/local/share/doc/$P

# TCZ them
###########
LIST2="$P $P-doc "
for Z in $LIST2
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:          fdkaac-doc.tcz
Description:    man page only
Version:        1.0.6
Author:         multiple see COPYING
Original-site:  https://github.com/nu774/fdkaac
Copying-policy: see COPYING
Size:           4.0K          		
Extension_by:   aus9 @ linuxquestions.org
Tags:           aac audio
Comments:       man page

Change-log:     2020/05/11 v 1.0.0 on 11x
Current:        2024/06/22 v 1.0.6 on 15x  ' > $P-doc.tcz.info
echo 'man-db.tcz' > $P-doc.tcz.dep

echo 'Title:          fdkaac.tcz
Description:    command line frontend libfdk-aac encoder    
Version:        1.0.6
Author:         multiple see COPYING
Original-site:  https://github.com/nu774/fdkaac
Copying-policy: see COPYING
Size:           36K         		
Extension_by:   aus9 @ linuxquestions.org 
Tags:           aac audio
Comments:       reads linear PCM audio in either WAV, raw PCM, or CAF format,
                and encodes it into either M4A / AAC file 
                Please read man page for heaps of parameters but
                $ fdkaac -p5 -b64 wav.wav -o test.m4a
                where wav.wav is the input file and output will be test.m4a       
                
Change-log:     2020/05/11 v 1.0.0 on 11x
Current:        2024/06/22 v 1.0.6 on 15x  ' > $P.tcz.info
readelf -d $P/usr/local/bin/$P | grep 'NEEDED'
# [libfdk-aac.so.1] fdk-aac
echo ' fdk-aac.tcz' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync


