PORTNAME=	sdl2_mixer
DISTVERSIONPREFIX=	release-
DISTVERSION=	2.8.2
CATEGORIES=	audio

MAINTAINER=	amdmi3@FreeBSD.org
COMMENT=	Sample multi-channel audio mixer library
WWW=		https://github.com/libsdl-org/SDL_mixer

LICENSE=	ZLIB
LICENSE_FILE=	${WRKSRC}/LICENSE.txt

USES=		cmake sdl pkgconfig
USE_GITHUB=	yes
GH_ACCOUNT=	libsdl-org
GH_PROJECT=	SDL_mixer
USE_SDL=	sdl2
CMAKE_OFF=	SDL2MIXER_DEPS_SHARED \
		SDL2MIXER_FLAC_DRFLAC \
		SDL2MIXER_GME_SHARED \
		SDL2MIXER_MIDI_TIMIDITY \
		SDL2MIXER_MOD_XMP_LITE \
		SDL2MIXER_MP3_MINIMP3 \
		SDL2MIXER_SAMPLES
CMAKE_ARGS=	-DSDL2MIXER_DEBUG_POSTFIX:STRING=
USE_LDCONFIG=	yes

PLIST_SUB=	LIBVERSION=0.${DISTVERSION:R:E}00.${DISTVERSION:E}

OPTIONS_DEFINE=		FLAC FLUIDSYNTH GME MPG123 OPUS VORBIS WAVPACK
OPTIONS_RADIO=		MOD
OPTIONS_RADIO_MOD=	MODPLUG XMP
OPTIONS_DEFAULT=	FLUIDSYNTH MPG123 OPUS VORBIS XMP

GME_DESC=		GME music support via game-music-emu
MOD_DESC=		Tracker music support
XMP_DESC=		MOD music support via libxmp

FLAC_LIB_DEPENDS=	libFLAC.so:audio/flac
FLAC_CMAKE_BOOL=	SDL2MIXER_FLAC SDL2MIXER_FLAC_LIBFLAC

FLUIDSYNTH_LIB_DEPENDS=	libfluidsynth.so:audio/fluidsynth
FLUIDSYNTH_CMAKE_BOOL=	SDL2MIXER_MIDI SDL2MIXER_MIDI_FLUIDSYNTH
# TODO: add timidity?

GME_LIB_DEPENDS=	libgme.so:audio/libgme
GME_CMAKE_BOOL=		SDL2MIXER_GME

MODPLUG_LIB_DEPENDS=	libmodplug.so:audio/libmodplug
MODPLUG_CMAKE_BOOL=	SDL2MIXER_MOD_MODPLUG

MPG123_LIB_DEPENDS=	libmpg123.so:audio/mpg123
MPG123_CMAKE_BOOL=	SDL2MIXER_MP3 SDL2MIXER_MP3_MPG123

OPUS_LIB_DEPENDS=	libopusfile.so:audio/opusfile
OPUS_CMAKE_BOOL=	SDL2MIXER_OPUS

VORBIS_LIB_DEPENDS=	libvorbisfile.so:audio/libvorbis
VORBIS_CMAKE_OFF=	-DSDL2MIXER_VORBIS=""
VORBIS_CMAKE_ON=	-DSDL2MIXER_VORBIS="VORBISFILE"

WAVPACK_LIB_DEPENDS=	libwavpack.so:audio/wavpack
WAVPACK_CMAKE_BOOL=	SDL2MIXER_WAVPACK

XMP_LIB_DEPENDS=	libxmp.so:audio/libxmp
XMP_CMAKE_BOOL=		SDL2MIXER_MOD_XMP

.include <bsd.port.options.mk>

.if !${PORT_OPTIONS:MXMP} && !${PORT_OPTIONS:MMODPLUG}
CMAKE_OFF+=		SDL2MIXER_MOD
.endif

.include <bsd.port.mk>
