# Contains the build infrastructural definitions for both
# mplayer and mencoder....the variables that we need to set
# before we include bsd.port.pre.mk

MPLAYER_PORT_VERSION=	1.5.0
MPLAYER_BASE_SNAPSHOT_DATE=	2025-08-16
MPLAYER_SNAPSHOT_DATE=	2026-04-04
MASTER_SITES=	LOCAL/riggs/mplayer
PATCH_SITES=	${MASTER_SITES}
PATCHFILES=	${DISTNAME}-${MPLAYER_SNAPSHOT_DATE:S/-//g}.patch.xz:-p1
DISTNAME=	mplayer-${MPLAYER_PORT_VERSION}.${MPLAYER_BASE_SNAPSHOT_DATE:S/-//g}
WRKSRC=		${WRKDIR}/mplayer-export-${MPLAYER_BASE_SNAPSHOT_DATE}

LICENSE=	GPLv2
LICENSE_FILE=	${WRKSRC}/LICENSE

LIB_DEPENDS=	libpng.so:graphics/png \
		libavcodec.so:multimedia/ffmpeg \
		libfreetype.so:print/freetype2

BUILD_DEPENDS=	${BUILD_DEPENDS_${ARCH}}
BUILD_DEPENDS_i386=	as:devel/binutils

USES=		compiler:c11 gmake iconv ncurses tar:xz
NOPRECIOUSMAKEVARS=	yes # ARCH
HAS_CONFIGURE=	yes
CONFIGURE_ENV+=	TMPDIR="${WRKSRC}"
CONFIGURE_ARGS=	--cc="${CC}" \
		--host-cc="${CC}" \
		--as="${AS}" \
		--mandir="${PREFIX}/share/man" \
		--extra-cflags="-I${PREFIX}/include -I${LOCALBASE}/include" \
		--extra-libs="-L${PREFIX}/lib" \
		--disable-alsa \
		--disable-ass-internal \
		--disable-bitmap-font \
		--disable-crystalhd \
		--disable-esd \
		--disable-faad \
		--disable-ffmpeg_a \
		--disable-ggi \
		--disable-ggiwmh \
		--disable-liba52 \
		--disable-libbs2b \
		--disable-libilbc \
		--disable-libnut \
		--disable-libvorbis \
		--disable-live \
		--disable-joystick \
		--disable-mad \
		--disable-libmpeg2 \
		--disable-nemesi \
		--disable-real \
		--yasm=''

common-post-patch:
	@${REINPLACE_CMD} \
		-e 's|/dev/dvd|${DEFAULT_DVD_DEVICE}|; \
		s|/dev/cdrom|${DEFAULT_CDROM_DEVICE}|' \
		-e 's|/usr/local|${LOCALBASE}|' \
		-e 's|%%LOCALBASE%%|${LOCALBASE}|' \
		-e 's|-lbz2|/usr/lib/libbz2.so|' \
		-e 's|-lncurses|/usr/lib/libncurses.so|' \
		-e 's|-liconv|${ICONV_LIB}|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
	@${REINPLACE_CMD} -E \
		-e 's|[[:space:]]gcc[-[:digit:]\.]+| ${CC}|' \
		-e 's|[[:space:]]gcc| ${CC}|' \
		-e 's|\$$\(CC\)|${CC}|' \
		-e 's|/usr/X11R6|${LOCALBASE}|' \
		-e 's|%%LOCALBASE%%|${LOCALBASE}|' \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT} \
		${CONFIGURE_WRKSRC}/Makefile
	@${FIND} ${WRKSRC}/DOCS/man -name "mplayer.1" | ${XARGS} ${REINPLACE_CMD} -E -e \
		's|/usr/\\:local/\\:etc/\\:mplayer|${DATADIR:S/\//\/\\\:/g}|g ; \
		 s|/dev/\\:(dvd[[:alnum:]]*[[:>:]])|${DEFAULT_DVD_DEVICE:S/dev\//dev\/\\\:/}|g ; \
		 s|/dev/\\:(cdrom[[:alnum:]]*[[:>:]])|${DEFAULT_CDROM_DEVICE:S/dev\//dev\/\\\:/}|g'
	@${RM} ${WRKSRC}/binary.ver
