summaryrefslogtreecommitdiff
path: root/devel/ncurses/builtin.mk
diff options
context:
space:
mode:
Diffstat (limited to 'devel/ncurses/builtin.mk')
-rw-r--r--devel/ncurses/builtin.mk194
1 files changed, 100 insertions, 94 deletions
diff --git a/devel/ncurses/builtin.mk b/devel/ncurses/builtin.mk
index f42eca9e9fe..952ece0d01a 100644
--- a/devel/ncurses/builtin.mk
+++ b/devel/ncurses/builtin.mk
@@ -1,145 +1,151 @@
-# $NetBSD: builtin.mk,v 1.7 2004/12/11 00:32:16 jlam Exp $
+# $NetBSD: builtin.mk,v 1.8 2005/06/01 18:02:44 jlam Exp $
-.for _lib_ in ncurses
-. if !defined(_BLNK_LIB_FOUND.${_lib_})
-_BLNK_LIB_FOUND.${_lib_}!= \
- if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" != "/usr/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" != "/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-BUILDLINK_VARS+= _BLNK_LIB_FOUND.${_lib_}
-. endif
-.endfor
-.undef _lib_
+BUILTIN_PKG:= ncurses
-_NCURSES_H= /usr/include/curses.h
+BUILTIN_FIND_LIBS:= ncurses
+BUILTIN_FIND_FILES_VAR:= H_NCURSES
+BUILTIN_FIND_FILES.H_NCURSES= /usr/include/curses.h
+BUILTIN_FIND_GREP.H_NCURSES= \#define[ ]*NCURSES_VERSION
+.include "../../mk/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.ncurses)
IS_BUILTIN.ncurses= no
-. if !empty(_BLNK_LIB_FOUND.ncurses:M[yY][eE][sS])
+. if empty(H_NCURSES:M${LOCALBASE}/*) && exists(${H_NCURSES}) && \
+ !empty(BUILTIN_LIB_FOUND.ncurses:M[yY][eE][sS])
IS_BUILTIN.ncurses= yes
-. elif exists(${_NCURSES_H})
-IS_BUILTIN.ncurses!= \
- if ${GREP} -q "\#define[ ]*NCURSES_VERSION" ${_NCURSES_H}; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-. if !empty(IS_BUILTIN.ncurses:M[yY][eE][sS])
-#
-# Create an appropriate name for the built-in package distributed
-# with the system. This package name can be used to check against
-# BUILDLINK_DEPENDS.<pkg> to see if we need to install the pkgsrc
-# version or if the built-in one is sufficient.
-#
-_NCURSES_VERSION!= \
+. endif
+.endif
+MAKEVARS+= IS_BUILTIN.ncurses
+
+###
+### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
+### a package name to represent the built-in package.
+###
+.if !defined(BUILTIN_PKG.ncurses) && \
+ !empty(IS_BUILTIN.ncurses:M[yY][eE][sS]) && \
+ exists(${H_NCURSES})
+BUILTIN_VERSION.ncurses!= \
${AWK} '/\#define[ ]*NCURSES_VERSION[ ]/ { \
vers = $$3; \
gsub("\"", "", vers); \
print vers; \
} \
- ' ${_NCURSES_H}
-BUILTIN_PKG.ncurses= ncurses-${_NCURSES_VERSION}
-BUILDLINK_VARS+= BUILTIN_PKG.ncurses
-. endif
-. endif
-BUILDLINK_VARS+= IS_BUILTIN.ncurses
-.endif # IS_BUILTIN.ncurses
+ ' ${H_NCURSES:Q}
+BUILTIN_PKG.ncurses= ncurses-${BUILTIN_VERSION.ncurses}
+.endif
+MAKEVARS+= BUILTIN_PKG.ncurses
+###
+### 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.ncurses)
-USE_BUILTIN.ncurses?= ${IS_BUILTIN.ncurses}
-PREFER.ncurses?= pkgsrc
-
-. if defined(BUILTIN_PKG.ncurses)
+. if ${PREFER.ncurses} == "pkgsrc"
+USE_BUILTIN.ncurses= no
+. else
+USE_BUILTIN.ncurses= ${IS_BUILTIN.ncurses}
+. if defined(BUILTIN_PKG.ncurses) && \
+ !empty(IS_BUILTIN.ncurses:M[yY][eE][sS])
USE_BUILTIN.ncurses= yes
-. for _depend_ in ${BUILDLINK_DEPENDS.ncurses}
-. if !empty(IS_BUILTIN.ncurses:M[yY][eE][sS])
+. for _dep_ in ${BUILDLINK_DEPENDS.ncurses}
+. if !empty(USE_BUILTIN.ncurses:M[yY][eE][sS])
USE_BUILTIN.ncurses!= \
- if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.ncurses}; then \
- ${ECHO} "yes"; \
+ if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.ncurses:Q}; then \
+ ${ECHO} yes; \
else \
- ${ECHO} "no"; \
+ ${ECHO} no; \
fi
-. endif
-. endfor
-. endif
-
-. if ${PREFER.ncurses} == "native"
+. endif
+. endfor
+. endif
# XXX
-# XXX By default, assume that the native curses on NetBSD systems
-# XXX supports ncurses.
+# XXX By default, assume that the native curses on NetBSD systems is
+# XXX good enough to replace ncurses. In reality, no version of NetBSD
+# XXX has a curses library that can completely replace ncurses; however,
+# XXX some versions implement enough of ncurses that some packages are
+# XXX happy.
# XXX
. if ${OPSYS} == "NetBSD"
USE_BUILTIN.ncurses= yes
+. endif
#
-# These versions of NetBSD didn't have a curses library that was
-# capable of replacing ncurses.
-#
-# XXX In reality, no version of NetBSD has a curses library that can
-# XXX completely replace ncurses; however, some versions implement
-# XXX enough of ncurses that some packages are happy.
+# Some platforms don't have a curses implementation that can replace
+# ncurses.
#
-_INCOMPAT_CURSES= NetBSD-0.*-* NetBSD-1.[0123]*-*
-_INCOMPAT_CURSES+= NetBSD-1.4.*-* NetBSD-1.4[A-X]-*
-. for _pattern_ in ${_INCOMPAT_CURSES} ${INCOMPAT_CURSES}
-. if !empty(MACHINE_PLATFORM:M${_pattern_})
+_INCOMPAT_CURSES?= NetBSD-0.*-* NetBSD-1.[0123]*-* \
+ NetBSD-1.4.*-* NetBSD-1.4[A-X]-*
+. for _pattern_ in ${_INCOMPAT_CURSES} ${INCOMPAT_CURSES}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
USE_BUILTIN.ncurses= no
-. endif
-. endfor
-. endif
-. endif
+. endif
+. endfor
+. endif # PREFER.ncurses
+.endif
+MAKEVARS+= USE_BUILTIN.ncurses
-. if defined(USE_NCURSES)
-. if !empty(IS_BUILTIN.ncurses:M[nN][oO]) || \
- (${PREFER.ncurses} == "pkgsrc")
+# If USE_NCURSES is defined, then force the use of an ncurses
+# implementation.
+#
+.if defined(USE_NCURSES)
+. if !empty(IS_BUILTIN.ncurses:M[nN][oO])
USE_BUILTIN.ncurses= no
-. endif
. endif
-.endif # USE_BUILTIN.ncurses
+.endif
+###
+### The section below only applies if we are not including this file
+### solely to determine whether a built-in implementation exists.
+###
CHECK_BUILTIN.ncurses?= no
.if !empty(CHECK_BUILTIN.ncurses:M[nN][oO])
-.if !empty(USE_BUILTIN.ncurses:M[yY][eE][sS])
-. include "../../mk/bsd.prefs.mk"
-. if !empty(_BLNK_LIB_FOUND.ncurses:M[nN][oO]) || ${OPSYS} == "Interix"
+. if !empty(USE_BUILTIN.ncurses:M[yY][eE][sS])
+. if !empty(BUILTIN_LIB_FOUND.ncurses:M[nN][oO]) || (${OPSYS} == "Interix")
BUILDLINK_TRANSFORM.ncurses+= -e "s|/curses\.h|/ncurses.h|g"
BUILDLINK_TRANSFORM+= l:ncurses:curses
-. endif
+. endif
BUILDLINK_FILES.ncurses+= include/curses.h
BUILDLINK_TARGETS+= buildlink-ncurses-extra-includes
-.endif
-
+. endif
BUILDLINK_TARGETS+= buildlink-ncurses-curses-h
-.if !target(buildlink-ncurses-extra-includes)
+# A full ncurses implementation provides more headers than some curses
+# implementations. Touch empty replacements for those headers so that
+# packages can continue to use the familiar ncurses header names.
+#
+. if !target(buildlink-ncurses-extra-includes)
.PHONY: buildlink-ncurses-extra-includes
buildlink-ncurses-extra-includes:
${_PKG_SILENT}${_PKG_DEBUG} \
extra_includes="include/term.h"; \
- for f in $${extra_includes}; do \
- if [ ! -f ${BUILDLINK_PREFIX.ncurses}/$$f ]; then \
- ${ECHO_BUILDLINK_MSG} "Touching extra ncurses header ($$f) in ${BUILDLINK_DIR}."; \
- ${MKDIR} -p `${DIRNAME} ${BUILDLINK_DIR}/$$f`; \
- ${TOUCH} ${TOUCH_FLAGS} ${BUILDLINK_DIR}/$$f; \
+ for f in $$extra_includes; do \
+ src=${BUILDLINK_PREFIX.ncurses:Q}"/$$f"; \
+ dest=${BUILDLINK_DIR:Q}"/$$f"; \
+ if ${TEST} ! -f "$$src"; then \
+ ${ECHO_BUILDLINK_MSG} "Touching extra ncurses header ($$f)"; \
+ ${MKDIR} `${DIRNAME} "$$dest"`; \
+ ${TOUCH} ${TOUCH_FLAGS} "$$dest"; \
fi; \
done
-.endif
+. endif
-.if !target(buildlink-ncurses-curses-h)
+# Some packages expect <curses.h> to provide declarations for ncurses.
+. if !target(buildlink-ncurses-curses-h)
.PHONY: buildlink-ncurses-curses-h
buildlink-ncurses-curses-h:
${_PKG_SILENT}${_PKG_DEBUG} \
- if [ ! -f ${BUILDLINK_DIR}/include/curses.h -a \
- -f ${BUILDLINK_PREFIX.ncurses}/include/ncurses.h ]; then \
+ src=${BUILDLINK_PREFIX.ncurses:Q}"/include/ncurses.h"; \
+ dest=${BUILDLINK_DIR:Q}"/include/curses.h"; \
+ if ${TEST} ! -f "$$dest" -a -f "$$src"; then \
${ECHO_BUILDLINK_MSG} "Linking curses.h -> ncurses.h."; \
- ${MKDIR} -p ${BUILDLINK_DIR}/include; \
- ${LN} -s ${BUILDLINK_PREFIX.ncurses}/include/ncurses.h \
- ${BUILDLINK_DIR}/include/curses.h; \
+ ${MKDIR} `${DIRNAME} "$$dest"`; \
+ ${LN} -s "$$src" "$$dest"; \
fi
-.endif
+. endif
.endif # CHECK_BUILTIN.ncurses