tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Doing more with curses.buildlink3.mk
Please review the attached patch to curses.buildlink3.mk. The goal of
the patch is to allow a user to choose to use ncurses over whatever
curses is installed in the base system. This can be done by setting the
following in /etc/mk.conf:
CURSES_DEFAULT= ncurses
curses.buildlink3.mk should be included by packages that need *some*
curses implementation instead of a particular one.
Thanks,
-- Johnny C. Lam
Index: curses.buildlink3.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/curses.buildlink3.mk,v
retrieving revision 1.5
diff -u -r1.5 curses.buildlink3.mk
--- curses.buildlink3.mk 3 Nov 2007 15:17:42 -0000 1.5
+++ curses.buildlink3.mk 22 Feb 2008 16:42:04 -0000
@@ -1,24 +1,86 @@
# $NetBSD: curses.buildlink3.mk,v 1.5 2007/11/03 15:17:42 rillig 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, and "ncurses".
#
# 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.
#
+# === 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. Setting this to "ncurses" means that
+# we want to use ncurses instead of the system curses.
+#
+# Possible: curses, ncurses
+# Default: (depends)
+#
+# === Variables set by this file ===
+#
+# CURSES_TYPE
+# The name of the selected curses implementation.
+
+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 # ncursesw
+
+# 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 there is no curses implementation in the base system, then
+# use ncurses instead.
+#
.if !exists(/usr/include/curses.h) && \
!exists(/usr/include/ncurses.h)
-. include "../../devel/ncurses/buildlink3.mk"
+CURSES_DEFAULT?= ncurses
.else
+CURSES_DEFAULT?= curses # just use the system curses
+.endif
+
+_CURSES_ACCEPTED= # empty
+.if exists(/usr/include/curses.h) || exists(/usr/include/ncurses.h)
+_CURSES_ACCEPTED+= curses # system curses exists
+.endif
+_CURSES_ACCEPTED+= ncurses # pkgsrc ncurses
+#_CURSES_ACCEPTED+= ncursesw # pkgsrc ncursesw
-# 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
+.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"
+# Nothing to include here because we're using the system curses.
+.elif ${CURSES_TYPE} == "ncurses"
+USE_NCURSES= yes
+. include "../../devel/ncurses/buildlink3.mk"
+#.elif ${CURSES_TYPE} == "ncursesw"
+#USE_NCURSES= yes
+#. include "../../devel/ncursesw/buildlink3.mk"
.endif
Home |
Main Index |
Thread Index |
Old Index