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

P=audacious-plugins
V=4.5.1
SRC=$P-$V
USER=`cat /etc/sysconfig/tcuser`
LIST="compiletc submitqc audacious-dev curl-dev faad2-dev ffmpeg7-dev libnotify-dev libxml2-dev mpg123-dev neon-dev opusfile-dev pipewire-dev wavpack-dev
libcddb-dev libcdio-dev"
for Z in $LIST
    do 
    su -c "tce-load -i $Z" $USER
done

ls /usr/local/tce.installed/ | grep libav* | grep 4  # we want no  no av*4 have loaded 
ls /usr/local/tce.installed/ | grep libav* | grep 5  # we want no  no av*5 have loaded 

cd /tmp
su -c "/usr/local/bin/wget -nc --no-check-certificate \
https://distfiles.audacious-media-player.org/$SRC.tar.bz2   " $USER 
tar jxvf $SRC*bz2
cd $SRC
./configure --prefix=/usr/local --localstatedir=/var --disable-qt --disable-oss4 --disable-pipewire --enable-gtk2 --disable-console
  
# Install path:                           /usr/local/lib/audacious
# GTK+ support:                           yes
# Qt support:                             no
# Audio Formats
# Audio CD:                               yes
# Free Lossless Audio Codec:              yes
# Ogg Vorbis:                             yes
# Opus:                                   yes
# MIDI (via FluidSynth):                  no
# MPEG-1 Layer I/II/III (via mpg123):     yes
# MPEG-2/4 AAC:                           yes
# WavPack:                                yes
# External Decoders
# FFmpeg:                                 yes
# libsndfile:                             yes
# Chiptunes
# AdLib synthesizer (adplug):             no
# Commodore 64 audio (sid):               no
# Game Music Emu (spc, nsf, gbs, etc.):   no
# ModPlug:                                no
# OpenMPT:                                no
# Nintendo DS audio (xsf):                yes
# PlayStation audio (psf/psf2):           yes
# Vortex Tracker (vtx):                   yes
# Other Inputs
# Metronome:                              yes
# Tone Generator:                         yes
# Effects
# Bauer stereophonic-to-binaural (bs2b):  no
# Bitcrusher:                             yes
# Channel Mixer:                          yes
# Crystalizer:                            yes
# Dynamic Range Compressor:               yes
# Echo/Surround:                          yes
# Extra Stereo:                           yes
# LADSPA Host (requires GTK+):            yes
# Sample Rate Converter:                  no
# Silence Removal:                        yes
# SoX Resampler:                          no
# Speed and Pitch:                        no
# Voice Removal:                          yes
# Outputs
# Advanced Linux Sound Architecture:      yes
# Jack Audio Connection Kit:              no
# Open Sound System:                      no
# PipeWire:                               no
# PulseAudio:                             yes
# Simple DirectMedia Layer:               yes
# Sndio:                                  no
# Win32 waveOut:                          no
# FileWriter:                             yes
# MP3 encoding:                           yes
# Vorbis encoding:                        yes
# FLAC encoding:                          yes
# Playlists
# Cue sheets:                             no
# M3U playlists:                          yes
# Microsoft ASX (legacy):                 yes
# Microsoft ASX 3.0:                      yes
# PLS playlists:                          yes
# XML Sharable Playlist Format (XSPF):    yes
# Transports
# FTP, SFTP, SMB (via GIO):               yes
# HTTP/HTTPS (via neon):                  yes
# MMS (via libmms):                       no
# General
# Ampache browser (requires Qt):          no
# Delete Files:                           yes
# libnotify OSD:                          yes
# Linux Infrared Remote Control (LIRC):   no
# MPRIS 2 Server:                         yes
# Scrobbler 2.0:                          yes
# Song Change:                            yes
# GTK+ Support                          
# GTK Interface:                          yes
# Winamp Classic Interface:               yes
# Album Art:                              yes
# Blur Scope:                             yes
# OpenGL Spectrum Analyzer:               yes
# Playlist Manager:                       yes
# Search Tool:                            yes
# Spectrum Analyzer (2D):                 yes
# Status Icon:                            yes
# X11 Global Hotkeys:                     yes
# X11 On-Screen Display (aosd):           yes

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

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

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

DIR=/tmp/$P/usr/local/lib/audacious
LIST2="Container Effect General Input Output Transport Visualization"
for Z in $LIST2
do
	cd $DIR/$Z
        strip --strip-unneeded *
done
cd /tmp

# TCZ them
#######
LIST="$P $P-locale "
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:          audacious-plugins-locale.tcz
Description:    language files
Version:        4.5.1
Author:         plugin framework = audacious developers
                specific plugins  see below      
