Subject: pkg/22955: some more suggestions and ideas for the pkgsrc infrastructure
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 09/25/2003 15:00:09
>Number:         22955
>Category:       pkg
>Synopsis:       some more suggestions and ideas for the pkgsrc infrastructure
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 25 19:01:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Greg A. Woods
>Release:        2003/09/17
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD
>Description:

	here are a whole bunch of suggestions and fixes and ideas for pkgsrc

>How-To-Repeat:

>Fix:

Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1288
diff -c -r1.1288 bsd.pkg.mk
*** mk/bsd.pkg.mk	17 Sep 2003 02:38:22 -0000	1.1288
--- mk/bsd.pkg.mk	22 Sep 2003 05:18:33 -0000
***************
*** 75,83 ****
  CLEANDEPENDS?=		NO
  DEINSTALLDEPENDS?=	NO	# add -R to pkg_delete
  REINSTALL?=		NO	# reinstall upon update
! CHECK_SHLIBS?=		YES	# run check-shlibs after install
  SHLIB_HANDLING?=	YES	# do automatic shared lib handling
  NOCLEAN?=		NO	# don't clean up after update
  
  PKGBASE?=		${PKGNAME:C/-[^-]*$//}
  PKGVERSION?=		${PKGNAME:C/^.*-//}
--- 75,84 ----
  CLEANDEPENDS?=		NO
  DEINSTALLDEPENDS?=	NO	# add -R to pkg_delete
  REINSTALL?=		NO	# reinstall upon update
! CHECK_SHLIBS?=		YES	# run check-shlibs after install, if PKG_DEVELOPER
  SHLIB_HANDLING?=	YES	# do automatic shared lib handling
  NOCLEAN?=		NO	# don't clean up after update
+ ALLOW_DOWNLEVEL_DEPENDS?=YES	# allow out-of-date dependencies
  
  PKGBASE?=		${PKGNAME:C/-[^-]*$//}
  PKGVERSION?=		${PKGNAME:C/^.*-//}
***************
*** 271,276 ****
--- 272,285 ----
  _PERL5_DEPENDS=		perl>=${PERL5_REQD}
  .  if !defined(BUILDLINK_DEPENDS.perl)
  ${_PERL5_DEPMETHOD}+=	${_PERL5_DEPENDS}:${PERL5_PKGSRCDIR}
+ .    if (${DISTNAME} != "p5-perl-headers")
+ # This isn't strictly true -- it's only needed for those applications
+ # which use system calls directly from scripts, and it implicitly will
+ # pull in perl too, but it's better than finding and editing every
+ # makefile for every perl package that really will need this integral
+ # part of perl....
+ ${_PERL5_DEPMETHOD}+=	p5-perl-headers-${OS_VERSION}:../../devel/p5-perl-headers
+ .    endif
  .  endif
  .endif
  
***************
*** 320,326 ****
  .    if empty(USE_BUILDLINK2:M[nN][oO])
  .      include "../../lang/f2c/buildlink2.mk"
  .    else
! DEPENDS+=	f2c>=20001205nb3:../../lang/f2c
  .    endif
  .  endif
  FC=             ${PKG_FC}
--- 329,337 ----
  .    if empty(USE_BUILDLINK2:M[nN][oO])
  .      include "../../lang/f2c/buildlink2.mk"
  .    else
! # this is an LDSTATIC_DEPENDS not just BUILD_DEPENDS because of the
! # shared Fortran run-time libs
! ${LDSTATIC_DEPENDS}+=	f2c>=20001205nb3:../../lang/f2c
  .    endif
  .  endif
  FC=             ${PKG_FC}
***************
*** 361,367 ****
  .if defined(USE_LIBTOOL)
  PKGLIBTOOL=		${LIBTOOL}
  PKGSHLIBTOOL=		${SHLIBTOOL}
! BUILD_DEPENDS+=		libtool-base>=${LIBTOOL_REQD}:../../devel/libtool-base
  CONFIGURE_ENV+=		LIBTOOL="${PKGLIBTOOL} ${LIBTOOL_FLAGS}"
  MAKE_ENV+=		LIBTOOL="${PKGLIBTOOL} ${LIBTOOL_FLAGS}"
  .endif
--- 372,381 ----
  .if defined(USE_LIBTOOL)
  PKGLIBTOOL=		${LIBTOOL}
  PKGSHLIBTOOL=		${SHLIBTOOL}
! . if ${USE_LIBTOOL} == "YES" ||  ${USE_LIBTOOL} == "yes"
! USE_LIBTOOL=		# defined
! . endif
! BUILD_DEPENDS+=		libtool${USE_LIBTOOL}>=${LIBTOOL_REQD}:../../devel/libtool${USE_LIBTOOL}
  CONFIGURE_ENV+=		LIBTOOL="${PKGLIBTOOL} ${LIBTOOL_FLAGS}"
  MAKE_ENV+=		LIBTOOL="${PKGLIBTOOL} ${LIBTOOL_FLAGS}"
  .endif
***************
*** 389,401 ****
--- 403,468 ----
  # Miscellaneous overridable commands:
  SHCOMMENT?=		${ECHO_MSG} >/dev/null '***'
  
+ # note this will cause double-up of these flags for packages using bmake
+ .if defined(COPTS) && !empty(COPTS) && defined(CFLAGS) && !empty(CFLAGS) && empty(CFLAGS:M*${COPTS}*)
+ CFLAGS+=              ${COPTS}
+ .endif
+ 
  DISTINFO_FILE?=		${.CURDIR}/distinfo
  
+ # initial things to do with LDSTATIC 
+ #
+ .if !empty(LDSTATIC)
+ 
+ MAKE_ENV+=		LDSTATIC="${LDSTATIC}"
+ . if empty(LDFLAGS:M*${LDSTATIC}*)
+ LDFLAGS+=		${LDSTATIC}
+ . endif
+ 
+ # XXX --disable-shared should be safe for all modern Autoconf
+ # generated scripts, but not, e.g., db4's....
+ . if defined(GNU_CONFIGURE) && !defined(NO_DISABLE_SHARED)
+ CONFIGURE_ARGS+=	--disable-shared
+ CONFIGURE_ENV+=		acl_cv_shlibext=
+ . endif
+ 
+ # XXX some packages use --enable-static to explicity generate extra
+ # static-linked binaries on their own (e.g. bogofilter) -- usually
+ # though for our purposes the use of LDSTATIC in LDFLAGS does the
+ # trick
+ . if defined(GNU_CONFIGURE) && !defined(NO_ENABLE_STATIC)
+ CONFIGURE_ARGS+=	--enable-static
+ . endif
+ 
+ .else # !-static
+ 
+ # XXX these should be safe for all modern Autoconf generated
+ # scripts....  XXX except those that don't allow both at the same
+ # time, eg. Mozilla et al, or those like bogofilger which use this to
+ # build extra static-linked binaries....
+ . if defined(GNU_CONFIGURE) && !defined(NO_ENABLE_STATIC)
+ CONFIGURE_ARGS+=	--enable-shared --enable-static
+ . endif
+ 
+ .endif # !-static
+ 
+ # X11 things to do with LDSTATIC
+ #
+ .if !empty(LDSTATIC)
+ 
+ .if defined(USE_X11)
+ X11_LDFLAGS=		-L${X11BASE}/lib
+ LDFLAGS+=		${X11_LDFLAGS}
+ .endif
+ 
+ .else # !-static   XXX don't indent anything in here as it's not locally modified...
+ 
  .include "../../mk/compiler.mk"
  
  FIX_RPATH+=		LIBS
  .if defined(USE_X11)
  X11_LDFLAGS=		# empty
+ # makes LDFLAGS unsuitable for use with ld itself because of the '-Wl'
  X11_LDFLAGS+=		-Wl,${RPATH_FLAG}${X11BASE}/lib
  X11_LDFLAGS+=		-L${X11BASE}/lib
  .endif
***************
*** 407,424 ****
  .  endif
  .endif
  FIX_RPATH+=		LDFLAGS
- MAKE_ENV+=		LDFLAGS="${LDFLAGS}"
  MAKE_ENV+=		RPATH_FLAG="${RPATH_FLAG}"
  MAKE_ENV+=		WHOLE_ARCHIVE_FLAG="${WHOLE_ARCHIVE_FLAG}"
  MAKE_ENV+=		NO_WHOLE_ARCHIVE_FLAG="${NO_WHOLE_ARCHIVE_FLAG}"
  MAKE_ENV+=		LINK_ALL_LIBGCC_HACK="${LINK_ALL_LIBGCC_HACK}"
  
  CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}" M4="${M4}" YACC="${YACC}"
  CONFIGURE_ENV+=		RPATH_FLAG="${RPATH_FLAG}"
  
  MAKE_FLAGS?=
  MAKEFILE?=		Makefile
! MAKE_ENV+=		PATH=${PATH}:${LOCALBASE}/bin:${X11BASE}/bin
  MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE}
  MAKE_ENV+=		X11BASE=${X11BASE} CFLAGS="${CFLAGS}"
  MAKE_ENV+=		CPPFLAGS="${CPPFLAGS}" FFLAGS="${FFLAGS}"
--- 474,497 ----
  .  endif
  .endif
  FIX_RPATH+=		LDFLAGS
  MAKE_ENV+=		RPATH_FLAG="${RPATH_FLAG}"
+ 
+ .endif # !-static (for USE_X11)
+ 
+ MAKE_ENV+=		LDFLAGS="${LDFLAGS}"
  MAKE_ENV+=		WHOLE_ARCHIVE_FLAG="${WHOLE_ARCHIVE_FLAG}"
  MAKE_ENV+=		NO_WHOLE_ARCHIVE_FLAG="${NO_WHOLE_ARCHIVE_FLAG}"
  MAKE_ENV+=		LINK_ALL_LIBGCC_HACK="${LINK_ALL_LIBGCC_HACK}"
  
  CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}" M4="${M4}" YACC="${YACC}"
+ CONFIGURE_ENV+=		AWK="${AWK}"
  CONFIGURE_ENV+=		RPATH_FLAG="${RPATH_FLAG}"
  
  MAKE_FLAGS?=
  MAKEFILE?=		Makefile
! # XXX pkgtools/digest uses OPSYS in a pmake makefile....
! MAKE_ENV+=		OPSYS=${OPSYS}
! MAKE_ENV+=		PATH=${PATH}:${X11BASE}/bin:${LOCALBASE}/bin:${LOCALBASE}/sbin
  MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE}
  MAKE_ENV+=		X11BASE=${X11BASE} CFLAGS="${CFLAGS}"
  MAKE_ENV+=		CPPFLAGS="${CPPFLAGS}" FFLAGS="${FFLAGS}"
