# vim: ft=make ts=4 sw=4 noet
.DEFAULT_GOAL := all

NAME    = ncurses
VERSION = 6.5
GARTYPE = v2

MASTER_SITES = http://invisible-island.net/archives/ncurses/
DISTFILES   += $(DISTNAME).tar.gz

LICENSE = COPYING

PACKAGES                  += OZSWncurses
SPKG_DESC_OZSWncurses      = GNU ncurses terminal library
CATALOGNAME_OZSWncurses    = ncurses

# Keep static libs (many packages link ncurses statically)
MERGE_EXCLUDE_STATICLIBS =

EXTRA_CONFIGURE_ARGS += --with-shared
EXTRA_CONFIGURE_ARGS += --without-debug
EXTRA_CONFIGURE_ARGS += --enable-pc-files
EXTRA_CONFIGURE_ARGS += --with-pkg-config-libdir=$(libdir)/pkgconfig
# Wide-char support (libncursesw) — needed by modern readline/bash
EXTRA_CONFIGURE_ARGS += --enable-widec
# Avoid conflicting with Solaris /usr/lib/libcurses
EXTRA_CONFIGURE_ARGS += --without-ada
# Solaris: use unsigned for ospeed type
EXTRA_CONFIGURE_ARGS += --with-ospeed=unsigned

# Fix libtool ECHO="print -r --" (ksh93 builtin, fails under bash)
post-configure:
	@if [ -f $(WORKSRC)/libtool ]; then \
	    find $(WORKSRC) -name "libtool" -type f -exec \
	        gsed -i 's/ECHO="print -r --"/ECHO="printf %s\\n"/g' {} \; ; \
	fi
	@$(MAKECOOKIE)

# Create libncurses.so -> libncursesw.so symlinks so packages can link with
# -lncurses and get libncursesw transparently.  The system libcurses.so.1
# is intentionally NOT aliased here — it must remain accessible as-is.
post-install:
	cd $(DESTDIR)$(libdir) && \
	    for suffix in "" ".6" ".6.5"; do \
	        ln -sf libncursesw.so$$suffix libncurses.so$$suffix; \
	    done && \
	    ln -sf libpanelw.so libpanel.so && \
	    ln -sf libpanelw.so.6 libpanel.so.6
	@$(MAKECOOKIE)

include gar/category.mk