Original-site:  https://distfiles.audacious-plugins-media-player.org/
Copying-policy: accompanied
Size:           1.6M                      
Extension_by:   aus9 @linuxquestions.org
Tags:           audio player 
Comments:       UPGRADE WARNING audacious-locale is now a dep of this TCE
                If audacious-locale was in your boot list change it to 
                audacious-plugins-locale.tcz

                plugin authors are not easy to find.
                Instead they are named in the *.h or *.cc files found here
                https://github.com/audacious-media-player/audacious-plugins/tree/master/src
                eg https://github.com/audacious-media-player/audacious-plugins/blob/master/src/alsa/alsa.cc
                
Change-log:     2024/05/30 v 4.3.1 on 15x
                2024/05/30 v 4.3.1 on 15x (aus9)
Current:        2025/11/16 v 4.5.1 on 16x ' > $P-locale.tcz.info
echo 'audacious-plugins.tcz
audacious-locale.tcz' > $P-locale.tcz.dep

echo 'Title:          audacious-plugins.tcz
Description:    plugins for audacious
Version:        4.5.1
Author:         plugin framework = audacious developers
                specific plugins  see locale TCE info        
Original-site:  https://distfiles.audacious-plugins-media-player.org/
Copying-policy: accompanied
Size:           972K                  
Extension_by:   aus9 @linuxquestions.org
Tags:           audio player 
Comments:       UPGRADE WARNING, audacious is now a dep of this TCE
                If audacious was in your boot list change it to 
                audacious-plugins.tcz

                Local files test ok were aac,flac,m4a, mp3,oga (ogg), wav & wma 
                Please read info for audacious for main uses including streaming
                
Change-log:     2014/02/11 v 3.4.3 (Juanito)
                2016/02/07 v 3.7.1
                2019/04/19 v 3.9
                2024/05/30 v 4.3.1 on 15x (aus9)
Current:        2025/11/16 v 4.5.1 on 16x  ' > $P.tcz.info

touch /tmp/dep-list
DIR=/tmp/$P/usr/local/lib/audacious
LIST2="Container Effect General Input Output Transport Visualization"
for Z in $LIST2
do
	cd $DIR/$Z
        readelf -d *.so | grep 'NEEDED' >> /tmp/dep-list
        cd /tmp
done
# there were 539 outputs to above, a new record !!
# libavdevice7 AV=libavdevice7.tcz checked Apps gui for AV

#libaudcore.so.5]libaudgui.so.5]libaudtag.so.3] audacious 
#libxml2.so.2]libxml2  
#libglib-2.0.so.0]libgio-2.0.so.0]libgobject-2.0.so.0]libgmodule-2.0.so.0]glib2 audacious
#libpangocairo-1.0.so.0]libpango-1.0.so.0]libpangoft2-1.0.so.0]pango audacious 
#libharfbuzz.so.0]harfbuzz audacious  
#libatk-1.0.so.0]at-spi2-core  audacious
#libcairo-gobject.so.2]libcairo.so.2]cairo audacious
#libgdk_pixbuf-2.0.so.0]gdk-pixbuf2 audacious
#libXrender.so.1]libXrender audacious
#libX11.so.6]libX11  pango audacious
#libXcomposite.so.1]libXcomposite audacious
#libnotify.so.4]libnotify  make optional as per Juanito
#libcurl.so.4]          curl ditto
#libfaad.so.2]          faad ditto
#libcdio_cdda.so.2] libcdio-paranoia = found with  AV
#libcdio.so.18]libcdio.tcz  libcdio-paranoia-    AV
#libcddb.so.2] libcddb.tcz    AV
#libavcodec.so.59]libavcodec7 = AV....assume Juanito happy avdevice5=   AV 
#libavformat.so.59]libavformat7 AV
#libavutil.so.57]libavutil7 AV
#libFLAC.so.8]flac  libsndfile   AV
#libmpg123.so.0] mpg123 
#libopus.so.0]opus AV
#libopusfile.so.0]opusfile 
#libsndfile.so.1]libsndfile  AV
#libogg.so.0]libogg AV
#libvorbis.so.0]libvorbisenc.so.2]libvorbisfile.so.3]libvorbis AV
#libwavpack.so.1] wavpack....built in not Juanito way  
#libasound.so.2]libasound     AV
#libmp3lame.so.0]lame  libavcodec7 AV  
#libpulse.so.0]libpulseaudio AV
#libSDL2-2.0.so.0]sdl2 AV
#libneon.so.27]  neon leave out as per Juanito
#libGL.so.1]libGL   AV
#[libfontconfig.so.1]fontconfig  audacious
#[libfreetype.so.6]freetype      audacious

# submitqc finds json-glib but the optional deps

echo 'json-glib.tcz
audacious.tcz
libavdevice7.tcz
libnotify.tcz ' > $P.tcz.dep

submitqc --libs 
rm -rf *.zsync

