#!/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=aqualung
V=1.2
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc gtk2-dev alsa-dev libcdio-paranoia-dev 
lame-dev  libsamplerate-dev  intltool libmad-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/jeremyevans/$P/releases/download/$V/$SRC.tar.gz   "  $USER
tar xvf $SRC*gz
cd $SRC

# src =sample rate converter (must have)

./configure --prefix=/usr/local --with-src --disable-systray --without-ladspa --without-ifp \
--without-lua --without-flac --without-speex --without-mod --without-mpc --without-mac \
 --without-wavpack --without-lavc --disable-rpath --without-sndio --without-oss --without-jack --without-pulse 
######################################
# LADSPA plugin support        : no
# CDDA (Audio CD) support      : yes (found)
# CDDB support                 : yes (found)
# Sample Rate Converter support: yes
# iRiver iFP driver support    : no
# JACK port management support : no
# Loop playback support        : yes
# Systray support              : no
# Podcast support              : yes
# Lua extension support        : no

#   Decoding support:
# sndfile (WAV, AIFF, AU, etc.)      : yes (found)
# Free Lossless Audio Codec (FLAC)   : no
# Ogg Vorbis                         : yes (found)
# Ogg Speex                          : no
# MPEG Audio (MPEG 1-2.5 Layer I-III): yes (found)
# MOD Audio (MOD, S3M, XM, IT, etc.) : no
# Musepack                           : no
# Monkey's Audio Codec               : no
# WavPack                            : no
# LAVC (AC3, AAC, WavPack, WMA, etc.): no

#   Encoding support:
# sndfile (WAV)                   : yes (found)
# Free Lossless Audio Codec (FLAC): no
# Ogg Vorbis                      : yes (found)
# LAME (MP3)                      : yes (found)

#   Output driver support:
# sndio Audio      : no
# OSS Audio        : no
# ALSA Audio       : yes (found)
# JACK Audio Server: no
# PulseAudio       : no
# Win32 Sound API  : not supported on linux-gnu
#######################################
make -j5  # 10s 
make install-strip DESTDIR=/tmp/$P
cd /tmp

# skins  keep dark in main
#####
SKIN=/tmp/$P-skin/usr/local/share/$P/skin
mkdir -p $SKIN
cd $P/usr/local/share/$P/skin
mv metal no_skin ocean plain woody $SKIN
cd /tmp

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

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

# main
#####
# they are of no use so
rm -rf $P/usr/local/share/doc
# no desktop was compiled make a basic one
mkdir -p $P/usr/local/share/pixmaps
cp $P/usr/local/share/aqualung/icon_48.png $P/usr/local/share/pixmaps/$P.png
APP=$P/usr/local/share/applications
mkdir -p $APP
echo '[Desktop Entry]
Name=aqualung
Exec=aqualung
Terminal=false
StartupNotify=true
Type=Application
Categories=Audio;Player
Icon=aqualung
X-FullPathIcon=/usr/local/share/pixmaps/aqualung.png'  > $APP/$P.desktop

mkdir -p $P/usr/local/share/doc/$P
echo 'GPL v2' > $P/usr/local/share/doc/$P/COPYING

# TCZ them
###########
LIST2="$P $P-doc $P-locale $P-skin "
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:          aqualung-doc.tcz
Description:    man page
Version:        1.2
Author:         Tom Szilagyi,Peter Szilagyi,Tomasz Maka,Jeremy Evans & Jamie Heilman 
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           8.0K         		
Extension_by:   aus9 @linuxquestions.org
Tags:           man
Comments:       man page some parts do not apply as
                some compiles have been disabled

Change-log:     2020/05/16 v 1.0 on 11x
Current:        2024/04/22 v 1.2 on 15x     ' > $P-doc.tcz.info
echo 'man-db.tcz                            ' > $P-doc.tcz.dep

echo 'Title:          aqualung-locale.tcz
Description:    locales 
Version:        1.2
Author:         Tom Szilagyi,Peter Szilagyi,Tomasz Maka,Jeremy Evans & Jamie Heilman
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           412K          		
Extension_by:   aus9 @linuxquestions.org 
Tags:           locale
Comments:       locales untested by me
                
Change-log:     2020/05/16 v 1.0 on 11x
Current:        2024/04/22 v 1.2 on 15x     ' > $P-locale.tcz.info
echo 'aqualung.tcz                          ' > $P-locale.tcz.dep

echo 'Title:          aqualung-skin.tcz
Description:    extra skins 
Version:        1.2
Author:         Tom Szilagyi,Peter Szilagyi,Tomasz Maka,Jeremy Evans & Jamie Heilman
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           216K          		
Extension_by:   aus9 @linuxquestions.org 
Tags:           theme
Comments:       extra skins for aqualung.
                 Can be loaded after aqualung is running.
                 for a Right Hand mouse user,
                 RH click somewhere in the GUI brings up menu 
                 -> click Skin Chooser
                -> select skin
                click apply.

Change-log:     2020/05/16 v 1.0 on 11x
Current:        2024/04/22 v 1.2 on 15x     ' > $P-skin.tcz.info
echo 'aqualung.tcz                          ' > $P-skin.tcz.dep

echo 'Title:          aqualung.tcz
Description:    gtk2 graphical audio media player/ripper 
Version:        1.2
Author:         Tom Szilagyi,Peter Szilagyi,Tomasz Maka,Jeremy Evans & Jamie Heilman
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2 
Size:           488K          		
Extension_by:   aus9 @linuxquestions.org  
Tags:           gtk2 audio player mp3 ogg wav
Comments:       Ensure sound works for Alsa as no pulseaudio built in.
                To keep size smallish, only wav, ogg and mp3 supported.

                Manual 
                http://aqualung.jeremyevans.net/manual/index.html

                There is about 5 second delay before play button works. YMMV
                If you try to add a file and it does not appear in your list,
                its not a format I have compiled support for.

                Click the MS or PL buttons  to toggle on/off the music 
                store or playlist.
                For a right hand mouse user, RH click nearly anyone in the GUI
                will bring up a control panel.
                You will probably want to adjust DSP -> sample rate converter

                There is a volume slider and a left-right channel slider at top.

                Optional dep of aqualung-skin.tcz for more skins

                To play audio disc, ensure MS button is on. 
                 -------CD Audio should appear in store.
                Double Left click it to add to your playlist.
                Click the playlist entry. click play to play entire cd.
                To play a specific track, click the button to the left of 
                cd-name and choose track then click play at top. 
                Or use the MS playlist menu to add a specific track 
                 to your playlist.

                You can not rip and play audio cd at same time.
                In case its not obvious....to rip try this
                After seeing audio cd-name in MS,
                RH click that name, select rip in context menu that opens
                You can now choose all or one track etc
                "Output Tab" choose output formats of wav,ogg or mp3
                 --if you choose ogg or mp3 Variable Bit Rates can be changed. 
                     
Change-log:     2020/05/16 v 1.0 on 11x
Current:        2024/04/22 v 1.2 on 15x    ' > $P.tcz.info
readelf -d $P/usr/local/bin/$P | grep 'NEEDED' 
#libxml2.so.2]libxml2
#libgtk-x11-2.0.so.0]libgdk-x11-2.0.so.0]gtk2
#libpangocairo-1.0.so.0]libpangoft2-1.0.so.0]libpango-1.0.so.0] pango -> gtk2
#libatk-1.0.so.0]at-spi2-core -> gtk2
#libcairo.so.2]cairo -> pango -> gtk2
#libgdk_pixbuf-2.0.so.0]gdk-pixbuf2 -> gtk2
#libgio-2.0.so.0]libgobject-2.0.so.0]libglib-2.0.so.0]libgthread-2.0.so.0] glib2 ->at-spi2-core -> gtk2
#libharfbuzz.so.0]harbuzz -> freetype
#libfontconfig.so.1]fontconfig -> cairo -> pango -> gtk2
#libfreetype.so.6]freetype -> fontconfig -> cairo -> pango -> gtk2
#libasound.so.2]libasound
#libmp3lame.so.0]lame
#libmad.so.0]libmad
#libsndfile.so.1]libsndfile -> libsamplerate
#libvorbis.so.0]libvorbisenc.so.2]libvorbisfile.so.3]libvorbis -> libsndfile -> libsamplerate
#libogg.so.0]libogg -> libvorbis -> libsndfile -> libsamplerate
#libsamplerate.so.0]libsamplerate
#libcdio_paranoia.so.2]libcdio_cdda.so.2]libcddb.so.2]libcdio-paranoia
#libcdio.so.18] libcdio -> libcdio-paranoia

echo 'libxml2.tcz
gtk2.tcz
libasound.tcz
lame.tcz
libmad.tcz
libsamplerate.tcz
libcdio-paranoia.tcz      ' > $P.tcz.dep

submitqc --libs
rm -rf *.zsync


