diff options
author | jlam <jlam> | 2008-02-25 04:19:34 +0000 |
---|---|---|
committer | jlam <jlam> | 2008-02-25 04:19:34 +0000 |
commit | 30d895127dd585ce1fc8c7a9e04b1e67cacbffb1 (patch) | |
tree | b1fc1d2628253083c17f00e031a6d5fd7f45b918 /mk | |
parent | 83d75cade2be91a4c1707e6aea1129ae47123669 (diff) | |
download | pkgsrc-30d895127dd585ce1fc8c7a9e04b1e67cacbffb1.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')
-rw-r--r-- | mk/curses.buildlink3.mk | 104 | ||||
-rw-r--r-- | mk/curses.builtin.mk | 71 |
2 files changed, 160 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 diff --git a/mk/curses.builtin.mk b/mk/curses.builtin.mk new file mode 100644 index 00000000000..4b4fc2ff9c1 --- /dev/null +++ b/mk/curses.builtin.mk @@ -0,0 +1,71 @@ +# $NetBSD: curses.builtin.mk,v 1.1 2008/02/25 04:19:34 jlam Exp $ + +BUILTIN_PKG:= curses + +BUILTIN_FIND_LIBS:= curses +BUILTIN_FIND_FILES_VAR:= H_CURSES +BUILTIN_FIND_FILES.H_CURSES= /usr/include/curses.h + +.include "buildlink3/bsd.builtin.mk" + +### +### Determine if there is a built-in implementation of the package and +### set IS_BUILTIN.<pkg> appropriately ("yes" or "no"). +### +.if !defined(IS_BUILTIN.curses) +IS_BUILTIN.curses= no +. if empty(H_CURSES:M${LOCALBASE}/*) && exists(${H_CURSES}) +IS_BUILTIN.curses= yes +. endif +.endif +MAKEVARS+= IS_BUILTIN.curses + +### +### Determine whether we should use the built-in implementation if it +### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no"). +### +.if !defined(USE_BUILTIN.curses) +# +# There will probably never be a devel/curses package because ncurses is +# the recommended curses on many platforms, so we should always prefer the +# native curses package. +# +PREFER.curses= native +. if ${PREFER.curses} == "pkgsrc" +USE_BUILTIN.curses= no +. else +USE_BUILTIN.curses= ${IS_BUILTIN.curses} +. if defined(BUILTIN_PKG.curses) && !empty(IS_BUILTIN.curses:M[yY][eE][sS]) +USE_BUILTIN.curses= yes +. for _dep_ in ${BUILDLINK_API_DEPENDS.curses} +. if !empty(USE_BUILTIN.curses:M[yY][eE][sS]) +USE_BUILTIN.curses!= \ + if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.curses:Q}; then \ + ${ECHO} yes; \ + else \ + ${ECHO} no; \ + fi +. endif +. endfor +. endif +. endif # PREFER.curses +.endif +MAKEVARS+= USE_BUILTIN.curses + +### +### The section below only applies if we are not including this file +### solely to determine whether a built-in implementation exists. +### +CHECK_BUILTIN.curses?= no +.if !empty(CHECK_BUILTIN.curses:M[nN][oO]) + +. if !empty(USE_BUILTIN.curses:M[yY][eE][sS]) +. if exists(${H_CURSES}) +BUILDLINK_INCDIRS.curses?= ${H_CURSES:H:S/^${BUILDLINK_PREFIX.curses}\///} +. endif +. if !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS]) +BUILDLINK_LDADD.curses?= -lcurses +. endif +. endif + +.endif # CHECK_BUILTIN.curses |