#!/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 CXXFLAGS="-mtune=generic -Os -pipe"
export LDFLAGS="-Wl,-O1"

P=aqualung
V=1.0
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 \
http://downloads.sourceforge.net/$P/$P-$V.tar.gz"  $USER
tar xvf $P*gz
mkdir $P
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  # takes seconds 
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/AUTHORS $P-doc/usr/local/share/doc/$P/
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

# 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.0
Author:         Tom Szilagyi
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           16K         		
Extension_by:   aus9 
Tags:           sound
Comments:       man page some parts do not apply as
                some compiles have been disabled

Change-log:     2020/05/16 first version 1.0 on 11x
Current:        2020/05/16
 ' > $P-doc.tcz.info

echo 'Title:          aqualung-locale.tcz
Description:    locales 
Version:        1.0
Author:         Tom Szilagyi
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           416K          		
Extension_by:   aus9 
Tags:           locale
Comments:       locales untested by me
                compile did not create a locale desktop

Change-log:     2020/05/16 first version 1.0 on 11x
Current:        2020/05/16
  ' > $P-locale.tcz.info

echo 'Title:          aqualung-skin.tcz
Description:    extra skins 
Version:        1.0
Author:         Tom Szilagyi
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2
Size:           216K          		
Extension_by:   aus9 
Tags:           skins 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 first version 1.0 on 11x
Current:        2020/05/16
  ' > $P-skin.tcz.info

echo 'Title:          aqualung.tcz
Description:    gtk2 graphical audio media player/ripper 
Version:        1.0
Author:         Tom Szilagyi
Original-site:  http://aqualung.jeremyevans.net/
Copying-policy: GPL v2 
Size:           496K          		
Extension_by:   aus9  
Tags:           gtk2 audio player
Comments:       Ensure sound works for Alsa as no pulseaudio built in.
                To keep size smallish, only wav, ogg and mp3 supported.

                Manual 
                https://aqualung.jeremyevans.net/manual/aqualung-doc.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 first version 1.0 on 11x
Current:        2020/05/16  
' > $P.tcz.info

echo 'man-db.tcz' > $P-doc.tcz.dep
echo 'aqualung.tcz' > $P-skin.tcz.dep
echo 'aqualung.tcz' > $P-locale.tcz.dep
echo 'gtk2.tcz
lame.tcz
libsamplerate.tcz
libcdio-paranoia.tcz
libmad.tcz ' > $P.tcz.dep

submitqc --libs