***************
*** 466,471 ****
--- 539,547 ----
  .endif
  PATCH_FUZZ_FACTOR?=	-F0			# Default to zero fuzz
  
+ # what kind of diffs should makepatches create?
+ MAKEPATCH_DIFF_ARGS?= -u
+ 
  EXTRACT_SUFX?=		.tar.gz
  
  # We need bzip2 for PATCHFILES with .bz2 suffix.
***************
*** 511,516 ****
--- 587,594 ----
  
  WRKSRC?=		${WRKDIR}/${DISTNAME}
  
+ HOME=			${WRKSRC}
+ 
  .if defined(NO_WRKSUBDIR)
  PKG_FAIL_REASON+='NO_WRKSUBDIR has been deprecated - please replace it with an explicit'
  PKG_FAIL_REASON+='assignment of WRKSRC= $${WRKDIR}'
***************
*** 624,629 ****
--- 702,717 ----
  .if defined(PERL5_ARCHLIB)
  PLIST_SUBST+=	PERL5_ARCHLIB=${PERL5_ARCHLIB:S/^${LOCALBASE}\///}
  .endif
+ .if !empty(LDSTATIC)
+ PLIST_SUBST+=	SHARED_ONLY="@comment "
+ .else
+ PLIST_SUBST+=	SHARED_ONLY=""
+ .endif
+ 
+ # Set REQUIRE_FILE to be the name of any REQUIRE file
+ .if !defined(REQUIRE_FILE) && exists(${PKGDIR}/REQUIRE)
+ REQUIRE_FILE=		${PKGDIR}/REQUIRE
+ .endif
  
  # Handle info files
  #
***************
*** 698,703 ****
--- 786,794 ----
  # Latest version of digest(1) required for pkgsrc
  DIGEST_REQD=		20010302
  
+ # XXX the DEPENDS_TARGET expansion doesn't seem to work right here (at
+ # least not for "make package")
+ #
  .PHONY: uptodate-digest
  uptodate-digest:
  	${_PKG_SILENT}${_PKG_DEBUG}					\
***************
*** 758,770 ****
  PRESERVE_FILE=		${WRKDIR}/.PRESERVE
  
  .ifndef PKG_ARGS_COMMON
! PKG_ARGS_COMMON=	-v -c -${COMMENT:Q}" " -d ${DESCR} -f ${PLIST}
! PKG_ARGS_COMMON+=	-l -b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE}
  PKG_ARGS_COMMON+=	-s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE}
  PKG_ARGS_COMMON+=	-P "`${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true | ${SORT} -u`"
  .  ifdef CONFLICTS
  PKG_ARGS_COMMON+=	-C "${CONFLICTS}"
  .  endif
  .  ifdef INSTALL_FILE
  PKG_ARGS_COMMON+=	-i ${INSTALL_FILE}
  .  endif
--- 849,882 ----
  PRESERVE_FILE=		${WRKDIR}/.PRESERVE
  
  .ifndef PKG_ARGS_COMMON
! PKG_ARGS_COMMON=	-c -${COMMENT:Q}" " -d ${DESCR} -f ${PLIST}
! PKG_ARGS_COMMON+=	-b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE}
  PKG_ARGS_COMMON+=	-s ${SIZE_PKG_FILE} -S ${SIZE_ALL_FILE}
  PKG_ARGS_COMMON+=	-P "`${MAKE} ${MAKEFLAGS} run-depends-list PACKAGE_DEPENDS_QUICK=true | ${SORT} -u`"
+ # 
+ # This is maybe not ever really be 100% necessary?  After all, we
+ # cannot change the prefix of a binary package without rebuilding it
+ # from source.
+ #
+ #     -l      Check that any symbolic links which are to be placed in the pack-
+ #             age are relative to the current prefix.  This means using
+ #             unlink(2) and symlink(2) to remove and re-link any symbolic links
+ #             which are targetted at full path names.
+ #
+ # This definitely breaks pkgtools/x11-links when LOCALBASE==/usr!
+ #
+ #.  if ${LOCALBASE} != /usr
+ #PKG_ARGS_COMMON+=	-l
+ #.  endif
+ .  if defined(PKG_VERBOSE)
+ PKG_ARGS_COMMON+=	-v
+ .  endif
  .  ifdef CONFLICTS
  PKG_ARGS_COMMON+=	-C "${CONFLICTS}"
  .  endif
+ .  ifdef REQUIRE_FILE
+ PKG_ARGS_COMMON+=	-r ${REQUIRE_FILE}
+ .  endif
  .  ifdef INSTALL_FILE
  PKG_ARGS_COMMON+=	-i ${INSTALL_FILE}
  .  endif
***************
*** 782,788 ****
  .  endif
  
  PKG_ARGS_INSTALL=	-p ${PREFIX} ${PKG_ARGS_COMMON}
! PKG_ARGS_BINPKG=	-p ${PREFIX:S/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON}
  .endif # !PKG_ARGS_COMMON
  
  .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
--- 894,900 ----
  .  endif
  
  PKG_ARGS_INSTALL=	-p ${PREFIX} ${PKG_ARGS_COMMON}
