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

P=recordmydesktop
V=0.4.0
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc alsa-dev libtheora-dev libvorbis-dev libXext-dev libXdamage-dev popt-dev"
for Z in $LIST 
    do 
    su -c "tce-load -i $Z" $USER
done

cd /tmp
/usr/local/bin/wget -nc --no-check-certificate \
https://github.com/Enselic/$P/releases/download/v$V/$SRC.tar.gz
tar xvf $SRC*gz
cd $SRC
./configure --prefix=/usr/local --enable-jack=no --enable-oss=no --with-x
# Audio driver that will be used: ALSA
# Compile with Jack support: Disabled

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;
make -j6  # seconds
make install-strip DESTDIR=/tmp/$P
cd /tmp

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

# main
######
mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v 2' > $P/usr/local/share/doc/$P/COPYING

# TCZ them
#######
LIST="$P $P-doc  "
for Z in $LIST
do
	mksquashfs $Z $Z.tcz
	md5sum $Z.tcz > $Z.tcz.md5.txt
	cd $Z
	find . -not -type d | cut -c 2- | sort > /tmp/$Z.tcz.list
	cd /tmp
done

ls -hal

echo 'Title:          recordmydesktop-doc.tcz
Description:    man page
Version:        0.4.0
Author:         John Varouhakis	(now inactive)
                Martin Nordholts (current)
Original-site:  https://github.com/Enselic/recordmydesktop
Copying-policy: GPL v 2
Size:           8.0K
Extension_by:   aus9 
Tags:           record screen 
Comments:       -
                
Change-log:     2024/12/15 v 0.4.0 on 15x
Current:        2026/01/31 rebuilt on 16x with updated alsa '  > $P-doc.tcz.info 
echo 'man-db.tcz' > $P-doc.tcz.dep

echo 'Title:          recordmydesktop.tcz
Description:    CLI screen and/or ALSA audio recorder
Version:        0.4.0
Author:         John Varouhakis	(now inactive)
                Martin Nordholts (current)
Original-site:  https://github.com/Enselic/recordmydesktop
Copying-policy: GPL v 2
Size:           44K
Extension_by:   aus9 
Tags:           record screen 
Comments:       Normal output is out.ogv which can be played back
                in vlc etc. As long as $ aplay <file.wav> works for you
                $ recordmydesktop
                To quit recording press Ctrl + c 
                Highly recommend you read man page in doc TCE

                If error "Could not open PCM device hw:0,0"
                $ recordmydesktop --device plughw:1,0 
                Or if using pulseaudio                 
                $ recordmydesktop --device pulse
                Pulseaudio members may also need alsa-plugins
                and setup libao YMMV not tested by me

                If mic capture is needed, please test mic first.
                see forum post=alsamixer mic activation tip with mini tutorial
                If you do not need sound then run the command with 
                --no-sound (this does reduce CPU usage)

                If error "Broken pipe: Overrun occurred"
                Try using a lower frequency eg 48Khz -> 40
                $ recordmydesktop --device plughw:1,0 --freq 40000
     
Change-log:     2014/01/19 v 0.3.8.1 on 9x (patham9)
                2024/12/15 v 0.4.0 on 15x
Current:        2026/01/31 rebuilt on 16x updated alsa(aus9) '  > $P.tcz.info
readelf -d $P/usr/local/bin/* | grep 'NEEDED'
#libSM.so.6]libSM
#libICE.so.6]libICE
#libasound.so.2]libasound
#libtheora.so.0]libtheora
#libogg.so.0]libogg libtheora
#libvorbisenc.so.2]libvorbisfile.so.3]#libvorbis.so.0]libvorbis
#libXdamage.so.1]libXdamage
#libXfixes.so.3]libXfixes libXdamage
#libXext.so.6]libXext
#libX11.so.6]libX11 libXext
#libpopt.so.0]popt
 
echo 'libSM.tcz
libICE.tcz 
libasound.tcz 
libtheora.tcz 
libvorbis.tcz 
libXdamage.tcz 
libXext.tcz 
popt.tcz ' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync

