summaryrefslogtreecommitdiff
path: root/mk/curses.buildlink3.mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2008-02-25 04:19:34 +0000
committerjlam <jlam@pkgsrc.org>2008-02-25 04:19:34 +0000
commit6c632be06567f61a427880857cdfabb980db4dc7 (patch)
treeb1fc1d2628253083c17f00e031a6d5fd7f45b918 /mk/curses.buildlink3.mk
parent09275ef5bd6a438e0d35932db2eda57ef2ca5dc9 (diff)
downloadpkgsrc-6c632be06567f61a427880857cdfabb980db4dc7.tar.gz
+ Introduce a way for a user to set the default curses implementation
used by packages that need curses. From curses.buildlink3.mk: CURSES_DEFAULT This value represents the type of curses we wish to use on the system. Setting this to "curses" means that the system curses implementation is fine. Possible: curses, ncurses, pdcurses + Move all code to detect a built-in version of curses into a curses.builtin.mk file. + Add code to {n,pd}curses/buildlink3.mk so make the headers and libraries usable as <curses.h> and -lcurses if _PKG_USE_CURSES is defined. _PKG_USE_CURSES is only defined by curses.buildlink3.mk. + Improve the detection of native ncurses in ncurses/builtin.mk and allow headers and libraries to be usable as <ncurses.h> and -lncurses.
Diffstat (limited to 'mk/curses.buildlink3.mk')
-rw-r--r--mk/curses.buildlink3.mk104
1 files changed, 89 insertions, 15 deletions
diff --git a/mk/curses.buildlink3.mk b/mk/curses.buildlink3.mk
index e7e903b44c3..f733445e46a 100644
--- a/mk/curses.buildlink3.mk
+++ b/mk/curses.buildlink3.mk
@@ -1,24 +1,98 @@
-# $NetBSD: curses.buildlink3.mk,v 1.5 2007/11/03 15:17:42 rillig Exp $
+# $NetBSD: curses.buildlink3.mk,v 1.6 2008/02/25 04:19:34 jlam Exp $
#
-# This file should be included by Makefiles for packages that use curses.
-# It checks whether a native curses implementation is available, or
-# otherwise adds a dependency on ncurses.
+# This Makefile fragment is meant to be included by packages that require
+# any curses implementation instead of one particular one. The available
+# curses implementations are "curses" if built-in, "ncurses", and
+# "pdcurses".
#
-# If a package genuinely requires ncurses, then it should directly include
-# ncurses/buildlink3.mk instead of this file in the package Makefile and
-# additionally set USE_NCURSES=yes.
+# If a package genuinely requires ncurses or pdcurses, then it should
+# directly include the appropriate buildlink3.mk instead of this file in
+# the package Makefile.
#
+# === User-settable variables ===
+#
+# CURSES_DEFAULT
+# This value represents the type of curses we wish to use on the
+# system. Setting this to "curses" means that the system curses
+# implementation is fine.
+#
+# Possible: curses, ncurses, pdcurses
+# Default: (depends)
+#
+# === Variables set by this file ===
+#
+# CURSES_TYPE
+# The name of the selected curses implementation.
-.if !exists(/usr/include/curses.h) && \
- !exists(/usr/include/ncurses.h)
-. include "../../devel/ncurses/buildlink3.mk"
+CURSES_BUILDLINK3_MK:= ${CURSES_BUILDLINK3_MK}+
+
+.include "bsd.fast.prefs.mk"
+
+.if !empty(CURSES_BUILDLINK3_MK:M+)
+
+# _CURSES_PKGS is an exhaustive list of all of the curses implementations
+# that may be used with curses.buildlink3.mk.
+#
+_CURSES_PKGS?= curses ncurses pdcurses
+
+CHECK_BUILTIN.curses:= yes
+. include "curses.builtin.mk"
+CHECK_BUILTIN.curses:= no
+
+# Set the value of CURSES_DEFAULT depending on the platform and what's
+# available in the base system.
+#
+# - Interix has an unusual ncurses installation that is missing some
+# shared libraries, but the ncurses/builtin.mk will take care of things
+# for us.
+#
+.if ${OPSYS} == "Interix"
+CURSES_DEFAULT?= ncurses
+.endif
+.if defined(IS_BUILTIN.curses) && !empty(IS_BUILTIN.curses:M[yY][eE][sS])
+CURSES_DEFAULT?= curses
.else
+CURSES_DEFAULT?= ncurses
+.endif
+
+_CURSES_ACCEPTED= # empty
+.if defined(IS_BUILTIN.curses) && !empty(IS_BUILTIN.curses:M[yY][eE][sS])
+_CURSES_ACCEPTED+= curses # system curses exists
+.endif
+_CURSES_ACCEPTED+= ncurses # pkgsrc ncurses
+_CURSES_ACCEPTED+= pdcurses # pkgsrc pdcurses
-# XXX this is ugly, but needed to get the BUILDLINK_TRANSFORM from builtin.mk;
-# on Interix, libncurses is static yet libcurses (also ncurses) is shared
-. include "bsd.fast.prefs.mk"
-. if ${OPSYS} == "Interix"
-. include "../../devel/ncurses/buildlink3.mk"
+_CURSES_TYPE= ${CURSES_DEFAULT}
+. if !empty(_CURSES_ACCEPTED:M${_CURSES_TYPE})
+CURSES_TYPE= ${_CURSES_TYPE}
+. else
+CURSES_TYPE= none
. endif
+BUILD_DEFS+= CURSES_DEFAULT
+BUILD_DEFS_EFFECTS+= CURSES_TYPE
+
+# _PKG_USE_CURSES is a flag for use by the curses packages' buildlink3.mk
+# files to indicate that the headers and libraries should be usable as
+# <curses.h> and -lcurses.
+#
+_PKG_USE_CURSES= yes
+
+.endif # CURSES_BUILDLINK3_MK
+
+.if ${CURSES_TYPE} == "none"
+PKG_FAIL_REASON= \
+ "${_CURSES_TYPE} is not an acceptable curses type for ${PKGNAME}."
+.elif ${CURSES_TYPE} == "curses"
+BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ncurses}
+BUILDLINK_PACKAGES+= curses
+BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}curses
+BUILDLINK_BUILTIN_MK.curses= ../../mk/curses.builtin.mk
+.elif ${CURSES_TYPE} == "ncurses"
+USE_NCURSES= yes
+. include "../../devel/ncurses/buildlink3.mk"
+BUILDLINK_LDADD.curses?= ${BUILDLINK_LDADD.ncurses}
+.elif ${CURSES_TYPE} == "pdcurses"
+. include "../../devel/pdcurses/buildlink3.mk"
+BUILDLINK_LDADD.curses?= ${BUILDLINK_LDADD.pdcurses}
.endif