! PKG_ARGS_BINPKG=	-U -p ${PREFIX:S/^${DESTDIR}//} -L ${PREFIX} ${PKG_ARGS_COMMON}
  .endif # !PKG_ARGS_COMMON
  
  .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
***************
*** 1218,1223 ****
--- 1330,1337 ----
  CONFIGURE_DIRS?=	${WRKSRC}
  CONFIGURE_SCRIPT?=	./configure
  CONFIGURE_ENV+=		PATH=${PATH}:${LOCALBASE}/bin:${X11BASE}/bin
+ # XXX only really needed for GNU Autoconf generated configure scripts?
+ CONFIGURE_ENV+=		HOME=${HOME}
  
  .if defined(GNU_CONFIGURE)
  #
***************
*** 1227,1232 ****
--- 1341,1350 ----
  GNU_CONFIGURE_PREFIX?=	${PREFIX}
  CONFIGURE_ARGS+=	--host=${MACHINE_GNU_PLATFORM}
  CONFIGURE_ARGS+=	--prefix=${GNU_CONFIGURE_PREFIX}
+ CONFIGURE_ARGS+=	--infodir=${GNU_CONFIGURE_PREFIX}/share/info
+ CONFIGURE_ARGS+=	--mandir=${GNU_CONFIGURE_PREFIX}/share/man
+ # speeds up one-time builds, which is definitely pkgsrc!
+ CONFIGURE_ARGS+=	--disable-dependency-tracking
  HAS_CONFIGURE=		yes
  .  if ${X11PREFIX} == ${LOCALBASE}
  CONFIGURE_ARGS+=	--x-includes=${X11BASE}/include
***************
*** 1234,1239 ****
--- 1352,1397 ----
  .  endif
  .endif
  
+ # XXX with pkggmake we wouldn't have to worry about this....
+ #
+ .if defined(GNU_AUTOMAKE) && (${PKGPATH} != "devel/gmake" && ${PKGPATH} != "devel/m4" && ${PKGPATH} != "devel/gtexinfo" && ${PKGPATH} != "converters/libiconv" && ${PKGPATH} != "devel/gettext-lib")
+ USE_GMAKE=		# defined (safest)
+ .endif
+ 
+ # If we are going to run autoconf then we need a version of m4
+ # compatible with GNU M4.  We assume anything calling autoconf will
+ # have included "mk/autoconf.mk".
+ # 
+ # Warning: this will break if we ever try to autoreconf devel/gmake,
+ # devel/gtexinfo or devel/m4 or devel/gettext-lib or converters/libiconv
+ #
+ .if defined(AUTOCONF_MK)
+ . if !defined(SYSTEM_M4_OK) && exists(/usr/bin/m4)
+ SYSTEM_M4_OK!=		if /usr/bin/m4 -g < /dev/null 2> /dev/null ; then echo yes; else echo no; fi
+ . else
+ SYSTEM_M4_NO=		no
+ . endif
+ # avoid the shell fork for sub-makes....
+ MAKEFLAGS+=	SYSTEM_M4_OK=${SYSTEM_M4_OK}
+ . if (${SYSTEM_M4_OK} == "yes")
+ M4=			/usr/bin/m4 -g
+ . else
+ .  if (${PKGPATH} != "devel/gmake" && ${PKGPATH} != "devel/m4" && ${PKGPATH} != "devel/gtexinfo" && ${PKGPATH} != "converters/libiconv" && ${PKGPATH} != "devel/gettext-lib")
+ BUILD_DEPENDS+=		m4>=1.4:../../devel/m4
+ M4=			${LOCALBASE}/bin/gm4
+ .  else	# we have no choice....
+ M4?=			m4
+ .  endif
+ . endif
+ .else	# we don't really care if M4 is GNU-compatible, or even if it exists
+ . if exists(/usr/bin/m4)
+ M4?=			/usr/bin/m4
+ . else
+ M4?=			m4
+ . endif
+ CONFIGURE_ENV+=		M4=${M4}
+ .endif
+ 
  #
  # Config file related settings - see Packages.txt
  #
***************
*** 1405,1411 ****
  .endif # !NO_SKIP
  
  # Add these defs to the ones dumped into +BUILD_DEFS
! BUILD_DEFS+=	PKGPATH
  BUILD_DEFS+=	OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
  BUILD_DEFS+=	CPPFLAGS CFLAGS FFLAGS LDFLAGS
  BUILD_DEFS+=	CONFIGURE_ENV CONFIGURE_ARGS
--- 1563,1572 ----
  .endif # !NO_SKIP
  
  # Add these defs to the ones dumped into +BUILD_DEFS
! BUILD_DEFS+=	PREFIX LOCALBASE X11PREFIX X11BASE
! BUILD_DEFS+=	PKG_SYSCONFDIR
! BUILD_DEFS+=	DEPENDS BUILD_DEPENDS
! BUILD_DEFS+=	PKGPATH PKGBASE PKGVERSION
  BUILD_DEFS+=	OPSYS OS_VERSION MACHINE_ARCH MACHINE_GNU_ARCH
  BUILD_DEFS+=	CPPFLAGS CFLAGS FFLAGS LDFLAGS
  BUILD_DEFS+=	CONFIGURE_ENV CONFIGURE_ARGS
***************
*** 1652,1658 ****
  # Please do not modify the leading "@" here
  .PHONY: check-vulnerable
  check-vulnerable:
! 	@if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then			\
  		${SETENV} PKGNAME="${PKGNAME}"				\
  			  PKGBASE="${PKGBASE}"				\
  			${AWK} '/^$$/ { next }				\
--- 1813,1819 ----
  # Please do not modify the leading "@" here
  .PHONY: check-vulnerable
  check-vulnerable:
! 	@if [ -f ${PKGVULNDIR}/pkg-vulnerabilities ]; then		\
  		${SETENV} PKGNAME="${PKGNAME}"				\
  			  PKGBASE="${PKGBASE}"				\
  			${AWK} '/^$$/ { next }				\
***************
*** 1821,1827 ****
  	found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";	\
  	if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then	\
  		${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \
! 		if [ "X$$STOP_DOWNLEVEL_AFTER_FIRST" != "X" ]; then	\
  			${ECHO} "stopping after first downlevel pkg found"; \
  			exit 1;						\
  		fi;							\
--- 1982,1988 ----
  	found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`";	\
  	if [ "X$$found" != "X" -a "X$$found" != "X${PKGNAME}" ]; then	\
  		${ECHO} "${PKGBASE} package: $$found installed, pkgsrc version ${PKGNAME}"; \
! 		if [ "X${STOP_DOWNLEVEL_AFTER_FIRST}" != "X" ]; then	\
  			${ECHO} "stopping after first downlevel pkg found"; \
  			exit 1;						\
  		fi;							\
***************
*** 1829,1834 ****
--- 1990,2006 ----
  .  endif
  .endif
  
+ .PHONY: show-installed-build-depends
+ .if !target(show-installed-build-depends)
+ show-installed-build-depends:
+ .  if defined(BUILD_DEPENDS)
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	for i in ${BUILD_DEPENDS:C/:.*$//:Q:S/\ / /g} ; do		\
+ 		echo "$$i =>" `${PKG_INFO} -e $$i` ;			\
+ 	done
+ .  endif
+ .endif
+ 
  .PHONY: show-installed-depends
  .if !target(show-installed-depends)
  show-installed-depends:
***************
*** 1840,1845 ****
--- 2012,2029 ----
  .  endif
  .endif
  
+ .PHONY: show-installed-all-depends
+ .if !target(show-installed-all-depends)
+ show-depends: show-installed-all-depends
+ show-installed-all-depends:
+ .  if defined(DEPENDS) || defined(BUILD_DEPENDS)
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	for i in ${BUILD_DEPENDS:C/:.*$//:Q:S/\ / /g} ${DEPENDS:C/:.*$//:Q:S/\ / /g} ; do \
+ 		echo "$$i =>" `${PKG_INFO} -e $$i` ;			\
+ 	done
+ .  endif
+ .endif
+ 
  .PHONY: show-needs-update
  .if !target(show-needs-update)
  show-needs-update:
***************
*** 1920,1933 ****
  .endif
  	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${WRKDIR}
  .ifdef WRKOBJDIR
- .  if ${PKGSRC_LOCKTYPE} == "sleep" || ${PKGSRC_LOCKTYPE} == "once"
- .    if !exists(${LOCKFILE})
  	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${RM} -f ${WRKDIR_BASENAME} || ${TRUE}
! .    endif
! .  endif
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	if ${LN} -s ${WRKDIR} ${WRKDIR_BASENAME} 2>/dev/null; then	\
  		${ECHO} "${WRKDIR_BASENAME} -> ${WRKDIR}";		\
  	fi
  .endif # WRKOBJDIR
--- 2104,2113 ----
  .endif
  	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${WRKDIR}
  .ifdef WRKOBJDIR
  	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	if [ ! -h ${WRKDIR_BASENAME} ]; then				\
! 		${RM} -rf ${WRKDIR_BASENAME};				\
! 		${LN} -s ${WRKDIR} ${WRKDIR_BASENAME};			\
  		${ECHO} "${WRKDIR_BASENAME} -> ${WRKDIR}";		\
  	fi
  .endif # WRKOBJDIR
***************
*** 2017,2023 ****
  # was written with a buggy version of GNU tar.
  #
  .if defined(EXTRACT_USING_PAX)
! _DFLT_EXTRACT_CMD?=	{ ${DECOMPRESS_CMD} $${extract_file} ; dd if=/dev/zero bs=10k count=2; } | ${PAX} -O -r ${EXTRACT_ELEMENTS}
  .else
  _DFLT_EXTRACT_CMD?=	${DECOMPRESS_CMD} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
  .endif
--- 2197,2203 ----
  # was written with a buggy version of GNU tar.
  #
  .if defined(EXTRACT_USING_PAX)
! _DFLT_EXTRACT_CMD?=	${DECOMPRESS_CMD} $${extract_file} | ${PAX} -O -r ${EXTRACT_ELEMENTS}
  .else
  _DFLT_EXTRACT_CMD?=	${DECOMPRESS_CMD} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
  .endif
***************
*** 2025,2031 ****
  .for __suffix__ in ${_EXTRACT_SUFFICES}
  .  if !defined(EXTRACT_CMD${__suffix__})
  .    if defined(EXTRACT_USING_PAX)
! EXTRACT_CMD${__suffix__}?=	{ ${DECOMPRESS_CMD${__suffix__}} $${extract_file} ; dd if=/dev/zero bs=10k count=2; } | ${PAX} -O -r ${EXTRACT_ELEMENTS}
  .  else
  EXTRACT_CMD${__suffix__}?=	${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
  .    endif
--- 2205,2211 ----
  .for __suffix__ in ${_EXTRACT_SUFFICES}
  .  if !defined(EXTRACT_CMD${__suffix__})
  .    if defined(EXTRACT_USING_PAX)
! EXTRACT_CMD${__suffix__}?=	${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${PAX} -O -r ${EXTRACT_ELEMENTS}
  .  else
  EXTRACT_CMD${__suffix__}?=	${DECOMPRESS_CMD${__suffix__}} $${extract_file} | ${GTAR} -xf - ${EXTRACT_ELEMENTS}
  .    endif
***************
*** 2102,2108 ****
  				${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
  			fi;						\
  		else							\
! 			patchlist=`${ECHO} ${PATCHDIR}/patch-*`;	\
  		fi;							\
  	fi;								\
  	if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
--- 2282,2288 ----
  				${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
  			fi;						\
  		else							\
! 			patchlist=`${LS} -1 ${PATCHDIR}/patch-* | ${SED} 's|^${PATCHDIR}/patch-optional-.*$$||'`; \
  		fi;							\
  	fi;								\
  	if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
***************
*** 2113,2118 ****
--- 2293,2299 ----
  	else								\
  		patchlist=`${ECHO} $${patchlist} ${_LOCALPATCHFILES}`;	\
  	fi;								\
+ 	patchlist="$${patchlist} $${OPTIONAL_PATCHFILES}";		\
  	if [ -n "$${patchlist}" ]; then					\
  		${ECHO_MSG} "${_PKGSRC_IN}> Applying pkgsrc patches for ${PKGNAME}" ; \
  		fail="";						\
***************
*** 2292,2304 ****
  pre-configure-override: ${_CONFIGURE_PREREQ}
  	@${DO_NADA}
  
  .PHONY: do-configure
  .if !target(do-configure)
  do-configure: 
  .  if defined(HAS_CONFIGURE)
  .    for DIR in ${CONFIGURE_DIRS}
  	${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} \
! 	    AWK="${AWK}" CC="${CC}" CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" \
  	    CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" FC="${FC}" F77="${FC}" FFLAGS="${FFLAGS}" \
  	    INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}" \
  	    ac_given_INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}" \
--- 2473,2487 ----
  pre-configure-override: ${_CONFIGURE_PREREQ}
  	@${DO_NADA}
  
+ # XXX at the moment Autoconf still doesn't use CPPFLAGS so include it in CFLAGS too....
+ #
  .PHONY: do-configure
  .if !target(do-configure)
  do-configure: 
  .  if defined(HAS_CONFIGURE)
  .    for DIR in ${CONFIGURE_DIRS}
  	${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD}cd ${DIR} && ${SETENV} \
! 	    AWK="${AWK}" CC="${CC}" CFLAGS="${CFLAGS} ${CPPFLAGS}" CPPFLAGS="${CPPFLAGS}" \
  	    CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" FC="${FC}" F77="${FC}" FFLAGS="${FFLAGS}" \
  	    INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}" \
  	    ac_given_INSTALL="`${TYPE} ${INSTALL} | ${AWK} '{ print $$NF }'` -c -o ${BINOWN} -g ${BINGRP}" \
***************
*** 2389,2397 ****
  
  .PHONY: real-su-package
  .if !target(real-su-package)
  real-su-package: ${PLIST} ${DESCR}
  	${_PKG_SILENT}${_PKG_DEBUG}					\
- 	${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"; \
  	if ${PKG_INFO} -qe ${PKGNAME}; then				\
  		: The package is installed. ;				\
  	else								\
--- 2572,2582 ----
  
  .PHONY: real-su-package
  .if !target(real-su-package)
+ # needs to depend on README.html if we're installing that file in PKGREPOSITORY...
  real-su-package: ${PLIST} ${DESCR}
+ 	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} delete-package
+ 	@${ECHO_MSG} "${_PKGSRC_IN}> Building binary package for ${PKGNAME}"
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	if ${PKG_INFO} -qe ${PKGNAME}; then				\
  		: The package is installed. ;				\
  	else								\
***************
*** 2406,2416 ****
  		fi;							\
  	fi;								\
  	if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then		\
! 		${MAKE} ${MAKEFLAGS} package-links;			\
  	else								\
  		${MAKE} ${MAKEFLAGS} delete-package;			\
  		exit 1;							\
  	fi
  	${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${PACKAGE_COOKIE}
  .  if defined(NO_BIN_ON_CDROM)
  	@${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be put on a CD-ROM:"
--- 2591,2604 ----
  		fi;							\
  	fi;								\
  	if ${PKG_CREATE} ${PKG_ARGS_BINPKG} ${PKGFILE}; then		\
! 		:;							\
  	else								\
  		${MAKE} ${MAKEFLAGS} delete-package;			\
  		exit 1;							\
  	fi
+ 	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} package-links
+ #	${INSTALL_DATA} README.html ${PKGREPOSITORY}/${PKGNAME}-README.html
+ 	${INSTALL_DATA} ${DESCR} ${PKGREPOSITORY}/${PKGNAME}-DESCR.txt
  	${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${PACKAGE_COOKIE}
  .  if defined(NO_BIN_ON_CDROM)
  	@${ECHO_MSG} "${_PKGSRC_IN}> Warning: ${PKGNAME} may not be put on a CD-ROM:"
***************
*** 2427,2434 ****
  .PHONY: package-links
  .if !target(package-links)
  package-links:
! 	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} delete-package-links
! 	${_PKG_SILENT}${_PKG_DEBUG}for cat in ${CATEGORIES}; do		\
  		if [ ! -d ${PACKAGES}/$$cat ]; then			\
  			${MKDIR} ${PACKAGES}/$$cat;			\
  			if [ $$? -ne 0 ]; then				\
--- 2615,2623 ----
  .PHONY: package-links
  .if !target(package-links)
  package-links:
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Building binary links for package ${PKGNAME}"
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	for cat in ${CATEGORIES}; do					\
  		if [ ! -d ${PACKAGES}/$$cat ]; then			\
  			${MKDIR} ${PACKAGES}/$$cat;			\
  			if [ $$? -ne 0 ]; then				\
***************
*** 2444,2458 ****
  .PHONY: delete-package-links
  .if !target(delete-package-links)
  delete-package-links:
! 	${_PKG_SILENT}${_PKG_DEBUG}\
! 	${FIND} ${PACKAGES} -type l -name ${PKGNAME}${PKG_SUFX} | ${XARGS} ${RM} -f
  .endif
  
  .PHONY: delete-package
  .if !target(delete-package)
! delete-package:
! 	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} delete-package-links
! 	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE}
  .endif
  
  .PHONY: real-su-install
--- 2633,2658 ----
  .PHONY: delete-package-links
  .if !target(delete-package-links)
  delete-package-links:
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Deleting binary links for package ${PKGNAME}"
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${FIND} ${PACKAGES} -type l \( -name ${PKGNAME}${PKG_SUFX} -o 	\
! 				       -name ${PKGNAME}-DESCR.txt 	\
! 				    \) -print0 | ${XARGS} -0 ${RM} -f ""
! .endif
! 
! .if !target(delete-dead-package-links)
! delete-dead-package-links:
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Deleting old dead binary links for all packages in ${PACKAGES}"
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${FIND} ${PACKAGES} -type l -a ! \( -follow -type f \) -print0 | ${XARGS} -0 ${RM} -f ""
  .endif
  
  .PHONY: delete-package
  .if !target(delete-package)
! delete-package: delete-package-links
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Deleting binary package for ${PKGNAME}"
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${RM} -f ${PKGFILE} ${PKGREPOSITORY}/${PKGNAME}-DESCR.txt
  .endif
  
  .PHONY: real-su-install
***************
*** 2529,2534 ****
--- 2729,2738 ----
  				${MKDIR} ${PREFIX};			\
  			fi;						\
  			${MTREE} ${MTREE_ARGS} ${PREFIX}/;		\
+ 			${RM} -f ${PREFIX}/doc && ${LN} -s share/doc ${PREFIX}/doc;	\
+ 			${RM} -f ${PREFIX}/info && ${LN} -s share/info ${PREFIX}/info;	\
+ 			${RM} -f ${PREFIX}/man && ${LN} -s share/man ${PREFIX}/man;	\
+ 			${RM} -f ${PREFIX}/var && ${LN} -s /var ${PREFIX}/var;		\
  		fi;							\
  	else								\
  		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
***************
*** 2601,2607 ****
  .  endif
  .endif
  .ifdef MESSAGE
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Please note the following:"
  	@${ECHO_MSG} ""
  	@${CAT} ${MESSAGE}
  	@${ECHO_MSG} ""
--- 2805,2811 ----
  .  endif
  .endif
  .ifdef MESSAGE
! 	@${ECHO_MSG} "${_PKGSRC_IN}> Please note the following important message:"
  	@${ECHO_MSG} ""
  	@${CAT} ${MESSAGE}
  	@${ECHO_MSG} ""
***************
*** 2617,2624 ****
  .  endif
  .endif
  .if !defined(NO_PKG_REGISTER)
! 	${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} fake-pkg
  .endif # !NO_PKG_REGISTER
  	${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
  .if defined(PKG_DEVELOPER) && (${CHECK_SHLIBS} == "YES")
  	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-shlibs
--- 2821,2829 ----
  .  endif
  .endif
  .if !defined(NO_PKG_REGISTER)
! 	${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} register-pkg
  .endif # !NO_PKG_REGISTER
+ 	${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} check-for-base-clashes
  	${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
  .if defined(PKG_DEVELOPER) && (${CHECK_SHLIBS} == "YES")
  	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} check-shlibs
***************
*** 2872,2878 ****
  	fi;								\
  	if [ "$$error" = 1 ]; then					\
  		${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
! 		${ECHO} "    at runtime. Please fix the package (add -Wl,-R.../lib in the right places)!"; \
  		${SHCOMMENT} Might not error-out for non-pkg-developers; \
  		exit 1;							\
  	fi
--- 3077,3083 ----
  	fi;								\
  	if [ "$$error" = 1 ]; then					\
  		${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
! 		${ECHO} "    at runtime.  Please fix the package (add -Wl,-R.../lib in the right places)!" ; \
  		${SHCOMMENT} Might not error-out for non-pkg-developers; \
  		exit 1;							\
  	fi
***************
*** 2990,2998 ****
  .PHONY: install
  .if !target(install)
  .  if ${PKGSRC_RUN_TEST} == "YES" || ${PKGSRC_RUN_TEST} == "yes"
! install: uptodate-pkgtools build test ${INSTALL_COOKIE}
  .  else
! install: uptodate-pkgtools build ${INSTALL_COOKIE}
  .  endif
  .endif
  
--- 3195,3203 ----
  .PHONY: install
  .if !target(install)
  .  if ${PKGSRC_RUN_TEST} == "YES" || ${PKGSRC_RUN_TEST} == "yes"
! install: test uptodate-pkgtools ${INSTALL_COOKIE}
  .  else
! install: build uptodate-pkgtools ${INSTALL_COOKIE}
  .  endif
  .endif
  
***************
*** 3075,3081 ****
--- 3280,3290 ----
  tools-message:
  	@${ECHO_MSG} "${_PKGSRC_IN}> Overriding tools for ${PKGNAME}"
  buildlink-message:
+ .if !defined(USE_BUILDLINK2)
  	@${ECHO_MSG} "${_PKGSRC_IN}> Buildlinking for ${PKGNAME}"
+ .else
+ 	@${ECHO_MSG} "${_PKGSRC_IN}> Buildlinking(v2) for ${PKGNAME}"
+ .endif
  configure-message:
  	@${ECHO_MSG} "${_PKGSRC_IN}> Configuring for ${PKGNAME}"
  build-message:
***************
*** 3100,3113 ****
  test-cookie:
  	${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${TEST_COOKIE}
  
! .ORDER: pre-fetch do-fetch post-fetch
! .ORDER: extract-message install-depends pre-extract do-extract post-extract extract-cookie
! .ORDER: patch-message pre-patch do-patch post-patch patch-cookie
! .ORDER: tools-message pre-tools do-tools post-tools tools-cookie
! .ORDER: buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! .ORDER: configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
! .ORDER: build-message pre-build do-build post-build build-cookie
! .ORDER: test-message pre-test do-test post-test test-cookie
  
  # Please note that the order of the following targets is important, and
  # should not be modified (.ORDER is not recognised by make(1) in a serial
--- 3309,3322 ----
  test-cookie:
  	${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${TEST_COOKIE}
  
! .ORDER: pre-fetch do-fetch post-fetch check-extract
! .ORDER: check-extract extract-message install-depends pre-extract do-extract post-extract extract-cookie
! .ORDER: check-extract patch-message pre-patch do-patch post-patch patch-cookie
! .ORDER: check-extract tools-message pre-tools do-tools post-tools tools-cookie
! .ORDER: check-extract buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! .ORDER: check-extract configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
! .ORDER: check-extract build-message pre-build do-build post-build post-build-scripts build-cookie
! .ORDER: check-extract test-message pre-test do-test post-test test-cookie
  
  # Please note that the order of the following targets is important, and
  # should not be modified (.ORDER is not recognised by make(1) in a serial
***************
*** 3115,3133 ****
  .PHONY: real-fetch real-extract real-patch real-tools real-buildlink
  .PHONY: real-configure real-build real-test real-install real-package
  .PHONY: real-replace real-undo-replace
! real-fetch: pre-fetch do-fetch post-fetch
! real-extract: extract-message install-depends pre-extract do-extract post-extract extract-cookie
! real-patch: patch-message pre-patch do-patch post-patch patch-cookie
! real-tools: tools-message pre-tools do-tools post-tools tools-cookie
! real-buildlink: buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! real-configure: configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
! real-build: build-message pre-build do-build post-build build-cookie
! real-test: test-message pre-test do-test post-test test-cookie
! real-install: do-su-install
! real-package: do-su-package
! real-replace: do-su-replace
  real-undo-replace: do-su-undo-replace
  
  _SU_TARGET=								\
  	if [ `${ID} -u` = 0 ]; then					\
  		${MAKE} ${MAKEFLAGS} $$realtarget;			\
--- 3324,3358 ----
  .PHONY: real-fetch real-extract real-patch real-tools real-buildlink
  .PHONY: real-configure real-build real-test real-install real-package
  .PHONY: real-replace real-undo-replace
! real-fetch: pre-fetch do-fetch post-fetch check-extract
! real-extract: check-extract extract-message install-depends pre-extract do-extract post-extract extract-cookie
! real-patch: check-extract patch-message pre-patch do-patch post-patch patch-cookie
! real-tools: check-extract tools-message pre-tools do-tools post-tools tools-cookie
! real-buildlink: check-extract buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! real-configure: check-extract configure-message pre-configure pre-configure-override do-configure post-configure configure-cookie
! real-build: check-extract build-message pre-build do-build post-build post-build-scripts build-cookie
! real-test: check-extract test-message pre-test do-test post-test test-cookie
! real-install: check-extract do-su-install
! real-package: check-extract do-su-package
! real-replace: check-extract do-su-replace
  real-undo-replace: do-su-undo-replace
  
+ check-extract:
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	extractname=$$(if [ -r ${EXTRACT_COOKIE} ]; then ${CAT} ${EXTRACT_COOKIE}; else echo "_CHECK_EXTRACT_COOKIE"; fi;); \
+ 	case "$$extractname" in						\
+ 	"")	${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}"; \
+ 		${FALSE};						\
+ 		;;							\
+ 	"_CHECK_EXTRACT_COOKIE"|"${PKGNAME}")				\
+ 		: ${DO_NADA} all is well;				\
+ 		;;							\
+ 	*)	${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
+ 		${ECHO_MSG} "*** Current version ${PKGNAME} in pkgsrc directory"; \
+ 		${FALSE};						\
+ 		;;							\
+ 	esac
+ 
  _SU_TARGET=								\
  	if [ `${ID} -u` = 0 ]; then					\
  		${MAKE} ${MAKEFLAGS} $$realtarget;			\
***************
*** 3152,3168 ****
  	fi
  
  .PHONY: do-su-install
! do-su-install:
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	extractname=`${CAT} ${EXTRACT_COOKIE}`;				\
! 	case "$$extractname" in						\
! 	"")	${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}" ;; \
! 	"${PKGNAME}")	;;						\
! 	*)	${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
! 		${ECHO_MSG} "*** Current version ${PKGNAME} in pkgsrc directory"; \
! 		${ECHO_MSG} "*** Cleaning and rebuilding the newer version of the package..."; \
! 		${MAKE} clean && ${MAKE} build ;;			\
! 	esac
  	@${ECHO_MSG} "${_PKGSRC_IN}> Installing for ${PKGNAME}"
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	realtarget="real-su-install";					\
--- 3377,3383 ----
  	fi
  
  .PHONY: do-su-install
! do-su-install: 
  	@${ECHO_MSG} "${_PKGSRC_IN}> Installing for ${PKGNAME}"
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	realtarget="real-su-install";					\
***************
*** 3195,3201 ****
  
  # Empty pre-* and post-* targets
  
! .for name in fetch extract patch tools buildlink configure build test install-script install package
  
  .  if !target(pre-${name})
  pre-${name}:
--- 3410,3416 ----
  
  # Empty pre-* and post-* targets
  
! .for name in fetch extract patch tools buildlink configure build-scripts build test install-script install package
  
  .  if !target(pre-${name})
  pre-${name}:
***************
*** 3209,3214 ****
--- 3424,3448 ----
  
  .endfor
  
+ # Makepatch
+ #
+ # Special target to create/update patches
+ 
+ .if !target(makepatches)
+ makepatches:
+ 	@${ECHO_MSG} "${_PKGSRC_IN}> Creating a whole new set of ${OPSYS} patches for ${PKGNAME}"
+ 	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f patches/patch-${OPSYS}
+ 	${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} patches/patch-${OPSYS}
+ 	${_PKG_SILENT}${_PKG_DEBUG}cd ${WRKSRC};			\
+ 		${FIND} . -name '*.orig' -print |			\
+ 			while read ORIG_FILE ; do			\
+ 				set +e;					\
+ 				${DIFF} ${MAKEPATCH_DIFF_ARGS} $${ORIG_FILE} $$(dirname $${ORIG_FILE})/$$(basename $${ORIG_FILE} .orig) >> ${.CURDIR}/patches/patch-${OPSYS}; \
+ 				set -e;					\
+ 			done
+ 	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} makepatchsum
+ .endif
+ 
  # Reinstall
  #
  # Special target to re-run install
***************
*** 3513,3522 ****
  		fi;							\
  	fi
  .  ifdef WRKOBJDIR
! 	-${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${RMDIR} ${BUILD_DIR} 2>/dev/null;				\
! 	${RM} -f ${WRKDIR_BASENAME}
  .  endif
  .endif
  
  
--- 3747,3755 ----
  		fi;							\
  	fi
  .  ifdef WRKOBJDIR
! 	-${_PKG_SILENT}${_PKG_DEBUG}${RMDIR} ${BUILD_DIR} 2>/dev/null;
  .  endif
+ 	-${_PKG_SILENT}${_PKG_DEBUG}${RM} -f README.html
  .endif
  
  
***************
*** 3558,3564 ****
  .  if defined(DIST_SUBDIR) && exists(DIST_SUBDIR)
  	-${_PKG_SILENT}${_PKG_DEBUG}${RMDIR} ${_DISTDIR}
  .  endif
- 	-${_PKG_SILENT}${_PKG_DEBUG}${RM} -f README.html
  .endif
  
  # Prints out a script to fetch all needed files (no checksumming).
--- 3791,3796 ----
***************
*** 3593,3598 ****
--- 3825,3831 ----
  				print block[line] }			\
  		')							\
  	done
+ # ' emacs closure
  .endif # !target(fetch-list-recursive)
  
  .PHONY: fetch-list-one-pkg
***************
*** 3708,3714 ****
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	newfile=${DISTINFO_FILE}.$$$$;					\
  	if [ -f ${DISTINFO_FILE} ]; then				\
! 		${AWK} '$$2 !~ /\(patch-[a-z0-9]+\)/ { print $$0 }' < ${DISTINFO_FILE} >> $$newfile; \
  	else \
  		${ECHO} -n "$$" > $$newfile;				\
  		${ECHO} -n "NetBSD" >> $$newfile; 			\
--- 3941,3947 ----
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	newfile=${DISTINFO_FILE}.$$$$;					\
  	if [ -f ${DISTINFO_FILE} ]; then				\
! 		${AWK} '$$2 !~ /(patch-[-A-z0-9]+)/ { print $$0 }' < ${DISTINFO_FILE} >> $$newfile; \
  	else \
  		${ECHO} -n "$$" > $$newfile;				\
  		${ECHO} -n "NetBSD" >> $$newfile; 			\
***************
*** 3882,3888 ****
  # If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible)
  PACKAGE_DEPENDS_WITH_PATTERNS?=true
  # To be used (-> true) ONLY if the pkg in question is known to be installed
! # (i.e. when calling for pkg_create args, and for fake-pkg)
  # Will probably not work with PACKAGE_DEPENDS_WITH_PATTERNS=false ...
  PACKAGE_DEPENDS_QUICK?=false
  .PHONY: run-depends-list
--- 4115,4121 ----
  # If PACKAGE_DEPENDS_WITH_PATTERNS is set, print as pattern (if possible)
  PACKAGE_DEPENDS_WITH_PATTERNS?=true
  # To be used (-> true) ONLY if the pkg in question is known to be installed
! # (i.e. when calling for pkg_create args, and for register-pkg)
  # Will probably not work with PACKAGE_DEPENDS_WITH_PATTERNS=false ...
  PACKAGE_DEPENDS_QUICK?=false
  .PHONY: run-depends-list
***************
*** 3938,3943 ****
--- 4171,4202 ----
  # Dependency checking
  ################################################################
  
+ _QUOTED_BUILD_DEPENDS=
+ .for dep in ${BUILD_DEPENDS}
+ _QUOTED_BUILD_DEPENDS+=	${dep:Q}
+ .endfor
+ 
+ .PHONY: show-install-depends
+ .if !target(show-install-depends)
+ show-install-depends:
+ . if defined(DEPENDS) || defined(BUILD_DEPENDS)
+ .  if defined(NO_DEPENDS)
+ 	@${DO_NADA}
+ .  else # !NO_DEPENDS
+ .   for dep in ${DEPENDS} ${BUILD_DEPENDS}
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	pkg_type="runtime";						\
+ 	for bpkg in ${_QUOTED_BUILD_DEPENDS} ; do			\
+ 		if [ '${dep}' = "$${bpkg}" ] ; then			\
+ 			pkg_type="build-only";				\
+ 		fi;							\
+ 	done;								\
+ 	${ECHO_MSG} "=====> $${pkg_type} :	'${dep}'"
+ .   endfor
+ .  endif # NO_DEPENDS
+ . endif # DEPENDS || BUILD_DEPENDS
+ .endif # target
+ 
  .PHONY: install-depends
  .if !target(install-depends)
  # Tells whether to halt execution if the object formats differ
***************
*** 3954,3963 ****
  	pkg="${dep:C/:.*//}";						\
  	dir="${dep:C/[^:]*://:C/:.*$//}";				\
  	found=`${PKG_BEST_EXISTS} "$$pkg" || ${TRUE}`;			\
  	if [ "X$$REBUILD_DOWNLEVEL_DEPENDS" != "X" ]; then		\
- 		pkgname=`cd $$dir ; ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKGNAME`; \
  		if [ "X$$found" != "X" -a "X$$found" != "X$${pkgname}" ]; then \
! 			${ECHO_MSG} "ignoring old installed package \"$$found\""; \
  			found="";					\
  		fi;							\
  	fi;								\
--- 4213,4228 ----
  	pkg="${dep:C/:.*//}";						\
  	dir="${dep:C/[^:]*://:C/:.*$//}";				\
  	found=`${PKG_BEST_EXISTS} "$$pkg" || ${TRUE}`;			\
+ 	pkgname=`cd $$dir && ${MAKE} ${MAKEFLAGS} show-var VARNAME=PKGNAME`; \
+ 	pkg_type="runtime";						\
+ 	for bpkg in ${_QUOTED_BUILD_DEPENDS} ; do			\
+ 		if [ '${dep}' = "$${bpkg}" ] ; then			\
+ 			pkg_type="build-only";				\
+ 		fi;							\
+ 	done;								\
  	if [ "X$$REBUILD_DOWNLEVEL_DEPENDS" != "X" ]; then		\
  		if [ "X$$found" != "X" -a "X$$found" != "X$${pkgname}" ]; then \
! 			${ECHO_MSG} "NOTICE:  ignoring old installed $${pkg_type} package \"$$found\"";	\
  			found="";					\
  		fi;							\
  	fi;								\
***************
*** 3975,3990 ****
  				exit 1;					\
  			fi;						\
  		fi;							\
! 		${ECHO_MSG} "${_PKGSRC_IN}> Required installed package $$pkg: $${found} found"; \
  	else								\
! 		${ECHO_MSG} "${_PKGSRC_IN}> Required package $$pkg: NOT found"; \
  		target=${DEPENDS_TARGET};				\
! 		${ECHO_MSG} "${_PKGSRC_IN}> Verifying $$target for $$dir"; 	\
  		if [ ! -d $$dir ]; then					\
! 			${ECHO_MSG} "=> No directory for $$dir.  Skipping.."; \
  		else							\
  			cd $$dir ;					\
! 			${MAKE} ${MAKEFLAGS} $$target _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$$pkg"; \
  			${ECHO_MSG} "${_PKGSRC_IN}> Returning to build of ${PKGNAME}"; \
  		fi;							\
  	fi
--- 4240,4277 ----
  				exit 1;					\
  			fi;						\
  		fi;							\
! 		if [ `${ECHO} $$found | ${WC} -w` -gt 1 ]; then	\
! 			${ECHO} '***' "WARNING:  Dependency on '$$pkg' expands to several installed packages " ; \
! 			${ECHO} "    (" `${ECHO} $$found` ")." ; 	\
! 			${ECHO} "    Please check if this is really intended!" ; \
! 			sleep 2 ;					\
! 		else 							\
! 			if [ "X$$found" != "X" -a "X$$found" != "X$${pkgname}" ]; then \
! 				case "${ALLOW_DOWNLEVEL_DEPENDS}" in	\
! 				[Nn][Oo])				\
! 					${ECHO_MSG} "${_PKGSRC_IN}==> ERROR:  $$found needs upgrade -> $$pkgname" ; \
! 					exit 1 ;			\
! 					;;				\
! 				*)					\
! 					${ECHO_MSG} "${_PKGSRC_IN}==> WARNING:  $$found should be upgraded -> $$pkgname" ; \
! 					;;				\
! 				esac ; 					\
! 			fi ; 						\
! 			${ECHO_MSG} "${_PKGSRC_IN}> Required $${pkg_type} package $${found} installed OK (need $${pkg})"; \
! 		fi ; 							\
  	else								\
! 		${ECHO_MSG} "${_PKGSRC_IN}> Required $${pkg_type} package NOT found: $${pkg}"; \
  		target=${DEPENDS_TARGET};				\
! 		${ECHO_MSG} "${_PKGSRC_IN}> Attempting '$${target}' for $${pkg} in $${dir}"; \
  		if [ ! -d $$dir ]; then					\
! 			${ECHO_MSG} "=> No directory '$${dir}' for $${pkg}.  Skipping...."; \
  		else							\
  			cd $$dir ;					\
! 			if [ -f ${EXTRACT_COOKIE} ]; then		\
! 				${ECHO_MSG} "${_PKGSRC_IN}> WARNING!!!  Starting with unclean work directory for $${target}"; \
! 				sleep 2 ;				\
! 			fi ;						\
! 			${MAKE} ${MAKEFLAGS} $$target _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$${pkg}"; \
  			${ECHO_MSG} "${_PKGSRC_IN}> Returning to build of ${PKGNAME}"; \
  		fi;							\
  	fi
***************
*** 4012,4017 ****
--- 4299,4307 ----
  .PHONY: binpkg-list
  .if !target(binpkg-list)
  binpkg-list:
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	${ECHO} "<TR><TD>${MACHINE_ARCH}:<TD><a href=\"${PKGNAME}${PKG_SUFX}\">${PKGNAME}</a><TD>(${OPSYS} ${OS_VERSION})</TR>"; \
+ 	exit 0
  	@if [ -e ${PACKAGES} ]; then					\
  		cd ${PACKAGES};						\
  		case ${.CURDIR} in					\
***************
*** 4060,4065 ****
--- 4350,4356 ----
  			;;						\
  		esac;							\
  	fi
+ # ' emacs closure
  .endif
  
  ################################################################
***************
*** 4161,4166 ****
--- 4452,4458 ----
  			${PKGVULNDIR}/pkg-vulnerabilities;			\
  	fi
  
+ # ' emacs closure
  
  # If PACKAGES is set to the default (../../packages), the current
  # ${MACHINE_ARCH} and "release" (uname -r) will be used. Otherwise a directory
***************
*** 4210,4224 ****
--- 4502,4580 ----
  # i.e. "make show-var VARNAME=var", will print var's value
  .PHONY: show-var
  show-var:
+ .if defined(${VARNAME})
  	@${ECHO} ${${VARNAME}:Q}
+ .else
+ 	@${ECHO} "${MAKE}: ${VARNAME} is not defined."
+ .endif
  
  # enhanced version of target above, to display multiple variables
  .PHONY: show-vars
  show-vars:
  .for VARNAME in ${VARNAMES}
+ . if defined(${VARNAME})
  	@${ECHO} ${${VARNAME}:Q}
+ . else
+ 	@${ECHO} "${MAKE}: ${VARNAME} is not defined."
+ . endif
  .endfor
  
+ .PHONY: su-show-var
+ su-show-var:
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	realtarget="show-var";						\
+ 	realflags="VARNAME=${VARNAME}";					\
+ 	action="show-var";						\
+ 	${_SU_TARGET} 
+ 
+ .PHONY: show-pkg_sysconf
+ show-pkg_sysconf:
+ 	@${ECHO} PKGBASE=${PKGBASE}
+ 	@${ECHO} PKG_SYSCONFBASE=${PKG_SYSCONFBASE}
+ 	@${ECHO} PKG_SYSCONFSUBDIR=${PKG_SYSCONFSUBDIR}
+ 	@${ECHO} PKG_SYSCONFDIR.ssh2=${PKG_SYSCONFDIR.ssh2}
+ 	@${ECHO} PKG_SYSCONFDIR=${PKG_SYSCONFDIR}
+ 
+ .PHONY: check-for-base-clashes
+ check-for-base-clashes:
+ .if ${LOCALBASE} != "/usr"
+ 	@${ECHO} '${_PKGSRC_IN} Checking for clashes with base system files...'
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	clashes=`${MAKE} ${MAKEFLAGS} show-base-clashes`; 		\
+ 	if [ -n "$$clashes" ] ; then					\
+ 		${ECHO} 'This package installs files which clash with the following base system files:'; \
+ 		${ECHO} '';						\
+ 		for file in $$clashes; do				\
+ 			${ECHO} "	$$file";			\
+ 		done;							\
+ 		${ECHO} '';						\
+ 		${ECHO} 'You will overwrite those files if you build it on systems with LOCALBASE=/usr'; \
+ 		${FALSE};						\
+ 	fi
+ .else
+ 	@${ECHO} '${_PKGSRC_IN} Not possible to check for clashes with base system files: LOCALBASE == /usr.'
+ .endif
+ 
+ # This could depend on ${INSTALL_COOKIE}, but doing so would make it
+ # impossible to run the check after doing "make install && make clean"
+ #
+ .PHONY: show-base-clashes
+ show-base-clashes:
+ .if ${LOCALBASE} != "/usr"
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	${PKG_INFO} -L ${PKGNAME} |					\
+ 		sed -e 's|${LOCALBASE}|/usr|' 				\
+ 		    -e 's|/usr/info|/usr/share/info|'			\
+ 		    -e 's|/usr/man|/usr/share/man|' |			\
+ 		while read file ; do					\
+ 			if [ -f "$$file" ]; then			\
+ 				${ECHO} $$file;				\
+ 			fi						\
+ 		done
+ .else
+ 	@${DO_NADA}
+ .endif
+ 
  .PHONY: print-build-depends-list
  .if !target(print-build-depends-list)
  print-build-depends-list:
***************
*** 4305,4310 ****
--- 4661,4668 ----
  		  END { print("p"); }'					\
  	| ${DC}
  
+ # ' emacs closure
+ 
  # Sizes of required pkgs (only)
  #
  # XXX This is intended to be run before pkg_create is called, so the
***************
*** 4375,4380 ****
--- 4733,4739 ----
  		} 							\
  		END { print "{ print $$$$0; }"; }			\
  	' <${MTREE_FILE}
+ # ' emacs closure
  .endif
  
  
***************
*** 4463,4475 ****
  
  PKGVIEWS+=	${DEFAULT_VIEW.${PKGBASE}}
  
! # Fake installation of package so that user can pkg_delete it later.
  # Also, make sure that an installed package is recognized correctly in
  # accordance to the @pkgdep directive in the packing lists.
! 
! .PHONY: fake-pkg
! .if !target(fake-pkg)
! fake-pkg: ${PLIST} ${DESCR} ${MESSAGE}
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	if [ ! -f ${PLIST} -o ! -f ${DESCR} ]; then			\
  		${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \
--- 4822,4838 ----
  
  PKGVIEWS+=	${DEFAULT_VIEW.${PKGBASE}}
  
! # Register the installation of the package so that can be pkg_delete'd.
! # 
  # Also, make sure that an installed package is recognized correctly in
  # accordance to the @pkgdep directive in the packing lists.
! # 
! # Finally check for known vulnerabilies if the vulnerabilities file is
! # available.
! 
! .PHONY: register-pkg
! .if !target(register-pkg)
! register-pkg: ${PLIST} ${DESCR} ${MESSAGE}
  	${_PKG_SILENT}${_PKG_DEBUG}					\
  	if [ ! -f ${PLIST} -o ! -f ${DESCR} ]; then			\
  		${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; \
***************
*** 4481,4489 ****
  		${MKDIR} ${_PKG_DBDIR};					\
  	fi
  .  if defined(FORCE_PKG_REGISTER)
  	${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} delete ${PKGNAME}
  .    if ${PKG_INSTALLATION_TYPE} == "overwrite"
! 	${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${_PKG_DBDIR}/${PKGNAME}
  .    endif
  .  endif
  	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE}
--- 4844,4856 ----
  		${MKDIR} ${_PKG_DBDIR};					\
  	fi
  .  if defined(FORCE_PKG_REGISTER)
+ 	${_PKG_SILENT}${_PKG_DEBUG}\
+ 	if [ -f ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY ] ; then		\
+ 		${CP} ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY ${WRKDIR}/.+REQUIRED_BY; \
+ 	fi
  	${_PKG_SILENT}${_PKG_DEBUG}${PKG_ADMIN} delete ${PKGNAME}
  .    if ${PKG_INSTALLATION_TYPE} == "overwrite"
! 	${_PKG_SILENT}${_PKG_DEBUG}${RM} -rf ${PKG_DBDIR}/${PKGNAME}
  .    endif
  .  endif
  	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILD_VERSION_FILE} ${BUILD_INFO_FILE}
***************
*** 4577,4588 ****
  	case $$doit in							\
  	yes)								\
  		${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \
! 		${MKDIR} ${_PKG_DBDIR}/${PKGNAME};			\
! 		${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${_PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
! 		${CP} ${DESCR} ${_PKG_DBDIR}/${PKGNAME}/+DESC;	\
! 		${ECHO} ${COMMENT:Q} > ${_PKG_DBDIR}/${PKGNAME}/+COMMENT; \
! 		${CP} ${BUILD_VERSION_FILE} ${_PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \
! 		${CP} ${BUILD_INFO_FILE} ${_PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \
  		if ${TEST} -e ${SIZE_PKG_FILE}; then 			\
  			${CP} ${SIZE_PKG_FILE} ${_PKG_DBDIR}/${PKGNAME}/+SIZE_PKG; \
  		fi ; 							\
--- 4944,4958 ----
  	case $$doit in							\
  	yes)								\
  		${ECHO_MSG} "${_PKGSRC_IN}> Registering installation for ${PKGNAME}"; \
! 		${MKDIR} ${PKG_DBDIR}/${PKGNAME};			\
! 		${PKG_CREATE} ${PKG_ARGS_INSTALL} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
! 		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC;		\
! 		${ECHO} ${COMMENT:Q} > ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
! 		${CP} ${BUILD_VERSION_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \
! 		${CP} ${BUILD_INFO_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \
! 		if [ -f ${WRKDIR}/.+REQUIRED_BY ] ; then		\
! 			${CP} ${WRKDIR}/.+REQUIRED_BY ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY; \
! 		fi;							\
  		if ${TEST} -e ${SIZE_PKG_FILE}; then 			\
  			${CP} ${SIZE_PKG_FILE} ${_PKG_DBDIR}/${PKGNAME}/+SIZE_PKG; \
  		fi ; 							\
***************
*** 4592,4597 ****
--- 4962,4972 ----
  		if ${TEST} -e ${PRESERVE_FILE}; then 			\
  			${CP} ${PRESERVE_FILE} ${_PKG_DBDIR}/${PKGNAME}/+PRESERVE; \
  		fi ; 							\
+ 		if [ -n "${REQUIRE_FILE}" ]; then			\
+ 			if ${TEST} -e ${REQUIRE_FILE}; then		\
+ 				${CP} ${REQUIRE_FILE} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
+ 			fi;						\
+ 		fi;							\
  		if [ "${PKG_INSTALLATION_TYPE}" = "pkgviews" ]; then	\
  			${TOUCH} ${_PKG_DBDIR}/${PKGNAME}/+VIEWS;	\
  		fi ;							\
***************
*** 4605,4610 ****
--- 4980,4990 ----
  				${CP} ${DEINSTALL_FILE} ${_PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
  			fi;						\
  		fi;							\
+ 		if [ -n "${MTREE_FILE}" ]; then				\
+ 			if ${TEST} -e ${MTREE_FILE}; then		\
+ 				${CP} ${MTREE_FILE} ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS; \
+ 			fi;						\
+ 		fi;							\
  		if [ -n "${MESSAGE}" ]; then				\
  			if ${TEST} -e ${MESSAGE}; then			\
  				${CP} ${MESSAGE} ${_PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
***************
*** 4627,4638 ****
  				${ECHO} "${PKGNAME} requires installed package $$realdep"; \
  			fi;						\
  		done ;;							\
  	esac
  .  if (${PKG_INSTALLATION_TYPE} == "pkgviews") && \
        !empty(BUILD_VIEWS:M[yY][eE][sS])
  	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} build-views
  .  endif	# pkgviews
! .endif		# !fake-pkg
  
  .PHONY: build-views
  build-views: do-su-build-views
--- 5007,5020 ----
  				${ECHO} "${PKGNAME} requires installed package $$realdep"; \
  			fi;						\
  		done ;;							\
+ 	*)								\
+ 		${ECHO_MSG} '*** WARNING: ${PKG_DBDIR}/${PKGNAME} already exists!!!!' ;; \
  	esac
  .  if (${PKG_INSTALLATION_TYPE} == "pkgviews") && \
        !empty(BUILD_VIEWS:M[yY][eE][sS])
  	${_PKG_SILENT}${_PKG_DEBUG}${MAKE} ${MAKEFLAGS} build-views
  .  endif	# pkgviews
! .endif		# !register-pkg
  
  .PHONY: build-views
  build-views: do-su-build-views
***************
*** 4763,4768 ****
--- 5145,5151 ----
  		$$0 = sprintf("%s.gz", $$0);				\
  	}								\
  	{ print $$0; }' |
+ # ' emacs closure
  .  else
  _MANZ_NAWK_CMD=	${AWK} '/^([^\/]*\/)*man\/([^\/]*\/)?man[1-9ln]\/.*[1-9ln]\.gz$$/ { \
  		$$0 = substr($$0, 1, length($$0) - 3);			\
***************
*** 4771,4776 ****
--- 5154,5160 ----
  		$$0 = substr($$0, 1, length($$0) - 3);			\
  	}								\
  	{ print $$0; }' |
+ # ' emacs closure
  .  endif # MANZ
  .endif
  
***************
*** 4782,4787 ****
--- 5166,5172 ----
  		if (!"${MANINSTALL:Mcatinstall}" && 			\
  				match($$0, start "cat" end)) {next;}	\
  		print $$0; }' |
+ # ' emacs closure
  
  .if defined(USE_IMAKE) && ${_PREFORMATTED_MAN_DIR} == "man"
  _IMAKE_MAN_CMD=	${AWK} '/^([^\/]*\/)*man\/([^\/]*\/)?cat[1-9ln]\/.*0(\.gz)?$$/ { \
***************
*** 4791,4797 ****
  	if (match($$0, "\.gz$$") > 0) { ext = ".gz";} else { ext = "";} \
  	$$0 = sprintf("%s%s", s, ext);					\
  	} { print $$0; }' |
! .  else
  _IMAKE_MAN_CMD=
  .endif # USE_IMAKE
  
--- 5176,5183 ----
  	if (match($$0, "\.gz$$") > 0) { ext = ".gz";} else { ext = "";} \
  	$$0 = sprintf("%s%s", s, ext);					\
  	} { print $$0; }' |
! # ' emacs closure
! .else
  _IMAKE_MAN_CMD=
  .endif # USE_IMAKE
  
***************
*** 4883,4889 ****
  	@\
  	${ECHO}			>>${DESCR} ; \
  	${ECHO} "Homepage:"	>>${DESCR} ; \
! 	${ECHO} '${HOMEPAGE}'	>>${DESCR}	
  .endif
  
  .include "../../mk/subst.mk"
--- 5269,5275 ----
  	@\
  	${ECHO}			>>${DESCR} ; \
  	${ECHO} "Homepage:"	>>${DESCR} ; \
! 	${ECHO} '${HOMEPAGE}'	>>${DESCR}
  .endif
  
  .include "../../mk/subst.mk"
>Release-Note:
>Audit-Trail:
>Unformatted: