PORTNAME=	nll
PORTVERSION=	20260317a
CATEGORIES=	lang
MASTER_SITES=	https://kozos.jp/nlux/archive/
DISTNAME=	nlux-alpha-${PORTVERSION:C|[a-zA-Z]*$||}

MAINTAINER=	kozos@kozos.jp
COMMENT=	Simple language for programming learning
WWW=		https://kozos.jp/nll/

LICENSE=	ZLIB
LICENSE_FILE=	${WRKSRC}/LICENSE

FLAVORS=		sdl2 nosdl sdl1
FLAVOR?=		${FLAVORS:[1]}
nosdl_PKGNAMESUFFIX=	-nosdl
sdl1_PKGNAMESUFFIX=	-sdl1

USES=		zip
MAKE_ARGS=	ARCH= \
		BUILD= \
		CCOMPILER=${CC}

.if ${FLAVOR} == sdl2
COMMENT+=	(SDL 2)
USES+=		sdl xorg
USE_SDL=	sdl2
USE_XORG=	x11
MAKE_ARGS+=	SDLDIR=${LOCALBASE} \
		USE_SDL1= \
		USE_SDL2=yes
.elif ${FLAVOR} == nosdl
COMMENT+=	(limited graphic and audio function)
MAKE_ARGS+=	USE_SDL1= \
		USE_SDL2=
.elif ${FLAVOR} == sdl1
COMMENT+=	(SDL 1.2)
USES+=		sdl xorg
USE_SDL=	sdl
USE_XORG=	x11
MAKE_ARGS+=	SDLDIR=${LOCALBASE} \
		USE_SDL1=yes \
		USE_SDL2=
.endif

WRKSRC=		${WRKDIR}/nlux/${PORTNAME}

PLIST_FILES=	bin/${PORTNAME} \
		share/man/man1/${PORTNAME}.1.gz

PORTDOCS=	AUDIO.txt README.txt
PORTEXAMPLES=	*.nll

OPTIONS_DEFINE=		DOCS EXAMPLES NCURSES NETWORK SYSCALL SYSTEM
OPTIONS_DEFAULT?=	LIBEDIT NCURSES SYSTEM

OPTIONS_RADIO=		LINEEDIT
OPTIONS_RADIO_LINEEDIT=	FGETS GETLINE LIBEDIT NLLINE READLINE

FGETS_DESC=	Use fgets()
GETLINE_DESC=	Use getline
LINEEDIT_DESC=	Line editor
NETWORK_DESC=	Network support
NLLINE_DESC=	Internal readline compatible library
SYSCALL_DESC=	System call function support
SYSTEM_DESC=	System function support

FGETS_MAKE_ARGS=	READLINE=fgets
GETLINE_MAKE_ARGS=	READLINE=getline
LIBEDIT_USES=		libedit
LIBEDIT_MAKE_ARGS=	READLINE=libedit \
			READLINEDIR=${LOCALBASE}
NCURSES_USES=		ncurses
NCURSES_MAKE_ARGS=	USE_CURSES=yes
NCURSES_MAKE_ARGS_OFF=	USE_CURSES=
NETWORK_MAKE_ARGS=	USE_NETWORK_FUNCTION=yes
NETWORK_MAKE_ARGS_OFF=	USE_NETWORK_FUNCTION=
NLLINE_MAKE_ARGS=	READLINE=nlline
READLINE_USES=		readline
READLINE_MAKE_ARGS=	READLINE=readline \
			READLINEDIR=${LOCALBASE}
SYSCALL_MAKE_ARGS=	USE_SYSCALL_FUNCTION=yes
SYSCALL_MAKE_ARGS_OFF=	USE_SYSCALL_FUNCTION=
SYSTEM_MAKE_ARGS=	USE_SYSTEM_FUNCTION=yes
SYSTEM_MAKE_ARGS_OFF=	USE_SYSTEM_FUNCTION=

post-install:
	${INSTALL_PROGRAM} ${WRKDIR}/nlux/bin/${PORTNAME} \
		${STAGEDIR}${PREFIX}/bin
	${INSTALL_MAN} ${WRKDIR}/nlux/man/man1/${PORTNAME}.1 \
		${STAGEDIR}${PREFIX}/share/man/man1

post-install-DOCS-on:
	${MKDIR} ${STAGEDIR}${DOCSDIR}
	${INSTALL_DATA} ${PORTDOCS:S|^|${WRKSRC}/|} ${STAGEDIR}${DOCSDIR}

post-install-EXAMPLES-on:
	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
	${INSTALL_DATA} ${PORTEXAMPLES:S|^|${WRKSRC}/samples/|} \
			${PORTEXAMPLES:S|^|${WRKSRC}/samples/graphic/|} \
			${PORTEXAMPLES:S|^|${WRKSRC}/samples/audio/|} \
			${PORTEXAMPLES:S|^|${WRKSRC}/samples/network/|} \
		${STAGEDIR}${EXAMPLESDIR}

.include <bsd.port.mk>
