#|/usr/bin/cygport
# dialog.cygport - dialog Cygwin package build control script definitions

NAME=dialog
VERSION=1.3+20260721	# changed from date in release to date in version
RELEASE=1		# to better match i-i.net package versions with Cygwin

CATEGORY="Interpreters"
SUMMARY="Curses widget-based script interpreter"
DESCRIPTION="A script interpreter which provides a set of curses widgets,
whose appearance and behavior can be customized."

SITE=https://invisible-island.net
HOMEPAGE=$SITE/$NAME
MANPAGE=$HOMEPAGE/manpage
SRC_DIR=$NAME-${VERSION/+/-}
SRC_URI=mirror://invisibleisland/$NAME/$SRC_DIR.tgz
SRC_URI+=" $SRC_URI.asc "
SRC_URI+=$(echo $MANPAGE/dialog{,_lib}.{html,pdf,ps,txt})   # add docs
DOCS=$(echo dialog{,_lib}.{html,pdf,ps,txt})
PATCH_URI="
	20140112-libtool-install.patch
	dialog-rc.c-dlg_create_rc-fopen-w-no-t.patch
"

BUILD_REQUIRES="gettext-devel libintl-devel libncurses-devel
		groff make pkg-config"

KEEP_LA_FILES=none

CYGCONF_ARGS="
	 --enable-nls
	 --enable-widec
	   --with-libtool
	   --with-ncurses
	   --with-pkg-config
	   --with-shared
"
#	--disable-echo			do not display "compiling" commands
#	--disable-extras		do not include extra dialogs
#	--disable-form			do not include the form dialog
#	--disable-gauge			do not include the gauge dialogs
#	 --enable-header-subdir		install dlg_XXX headers to subdirectory
#	--disable-included-msgs		use included messages, for i18n support
#	--disable-largefile		omit support for large files
#	--disable-libtool-version	enable to use libtool's incompatible naming scheme
#	--disable-mixedform		do not include the mixedform dialog
#	--disable-mixedgauge		do not include the mixedgauge dialog
#	 --enable-nls			use Native Language Support
#	--disable-rc-file		do not include config-file support
#	--disable-rc-file2		do not use extra attributes in config-file
#	--disable-rpath-hack		don't add rpath options for additional libraries
#	 --enable-rpath			use rpath option when generating shared libraries
#	 --enable-stdnoreturn		enable C11 _Noreturn feature for diagnostics
#	--disable-tailbox		do not include the tailbox dialog
#	--disable-trace			do not support --trace option
#	 --enable-warnings		test: turn on gcc compiler warnings
#	--disable-whiptail		do not map extra whiptail options
#	 --enable-widec			enable wide-curses features
#	--disable-Xdialog		do not include Xdialog-style dialogs (1.1)
#	--disable-Xdialog2		do not include extra Xdialog-style dialogs (1.2)
#	   --with-abi-version=XXX	override derived ABI version
#	   --with-curses-5lib		compile/link with SunOS 5lib curses
#	   --with-curses-colr		compile/link with HPUX 10.x color-curses
#	   --with-curses-dir=DIR	directory in which (n)curses is installed
#	   --with-dbmalloc		test: use Conor Cahill's dbmalloc library
#	   --with-dmalloc		test: use Gray Watson's dmalloc library
#	   --with-export-syms=XXX	limit exported symbols using libtool
#	   --with-included-gettext	use the GNU gettext library included here
#	   --with-install-prefix=XXX	sets DESTDIR, useful for packaging
#	   --with-libiconv-prefix=DIR	search for libiconv in DIR/include and DIR/lib
#	   --with-libtool-opts=XXX	specify additional libtool options
#	   --with-libtool		generate libraries with libtool
#	   --with-man2html=XXX		use XXX rather than groff
#	   --with-ncurses		use ncurses-libraries
#	   --with-ncursesw		use wide ncurses-libraries
#	   --with-neXtaw		link with neXT Athena library
#	   --with-no-leaks		test: free permanent memory, analyze leaks
#	   --with-package=XXX		rename dialog to XXX, library to libXXX.a, etc
#	   --with-pdcurses		compile/link with pdcurses X11 library
#	   --with-pkg-config{=path}	enable/disable use of pkg-config
#	   --with-purify		test: use Purify
#	   --with-rel-version=XXX	override derived release version
#	   --with-screen=XXX		use specified curses-libraries
#	   --with-shared		generate shared-libraries
#	   --with-shlib-version=X	Specify rel or abi version for shared libs
#	   --with-textdomain=PKG	NLS text-domain (default is package name)
#	   --with-valgrind		test: use valgrind
#	   --with-versioned-syms=X	markup versioned symbols using ld
#	   --with-x			use the X Window System
#	   --with-Xaw3d			link with Xaw 3d library
#	   --with-Xaw3dxft		link with Xaw 3d xft library
#	   --with-XawPlus		link with Athena-Plus library

ABI=15

PKG_NAMES="lib${NAME}$ABI lib$NAME-devel $NAME"


declare libdialog${ABI}_SUMMARY="$SUMMARY library (runtime)"
declare libdialog${ABI}_CONTENTS="usr/bin/cygdialog-$ABI.dll"


libdialog_devel_SUMMARY="$SUMMARY library (development)"
libdialog_devel_REQUIRES="libncurses-devel"
libdialog_devel_CONTENTS="usr/bin/$NAME-config usr/include/ usr/lib/
usr/share/man/man3/ usr/share/doc/dialog/dialog_lib.*"


dialog_CONTENTS="--exclude=man3
		 --exclude=usr/share/doc/dialog/dialog_lib.*
		usr/bin/*.exe usr/share/"


src_compile() {
    AUTOCONF_VERSION=2.52
    cd $B
    cygconf --with-libtool-opts="-no-undefined -shared"
    cygmake LIBTOOL_OPTS="-no-undefined -shared"
}


src_install() {
    cd $B
    cyginstall

    # keep the samples executable as needed, but drop samples/install
    pushd $S
    dodir /usr/share/doc/$NAME
    tar -c --exclude=install samples | tar -x -C $D/usr/share/doc/$NAME
    popd
}


# fix 'make test' can't handle different $B and $S
src_test() {
    ln -fst $B/ $S/run_test.sh
    cd $B
    cygtest
}


LICENSE=LGPL-2.1-only
# SPDX-Licence-Identifier: LGPL-2.1-only
LICENSE_SPDX="SPDX-Licence-Identifier: $LICENSE"
LICENSE_URI="COPYING"

DOCS+=" $LICENSE_URI"

CYGWIN_MAINTAINER=Brian%20Inglis
CYGWIN_MAINTAINER_EMAIL=Brian.Inglis@SystematicSW.ab.ca

UPSTREAM_MAINTAINER=Thomas%20Dickey
UPSTREAM_MAINTAINER_EMAIL=dickey@$SITE

UPSTREAM_EMAIL=dickey@his.com

SUBJECT=${OSTYPE^}%20Package%20$NAME%20$VERSION
MAILTO=mailto:$UPSTREAM_MAINTAINER%20%3C$UPSTREAM_MAINTAINER_EMAIL%3E\
,$UPSTREAM_MAINTAINER%20%3C$UPSTREAM_EMAIL%3E\
?from=$CYGWIN_MAINTAINER%20%3C$CYGWIN_MAINTAINER_EMAIL%3E\
\&subject=$SUBJECT\&body=$SUBJECT

