Wed Mar 5 16:23:52 2008 UTC ()
+ Fix error in previous commit -- too much of the termcap buildlink
  code was moved to the builtin.mk file.  The buildlink3.mk file should
  contain the bits that always apply to all packages that include it.
  The builtin.mk file should include the bits that only apply if
  "termcap" is listed in ${BUILDLINK_PACKAGES} (this isn't the case
  if we use curses to replace termcap).  As such, redistribute the
  code as follows:

    + Move the parts that remove -l options for terminal libraries we
      don't support, as well as for transforming "-ltermcap" into the
      appropriate libraries, from the builtin.mk back into the
      buildlink3.mk.

    + Leave the parts the remove -lcurses and -lncurses in the
      builtin.mk.  We can remove the ${TERMCAP_TYPE} == "curses" check
      since that part of the file is protected by CHECK_BUILTIN.termcap,
      so it should only be triggered if "termcap" is in BUILDLINK_PACKAGES,
      which only happens if ${TERMCAP_TYPE} isn't "curses".


(jlam)
diff -r1.4 -r1.5 pkgsrc/mk/termcap.buildlink3.mk
diff -r1.3 -r1.4 pkgsrc/mk/termcap.builtin.mk

cvs diff -r1.4 -r1.5 pkgsrc/mk/termcap.buildlink3.mk (expand / switch to context diff)
--- pkgsrc/mk/termcap.buildlink3.mk 2008/03/05 07:10:26 1.4
+++ pkgsrc/mk/termcap.buildlink3.mk 2008/03/05 16:23:52 1.5
@@ -1,4 +1,4 @@
-# $NetBSD: termcap.buildlink3.mk,v 1.4 2008/03/05 07:10:26 jlam Exp $
+# $NetBSD: termcap.buildlink3.mk,v 1.5 2008/03/05 16:23:52 jlam Exp $
 #
 # This Makefile fragment is meant to be included by packages that require
 # a termcap implementation that supports the basic termcap functions:
@@ -8,8 +8,7 @@
 # === Variables set by this file ===
 #
 # TERMCAP_TYPE
-#	The name of the selected termcap implementation.  This is actually
-#	indirectly set by termcap.builtin.mk but is exported by this file.
+#	The name of the selected termcap implementation.
 
 TERMCAP_BUILDLINK3_MK:=	${TERMCAP_BUILDLINK3_MK}+
 
@@ -17,9 +16,38 @@
 
 .if !empty(TERMCAP_BUILDLINK3_MK:M+)
 
+# _TERMCAP_TYPES is an exhaustive list of all of the termcap
+#	implementations that may be found.
+#
+_TERMCAP_TYPES?=	curses termcap termlib tinfo
+
 CHECK_BUILTIN.termcap:=	yes
 .  include "termcap.builtin.mk"
 CHECK_BUILTIN.termcap:=	no
+
+.if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
+.  if defined(BUILTIN_LIBNAME.termcap)
+TERMCAP_TYPE=	${BUILTIN_LIBNAME.termcap}
+.  else
+TERMCAP_TYPE=	none
+.  endif
+.else
+TERMCAP_TYPE=	curses		# pkgsrc termcap is curses
+.endif
+BUILD_DEFS+=	TERMCAP_TYPE
+
+# Most GNU configure scripts will try finding every termcap implementation,
+# so prevent them from finding any except for the one we decide upon.
+#
+# There is special handling for packages that can be provided by pkgsrc,
+# e.g. curses -- see termcap.builtin.mk for details.
+#
+.  for _tcap_ in ${_TERMCAP_TYPES:Ntermcap:Ncurses}
+.    if empty(TERMCAP_TYPE:M${_tcap_})
+BUILDLINK_TRANSFORM+=		rm:-l${_tcap_}
+.    endif
+.  endfor
+BUILDLINK_TRANSFORM+=		l:termcap:${BUILDLINK_LIBNAME.termcap}
 
 .endif	# TERMCAP_BUILDLINK3_MK
 

cvs diff -r1.3 -r1.4 pkgsrc/mk/termcap.builtin.mk (expand / switch to context diff)
--- pkgsrc/mk/termcap.builtin.mk 2008/03/05 07:10:26 1.3
+++ pkgsrc/mk/termcap.builtin.mk 2008/03/05 16:23:52 1.4
@@ -1,14 +1,9 @@
-# $NetBSD: termcap.builtin.mk,v 1.3 2008/03/05 07:10:26 jlam Exp $
+# $NetBSD: termcap.builtin.mk,v 1.4 2008/03/05 16:23:52 jlam Exp $
 
 BUILTIN_PKG:=	termcap
 
-# _TERMCAP_TYPES is an exhaustive list of all of the termcap implementations
-#	that may be found.
-#
-_TERMCAP_TYPES?=	curses termcap termlib tinfo
+BUILTIN_FIND_LIBS:=	curses termcap termlib tinfo
 
-BUILTIN_FIND_LIBS:=	${_TERMCAP_TYPES}
-
 .include "buildlink3/bsd.builtin.mk"
 
 ###
@@ -58,17 +53,6 @@
 BUILTIN_LIBNAME.termcap=	termlib
 .endif
 
-.if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
-.  if defined(BUILTIN_LIBNAME.termcap)
-TERMCAP_TYPE=	${BUILTIN_LIBNAME.termcap}
-.  else
-TERMCAP_TYPE=	none
-.  endif
-.else
-TERMCAP_TYPE=	curses		# pkgsrc termcap is curses
-.endif
-BUILD_DEFS+=	TERMCAP_TYPE
-
 ###
 ### The section below only applies if we are not including this file
 ### solely to determine whether a built-in implementation exists.
@@ -80,23 +64,14 @@
 BUILDLINK_LIBNAME.termcap=	${BUILTIN_LIBNAME.termcap}
 .  endif
 
-# Most GNU configure scripts will try finding every termcap implementation,
-# so prevent them from finding any except for the one we decide upon.
+# If the package wants both "termcap" and "curses", then we must not
+# remove the -l options for the curses libraries; otherwise, we should
+# remove them as GNU configure scripts commonly check for one or both
+# of those library options.
 #
-# There is special handling here for packages that can be provided by
-# pkgsrc, e.g. curses.  In case we need both that package as well as
-# termcap, we must not remove the -l options for that package's libraries.
-#
-.  for _tcap_ in ${_TERMCAP_TYPES:Ntermcap:Ncurses}
-.    if empty(TERMCAP_TYPE:M${_tcap_})
-BUILDLINK_TRANSFORM+=		rm:-l${_tcap_}
-.    endif
-.  endfor
-.  if empty(TERMCAP_TYPE:Mcurses) && \
-      empty(BUILDLINK_PACKAGES:Mcurses) && empty(BUILDLINK_PACKAGES:Mncurses)
+.  if empty(BUILDLINK_PACKAGES:Mcurses) && empty(BUILDLINK_PACKAGES:Mncurses)
 BUILDLINK_TRANSFORM+=		rm:-lcurses
 BUILDLINK_TRANSFORM+=		rm:-lncurses
 .  endif
-BUILDLINK_TRANSFORM+=		l:termcap:${BUILDLINK_LIBNAME.termcap}
 
 .endif	# CHECK_BUILTIN.termcap