Index: Mk/Scripts/do-depends.sh
===================================================================
--- Mk/Scripts/do-depends.sh
+++ Mk/Scripts/do-depends.sh
@@ -141,6 +141,11 @@
 		export FLAVOR="${origin##*@}"
 		origin=${origin%@*}
 		;;
+	*~*/*)	;; # Ignore ~ in the path which would not be a subpackage
+	*~*)
+		subpkg=${origin##*~}
+		origin=${origin%~*}
+		;;
 	esac
 
 	depends_args="${dp_DEPENDS_ARGS}"
Index: Mk/Scripts/functions.sh
===================================================================
--- Mk/Scripts/functions.sh
+++ Mk/Scripts/functions.sh
@@ -7,7 +7,8 @@
 # Strip (owner,group,perm) from keywords
 _strip_perms() {
 	sed -Ee 's/^@\([^)]*\)[[:space:]]+//' \
-	    -e 's/^(@[[:alpha:]]+)\([^)]*\)[[:space:]]+/\1 /'
+	    -e 's/^(@[[:alpha:]]+)\([^)]*\)[[:space:]]+/\1 /' \
+	    -e 's/^@@[[:alnum:]]+@@//'
 }
 
 # Expand TMPPLIST to absolute paths, splitting files and dirs into separate
Index: Mk/bsd.options.mk
===================================================================
--- Mk/bsd.options.mk
+++ Mk/bsd.options.mk
@@ -457,6 +457,20 @@
 _OPTIONS_${target}?=
 .endfor
 
+# Handle subpackages before the rest to be able to handle options helpers with
+# subpackages.
+.for opt in ${_REALLY_ALL_POSSIBLE_OPTIONS}
+.  if ${PORT_OPTIONS:M${opt}}
+.    if defined(${opt}_SUBPACKAGES)
+SUBPACKAGES+=	${${opt}_SUBPACKAGES}
+.    endif
+.  else
+.    if defined(${opt}_SUBPACKAGES_OFF)
+SUBPACKAGES+=	${${opt}_SUBPACKAGES_OFF}
+.    endif
+.  endif
+.endfor
+
 .for opt in ${_REALLY_ALL_POSSIBLE_OPTIONS}
 # PLIST_SUB
 PLIST_SUB?=
@@ -542,6 +556,11 @@
 .      if defined(${opt}_${deptype}_DEPENDS)
 ${deptype}_DEPENDS+=	${${opt}_${deptype}_DEPENDS}
 .      endif
+.      for p in ${SUBPACKAGES}
+.        if defined(${opt}_${deptype}_DEPENDS.${p})
+${deptype}_DEPENDS.${p}+=	${${opt}_${deptype}_DEPENDS.${p}}
+.        endif
+.      endfor
 .    endfor
 .    for target in ${_OPTIONS_TARGETS}
 _target=	${target:C/:.*//}
@@ -613,6 +632,11 @@
 .      if defined(${opt}_${deptype}_DEPENDS_OFF)
 ${deptype}_DEPENDS+=	${${opt}_${deptype}_DEPENDS_OFF}
 .      endif
+.      for p in ${SUBPACKAGES}
+.        if defined(${opt}_${deptype}_DEPENDS_OFF.${p})
+${deptype}_DEPENDS.${p}+=	${${opt}_${deptype}_DEPENDS_OFF.${p}}
+.        endif
+.      endfor
 .    endfor
 .    for target in ${_OPTIONS_TARGETS}
 _target=	${target:C/:.*//}
Index: Mk/bsd.port.mk
===================================================================
--- Mk/bsd.port.mk
+++ Mk/bsd.port.mk
@@ -2196,6 +2196,7 @@
 _PKGMESSAGES+=	${PKGMESSAGE}
 
 TMPPLIST?=	${WRKDIR}/.PLIST.mktmp
+_PLIST?=	${WRKDIR}/.PLIST
 
 .if defined(PKG_NOCOMPRESS)
 PKG_SUFX?=		.tar
@@ -2583,20 +2584,70 @@
 
 PKGREPOSITORYSUBDIR?=	All
 PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
-.if exists(${PACKAGES})
-PACKAGES:=	${PACKAGES:S/:/\:/g}
-_HAVE_PACKAGES=	yes
-PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
-.else
-PKGFILE?=		${.CURDIR}/${PKGNAME}${PKG_SUFX}
-.endif
-WRKDIR_PKGFILE=	${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX}
 
 # The "latest version" link -- ${PKGNAME} minus everthing after the last '-'
 PKGLATESTREPOSITORY?=	${PACKAGES}/Latest
 PKGBASE?=			${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
 PKGLATESTFILE=		${PKGLATESTREPOSITORY}/${PKGBASE}${PKG_SUFX}
 
+_PKGS=	${PKGBASE}
+PORTS_FEATURES+=		SUBPACKAGES
+.if defined(SUBPACKAGES)
+.  if ${SUBPACKAGES:Mmain}
+DEV_ERROR+=		"SUBPACKAGES cannot contain 'main', it is a reserved value"
+.  endif
+.  for f in ${SUBPACKAGES}
+.    if ${f:C/[[:lower:][:digit:]_]//g}
+_BAD_SUBPACKAGE_NAMES+=		${f}
+.    endif
+.  endfor
+.  if !empty(_BAD_SUBPACKAGE_NAMES)
+DEV_ERROR+=		"SUBPACKAGES contains subpackages that are not all [a-z0-9_]: ${_BAD_SUBPACKAGE_NAMES}"
+.  endif
+.endif
+.for p in ${SUBPACKAGES}
+_PKGS+=	${PKGBASE}-${p}
+_P.${PKGBASE}-${p}= .${p}
+.endfor
+
+.if !defined(_DID_SUBPACKAGES_HELPERS)
+_DID_SUBPACKAGES_HELPERS=	yes
+_SUBPACKAGE_HELPERS_FILE=	DESCR PKGINSTALL PKGDEINSTALL PKGMESSAGE \
+			PKGPREINSTALL PKGPOSTINSTALL PKGPREDEINSTALL PKGPOSTDEINSTALL \
+			PKGPREUPGRADE PKGPOSTUPGRADE PKGUPGRADE
+
+. for p in ${SUBPACKAGES}
+# These overwrite the current value
+.  for v in ${_SUBPACKAGE_HELPERS_FILE}
+${v}.${p}?=	${$v}.$p
+.  endfor
+_PKGMESSAGES.${p}=		${PKGMESSAGE}.${p}
+# XXX: for testing, and maybe kept afterwards
+.  if !exists(${DESCR.${p}})
+DESCR.${p}=		${DESCR}
+DEV_WARNING+=	"DESCR.${p} needs to point to an existing file."
+.  endif
+# XXX: Thoughts?
+COMMENT.${p}?=	${COMMENT} (subpkg: ${p})
+. endfor
+.endif
+
+
+.if exists(${PACKAGES})
+-PACKAGES:=	${PACKAGES:S/:/\:/g}
+_HAVE_PACKAGES=	yes
+_PKGDIR=	${PKGREPOSITORY}
+.else
+_PKGDIR=	${.CURDIR}
+.endif
+.  for p in ${_PKGS}
+PKGFILE${_P.${p}}=	${_PKGDIR}/${p}-${PKGVERSION}${PKG_SUFX}
+.  endfor
+_EXTRA_PACKAGE_TARGET_DEP+=	${_PKGDIR}
+.for p in ${_PKGS}
+WRKDIR_PKGFILE${_P.${p}}=	${WRKDIR}/pkg/${p}-${PKGVERSION}${PKG_SUFX}
+.endfor
+
 CONFIGURE_SCRIPT?=	configure
 CONFIGURE_CMD?=		./${CONFIGURE_SCRIPT}
 CONFIGURE_TARGET?=	${HOSTARCH}-portbld-${OPSYS:tl}${OSREL}
@@ -3371,10 +3422,6 @@
 _EXTRA_PACKAGE_TARGET_DEP+= ${PKGFILE}
 _PORTS_DIRECTORIES+=	${PKGREPOSITORY}
 
-${PKGFILE}: ${WRKDIR_PKGFILE} ${PKGREPOSITORY}
-	@${LN} -f ${WRKDIR_PKGFILE} ${PKGFILE} 2>/dev/null \
-			|| ${CP} -f ${WRKDIR_PKGFILE} ${PKGFILE}
-
 .  if ${PKGORIGIN} == "ports-mgmt/pkg" || ${PKGORIGIN} == "ports-mgmt/pkg-devel"
 _EXTRA_PACKAGE_TARGET_DEP+=	${PKGLATESTREPOSITORY}
 _PORTS_DIRECTORIES+=	${PKGLATESTREPOSITORY}
@@ -3386,16 +3433,29 @@
 
 .endif
 
-# from here this will become a loop for subpackages
-${WRKDIR_PKGFILE}: ${TMPPLIST} create-manifest ${WRKDIR}/pkg
-	@if ! ${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CREATE} ${PKG_CREATE_ARGS} -m ${METADIR} -p ${TMPPLIST} -f ${PKG_SUFX:S/.//} -o ${WRKDIR}/pkg ${PKGNAME}; then \
+.for p in ${_PKGS}
+${_PLIST}.${p}: ${TMPPLIST}
+	@if [ "${PKGBASE}" = "${p}" ]; then \
+		${GREP} -Fv -e"@comment " -e"@@" ${TMPPLIST} > ${.TARGET} ; \
+	else \
+		${SED} -n "s/@@${p:S/${PKGBASE}-//}@@//p" ${TMPPLIST} > ${.TARGET} ; \
+	fi
+
+${WRKDIR_PKGFILE${_P.${p}}}: ${_PLIST}.${p} create-manifest.${p} ${WRKDIR}/pkg
+	@echo "===>    Building ${p}-${PKGVERSION}"
+	@if ! ${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_CREATE} ${PKG_CREATE_ARGS} -m ${METADIR}.${p} -p ${_PLIST}.${p} -f ${PKG_SUFX:S/.//} -o ${WRKDIR}/pkg ${PKGNAME}; then \
 		cd ${.CURDIR} && eval ${MAKE} delete-package >/dev/null; \
 		exit 1; \
 	fi
-	#
-# Temporary will be later dynamically added per subpackages
-_EXTRA_PACKAGE_TARGET_DEP+=	${WRKDIR_PKGFILE}
-# This will be the end of the loop
+
+_EXTRA_PACKAGE_TARGET_DEP+=	${WRKDIR_PKGFILE${_P.${p}}}
+
+${PKGFILE${_P.${p}}}: ${WRKDIR_PKGFILE${_P.${p}}}
+	@${LN} -f ${WRKDIR_PKGFILE${_P.${p}}} ${PKGFILE${_P.${p}}} 2>/dev/null \
+		|| ${CP} -f ${WRKDIR_PKGFILE${_P.${p}}} ${PKGFILE${_P.${p}}}
+
+_EXTRA_PACKAGE_TARGET_DEP+=	${PKGFILE${_P.${p}}}
+.endfor
 
 .if !target(do-package)
 PKG_CREATE_ARGS=	-r ${STAGEDIR}
@@ -3407,14 +3467,18 @@
 
 .if !target(delete-package)
 delete-package:
-	@${ECHO_MSG} "===>  Deleting package for ${PKGNAME}"
+. for p in ${_PKGS}
+	@${ECHO_MSG} "===>  Deleting package for ${p}"
 # When staging, the package may only be in the workdir if not root
-	@${RM} ${PKGFILE} ${WRKDIR_PKGFILE} 2>/dev/null || :
+	@${RM} ${PKGFILE${_P.${p}}} ${WRKDIR_PKGFILE${_P.${p}}} 2>/dev/null || :
+. endfor
 .endif
 
 .if !target(delete-package-list)
 delete-package-list:
-	@${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} ${PKGFILE})"
+. for p in ${_PKGS}
+	@${ECHO_CMD} "[ -f ${PKGFILE${_P.${p}}} ] && (${ECHO_CMD} deleting ${PKGFILE${_P.${p}}}; ${RM} ${PKGFILE${_P.${p}}})"
+. endfor
 .endif
 
 # Used by scripts and users to install a package from local repository.
@@ -3426,13 +3490,16 @@
 .if defined(INSTALLS_DEPENDS)
 _INSTALL_PKG_ARGS+=	-A
 .endif
-install-package:
-	@if [ -f "${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX}" ]; then \
-	    _pkgfile="${WRKDIR_PKGFILE}"; \
+.for p in ${_PKGS}
+install-package: install-package.${p}
+install-package.${p}:
+	@if [ -f "${WRKDIR_PKGFILE${_P.${p}}}" ]; then \
+	    _pkgfile="${WRKDIR_PKGFILE${_P.${p}}}"; \
 	else \
-	    _pkgfile="${PKGFILE}"; \
+	    _pkgfile="${PKGFILE${_P.${p}}}"; \
 	fi; \
 	${PKG_ADD} ${_INSTALL_PKG_ARGS} $${_pkgfile}
+.endfor
 .endif
 
 
@@ -3621,7 +3688,7 @@
 test-message:
 	@${ECHO_MSG} "===>  Testing for ${PKGNAME}"
 package-message:
-	@${ECHO_MSG} "===>  Building package for ${PKGNAME}"
+	@${ECHO_MSG} "===>  Building packages for ${PKGNAME}"
 
 # Empty pre-* and post-* targets
 
@@ -3692,14 +3759,16 @@
 		${SU_CMD} "${MAKE} ${.TARGET}"
 	@${ECHO_MSG} "===>  Returning to user credentials"
 .else
-	@${ECHO_MSG} "===>  Deinstalling for ${PKGBASE}"
-	@if ${PKG_INFO} -e ${PKGBASE}; then \
-		p=`${PKG_INFO} -q -O ${PKGBASE}`; \
+.for _p in ${_PKGS}
+	@${ECHO_MSG} "===>  Deinstalling for ${_p}"
+	@if ${PKG_INFO} -e ${_p}; then \
+		p=`${PKG_INFO} -q -O ${_p}`; \
 		${ECHO_MSG} "===>   Deinstalling $${p}"; \
-		${PKG_DELETE} -f ${PKGBASE} ; \
+		${PKG_DELETE} -f ${_p} ; \
 	else \
-		${ECHO_MSG} "===>   ${PKGBASE} not installed, skipping"; \
+		${ECHO_MSG} "===>   ${_p} not installed, skipping"; \
 	fi
+.endfor
 	@${RM} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
 .endif
 .endif
@@ -3935,7 +4004,7 @@
 repackage: pre-repackage package
 
 pre-repackage:
-	@${RM} ${PACKAGE_COOKIE}
+	@${RM} ${PACKAGE_COOKIE} ${TMPPLIST}*
 .endif
 
 # Build a package but don't check the cookie for installation, also don't
@@ -3953,10 +4022,13 @@
 depends: pkg-depends extract-depends patch-depends lib-depends fetch-depends build-depends run-depends
 
 .for deptype in PKG EXTRACT PATCH FETCH BUILD LIB RUN TEST
+.for p in ${_PKGS}
+${deptype}_DEPENDS_ALL+=	${${deptype}_DEPENDS${_P.${p}}}
+.endfor
 ${deptype:tl}-depends:
-.if defined(${deptype}_DEPENDS) && !defined(NO_DEPENDS)
+.if !empty(${deptype}_DEPENDS_ALL) && !defined(NO_DEPENDS)
 	@${SETENV} \
-		dp_RAWDEPENDS="${${deptype}_DEPENDS}" \
+		dp_RAWDEPENDS="${${deptype}_DEPENDS_ALL}" \
 		dp_DEPTYPE="${deptype}_DEPENDS" \
 		dp_DEPENDS_TARGET="${DEPENDS_TARGET}" \
 		dp_DEPENDS_PRECLEAN="${DEPENDS_PRECLEAN}" \
@@ -3985,7 +4057,7 @@
 
 # Dependency lists: both build and runtime, recursive.  Print out directory names.
 
-_UNIFIED_DEPENDS=${PKG_DEPENDS} ${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} ${TEST_DEPENDS}
+_UNIFIED_DEPENDS=${PKG_DEPENDS_ALL} ${EXTRACT_DEPENDS_ALL} ${PATCH_DEPENDS_ALL} ${FETCH_DEPENDS_ALL} ${BUILD_DEPENDS_ALL} ${LIB_DEPENDS_ALL} ${RUN_DEPENDS_ALL} ${TEST_DEPENDS_ALL}
 _DEPEND_SPECIALS=	${_UNIFIED_DEPENDS:M*\:*\:*:C,^[^:]*:([^:]*):.*$,\1,}
 
 .for d in ${_UNIFIED_DEPENDS:M*\:/*}
@@ -4037,10 +4109,10 @@
 ALL-DEPENDS-FLAVORS-LIST=	${DEPENDS-LIST} -f -r ${_UNIFIED_DEPENDS:Q}
 DEINSTALL-DEPENDS-FLAVORS-LIST=	${DEPENDS-LIST} -f -r ${_UNIFIED_DEPENDS:N${PKG_DEPENDS}:Q}
 MISSING-DEPENDS-LIST=		${DEPENDS-LIST} -m ${_UNIFIED_DEPENDS:Q}
-BUILD-DEPENDS-LIST=			${DEPENDS-LIST} "${PKG_DEPENDS} ${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}"
-RUN-DEPENDS-LIST=			${DEPENDS-LIST} "${LIB_DEPENDS} ${RUN_DEPENDS}"
-TEST-DEPENDS-LIST=			${DEPENDS-LIST} ${TEST_DEPENDS:Q}
-CLEAN-DEPENDS-LIST=			${DEPENDS-LIST} -wr ${_UNIFIED_DEPENDS:Q} 
+BUILD-DEPENDS-LIST=			${DEPENDS-LIST_ALL} "${PKG_DEPENDS_ALL} ${EXTRACT_DEPENDS_ALL} ${PATCH_DEPENDS_ALL} ${FETCH_DEPENDS_ALL} ${BUILD_DEPENDS_ALL} ${LIB_DEPENDS_ALL}"
+RUN-DEPENDS-LIST=			${DEPENDS-LIST_ALL} "${LIB_DEPENDS_ALL} ${RUN_DEPENDS_ALL}"
+TEST-DEPENDS-LIST=			${DEPENDS-LIST} ${TEST_DEPENDS_ALL:Q}
+CLEAN-DEPENDS-LIST=			${DEPENDS-LIST} -wr ${_UNIFIED_DEPENDS:Q}
 CLEAN-DEPENDS-LIMITED-LIST=	${DEPENDS-LIST} -w ${_UNIFIED_DEPENDS:Q}
 
 .if !target(clean-depends)
@@ -4128,7 +4200,7 @@
 	@${ECHO_MSG} "===> Fetching all required distfiles for ${PKGNAME} and dependencies"
 .for deptype in PKG EXTRACT PATCH FETCH BUILD RUN
 .if defined(${deptype}_DEPENDS)
-	@targ=fetch; deps="${${deptype}_DEPENDS}"; ${FETCH_LIST}
+	@targ=fetch; deps="${${deptype}_DEPENDS_ALL}"; ${FETCH_LIST}
 .endif
 .endfor
 .endif
@@ -4140,7 +4212,7 @@
 .if !defined(NO_DEPENDS)
 .for deptype in PKG EXTRACT PATCH FETCH BUILD RUN
 .if defined(${deptype}_DEPENDS)
-	@targ=fetch-list; deps="${${deptype}_DEPENDS}"; ${FETCH_LIST}
+	@targ=fetch-list; deps="${${deptype}_DEPENDS_ALL}"; ${FETCH_LIST}
 .endif
 .endfor
 .endif
@@ -4179,7 +4251,7 @@
 	@${PACKAGE-DEPENDS-LIST}
 .endif
 
-_LIB_RUN_DEPENDS=	${LIB_DEPENDS} ${RUN_DEPENDS}
+_LIB_RUN_DEPENDS=	${LIB_DEPENDS_ALL} ${RUN_DEPENDS_ALL}
 PACKAGE-DEPENDS-LIST?= \
 	if [ "${CHILD_DEPENDS}" ]; then \
 		installed=$$(${PKG_INFO} -qO ${PKGORIGIN} 2>/dev/null || \
@@ -4226,56 +4298,68 @@
 		fi; \
 	done
 
-ACTUAL-PACKAGE-DEPENDS?= \
+.for p in ${_PKGS}
+ACTUAL-PACKAGE-DEPENDS${_P.${p}}?= \
 	depfiles="" ; \
-	for lib in ${LIB_DEPENDS:C/\:.*//}; do \
+	for lib in ${LIB_DEPENDS${_P.${p}}:C/\:.*//}; do \
 		depfiles="$$depfiles `${SETENV} LIB_DIRS="${LIB_DIRS}" LOCALBASE="${LOCALBASE}" ${SH} ${SCRIPTSDIR}/find-lib.sh $${lib}`" ; \
 	done ; \
-	${SETENV} PKG_BIN="${PKG_BIN}" ${SH} ${SCRIPTSDIR}/actual-package-depends.sh $${depfiles} ${RUN_DEPENDS:C/(.*)\:.*/"\1"/}
+	for self in ${SELF_DEPENDS${_P.${p}}}; do \
+		if [ "$$self" = "main" ]; then \
+			printf "\"%s\": {origin: \"%s\", version: \"%s\"}\n" ${PKGBASE} ${PKGORIGIN} ${PKGVERSION}; \
+		else \
+			printf "\"%s-%s\": {origin: \"%s\", version: \"%s\"}\n" ${PKGBASE} $$self ${PKGORIGIN} ${PKGVERSION}; \
+		fi ; \
+	done ; \
+	${SETENV} PKG_BIN="${PKG_BIN}" ${SH} ${SCRIPTSDIR}/actual-package-depends.sh $${depfiles} ${RUN_DEPENDS${_P.${p}}:C/(.*)\:.*/"\1"/}
+.endfor
 
 PKG_NOTES_ENV?=
 .for note in ${PKG_NOTES}
 PKG_NOTES_ENV+=	dp_PKG_NOTE_${note}=${PKG_NOTE_${note}:Q}
 .endfor
 
-create-manifest:
+.for p in ${_PKGS}
+create-manifest: create-manifest.${p}
+create-manifest.${p}:
 	@${SETENV} \
-			dp_SCRIPTSDIR='${SCRIPTSDIR}'                         \
-			dp_ACTUAL_PACKAGE_DEPENDS='${ACTUAL-PACKAGE-DEPENDS}' \
-			dp_CATEGORIES='${CATEGORIES:u:S/$/,/}'                \
-			dp_COMMENT=${COMMENT:Q}                               \
-			dp_COMPLETE_OPTIONS_LIST='${COMPLETE_OPTIONS_LIST}'   \
-			dp_DEPRECATED=${DEPRECATED:Q}                         \
-			dp_DESCR='${DESCR}'                                   \
-			dp_EXPIRATION_DATE='${EXPIRATION_DATE}'               \
-			dp_GROUPS='${GROUPS:u:S/$/,/}'                        \
-			dp_LICENSE='${LICENSE:u:S/$/,/}'                      \
-			dp_LICENSE_COMB='${LICENSE_COMB}'                     \
-			dp_MAINTAINER='${MAINTAINER}'                         \
-			dp_METADIR='${METADIR}'                               \
-			dp_NO_ARCH='${NO_ARCH}'                               \
-			dp_PKGBASE='${PKGBASE}'                               \
-			dp_PKGDEINSTALL='${PKGDEINSTALL}'                     \
-			dp_PKGINSTALL='${PKGINSTALL}'                         \
-			dp_PKGMESSAGES='${_PKGMESSAGES}'                      \
-			dp_PKGORIGIN='${PKGORIGIN}'                           \
-			dp_PKGPOSTDEINSTALL='${PKGPOSTDEINSTALL}'             \
-			dp_PKGPOSTINSTALL='${PKGPOSTINSTALL}'                 \
-			dp_PKGPOSTUPGRADE='${PKGPOSTUPGRADE}'                 \
-			dp_PKGPREDEINSTALL='${PKGPREDEINSTALL}'               \
-			dp_PKGPREINSTALL='${PKGPREINSTALL}'                   \
-			dp_PKGPREUPGRADE='${PKGPREUPGRADE}'                   \
-			dp_PKGUPGRADE='${PKGUPGRADE}'                         \
-			dp_PKGVERSION='${PKGVERSION}'                         \
-			dp_PKG_BIN='${PKG_BIN}'                               \
-			dp_PKG_IGNORE_DEPENDS='${PKG_IGNORE_DEPENDS}'         \
-			dp_PKG_NOTES='${PKG_NOTES}'                           \
-			dp_PORT_OPTIONS='${PORT_OPTIONS}'                     \
-			dp_PREFIX='${PREFIX}'                                 \
-			dp_USERS='${USERS:u:S/$/,/}'                          \
-			dp_WWW='${WWW}'                                       \
-			${PKG_NOTES_ENV}                                      \
+			dp_SCRIPTSDIR='${SCRIPTSDIR}'                              \
+			dp_ACTUAL_PACKAGE_DEPENDS='${ACTUAL-PACKAGE-DEPENDS${_P.${p}}}' \
+			dp_CATEGORIES='${CATEGORIES:u:S/$/,/}'                     \
+			dp_COMMENT=${COMMENT${_P.${p}}:Q}                               \
+			dp_COMPLETE_OPTIONS_LIST='${COMPLETE_OPTIONS_LIST}'        \
+			dp_DEPRECATED=${DEPRECATED:Q}                              \
+			dp_DESCR='${DESCR${_P.${p}}}'                                   \
+			dp_EXPIRATION_DATE='${EXPIRATION_DATE}'                    \
+			dp_GROUPS='${GROUPS:u:S/$/,/}'                             \
+			dp_LICENSE='${LICENSE:u:S/$/,/}'                           \
+			dp_LICENSE_COMB='${LICENSE_COMB}'                          \
+			dp_MAINTAINER='${MAINTAINER}'                              \
+			dp_METADIR='${METADIR}.${p}'                               \
+			dp_NO_ARCH='${NO_ARCH}'                                    \
+			dp_PKGBASE='${p}'                                          \
+			dp_PKGDEINSTALL='${PKGDEINSTALL${_P.${p}}}'                     \
+			dp_PKGINSTALL='${PKGINSTALL${_P.${p}}}'                         \
+			dp_PKGMESSAGES='${_PKGMESSAGES${_P.${p}}}'                      \
+			dp_PKGORIGIN='${PKGORIGIN}'                                \
+			dp_PKGPOSTDEINSTALL='${PKGPOSTDEINSTALL${_P.${p}}}'             \
+			dp_PKGPOSTINSTALL='${PKGPOSTINSTALL${_P.${p}}}'                 \
+			dp_PKGPOSTUPGRADE='${PKGPOSTUPGRADE${_P.${p}}}'                 \
+			dp_PKGPREDEINSTALL='${PKGPREDEINSTALL${_P.${p}}}'               \
+			dp_PKGPREINSTALL='${PKGPREINSTALL${_P.${p}}}'                   \
+			dp_PKGPREUPGRADE='${PKGPREUPGRADE${_P.${p}}}'                   \
+			dp_PKGUPGRADE='${PKGUPGRADE${_P.${p}}}'                         \
+			dp_PKGVERSION='${PKGVERSION}'                              \
+			dp_PKG_BIN='${PKG_BIN}'                                    \
+			dp_PKG_IGNORE_DEPENDS='${PKG_IGNORE_DEPENDS}'              \
+			dp_PKG_NOTES='${PKG_NOTES}'                                \
+			dp_PORT_OPTIONS='${PORT_OPTIONS}'                          \
+			dp_PREFIX='${PREFIX}'                                      \
+			dp_USERS='${USERS:u:S/$/,/}'                               \
+			dp_WWW='${WWW}'                                            \
+			${PKG_NOTES_ENV}                                           \
 			${SH} ${SCRIPTSDIR}/create-manifest.sh
+.endfor
 
 
 # Print out package names.
@@ -4283,8 +4367,11 @@
 package-depends:
 	@${PACKAGE-DEPENDS-LIST} | ${AWK} '{print $$1":"$$3}'
 
-actual-package-depends:
-	@${ACTUAL-PACKAGE-DEPENDS}
+.for p in ${_PKGS}
+actual-package-depends${_P.${p}}:
+	@${ACTUAL-PACKAGE-DEPENDS${_P.${p}}}
+.endfor
+
 
 # Build packages for port and dependencies
 
@@ -4325,12 +4412,12 @@
 # first to avoid gratuitous breakage.
 
 . if !target(describe)
-_EXTRACT_DEPENDS=${EXTRACT_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
-_PATCH_DEPENDS=${PATCH_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
-_FETCH_DEPENDS=${FETCH_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
-_LIB_DEPENDS=${LIB_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
-_BUILD_DEPENDS=${BUILD_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,} ${_LIB_DEPENDS}
-_RUN_DEPENDS=${RUN_DEPENDS:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,} ${_LIB_DEPENDS}
+_EXTRACT_DEPENDS=${EXTRACT_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
+_PATCH_DEPENDS=${PATCH_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
+_FETCH_DEPENDS=${FETCH_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
+_LIB_DEPENDS=${LIB_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,}
+_BUILD_DEPENDS=${BUILD_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,} ${_LIB_DEPENDS}
+_RUN_DEPENDS=${RUN_DEPENDS_ALL:C/^[^ :]+:([^ :@]+)(@[^ :]+)?(:[^ :]+)?/\1/:O:u:C,(^[^/]),${PORTSDIR}/\1,} ${_LIB_DEPENDS}
 . if exists(${DESCR})
 _DESCR=${DESCR}
 . else
@@ -4463,6 +4550,11 @@
 	@for file in ${PLIST_FILES}; do \
 		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
 	done
+.for p in ${_PKGS:[2..-1]}
+	@for file in ${PLIST_FILES${_P.${p}}}; do \
+		${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} -e 's/^/@@${_P.${p}:S/^.//}@@/' >> ${TMPPLIST}; \
+	done
+.endfor
 .if !empty(PLIST)
 	@if [ -f ${PLIST} ]; then \
 		${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
@@ -4473,6 +4565,11 @@
 	@${ECHO_CMD} ${dir} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} -e 's,^,@dir ,' >> ${TMPPLIST}
 .endfor
 
+.for p in ${_PKGS:[2..-1]}
+.for dir in ${PLIST_DIRS${_P.${p}}}
+	@${ECHO_CMD} ${dir} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} -e 's,^,@@${_P.${p}:S/^.//}@@@dir ,' >> ${TMPPLIST}
+.endfor
+.endfor
 .endif
 
 ${TMPPLIST}:
@@ -4648,17 +4745,20 @@
 STAGE_ARGS=		-i ${STAGEDIR}
 
 .if !defined(NO_PKG_REGISTER)
-fake-pkg:
+. for p in ${_PKGS}
+fake-pkg: fake-pkg.${p}
+fake-pkg.${p}: ${_PLIST}.${p} ${METADIR}.${p}
 .if defined(INSTALLS_DEPENDS)
 	@${ECHO_MSG} "===>   Registering installation for ${PKGNAME} as automatic"
-	@${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_REGISTER} -d ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
+	@${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_REGISTER} -d ${STAGE_ARGS} -m ${METADIR}.${p} -f ${_PLIST}.${p}
 .else
 	@${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"
-	@${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_REGISTER} ${STAGE_ARGS} -m ${METADIR} -f ${TMPPLIST}
-.endif
-	@${RM} -r ${METADIR}
+	@${SETENV} ${PKG_ENV} FORCE_POST="${_FORCE_POST_PATTERNS}" ${PKG_REGISTER} ${STAGE_ARGS} -m ${METADIR}.${p} -f ${_PLIST}.${p}
 .endif
+	@${RM} -r ${METADIR.${p}}
+.endfor
 .endif
+.endif # !target(fake-pkg)
 
 # Depend is generally meaningless for arbitrary ports, but if someone wants
 # one they can override this.  This is just to catch people who've gotten into
Index: archivers/Makefile
===================================================================
--- archivers/Makefile
+++ archivers/Makefile
@@ -151,10 +151,6 @@
     SUBDIR += php71-phar
     SUBDIR += php71-zip
     SUBDIR += php71-zlib
-    SUBDIR += php72-bz2
-    SUBDIR += php72-phar
-    SUBDIR += php72-zip
-    SUBDIR += php72-zlib
     SUBDIR += php73-bz2
     SUBDIR += php73-phar
     SUBDIR += php73-zip
Index: archivers/php72-bz2/Makefile
===================================================================
--- archivers/php72-bz2/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	archivers
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-bz2
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: archivers/php72-phar/Makefile
===================================================================
--- archivers/php72-phar/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	archivers
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-phar
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: archivers/php72-phar/files/patch-config.m4
===================================================================
--- archivers/php72-phar/files/patch-config.m4
+++ /dev/null
@@ -1,41 +0,0 @@
---- config.m4.orig	2016-06-21 19:56:50 UTC
-+++ config.m4
-@@ -4,8 +4,38 @@ dnl config.m4 for extension phar
- PHP_ARG_ENABLE(phar, for phar archive support,
- [  --disable-phar          Disable phar support], yes)
- 
-+PHP_ARG_WITH(pcre-dir, pcre install prefix,
-+[  --with-pcre-dir           PHAR: pcre install prefix], no, no)
-+
-+
- if test "$PHP_PHAR" != "no"; then
-+
-+  dnl This is PECL build, check if bundled PCRE library is used
-+  old_CPPFLAGS=$CPPFLAGS
-+  CPPFLAGS=$INCLUDES
-+  AC_EGREP_CPP(yes,[
-+#include <main/php_config.h>
-+#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
-+yes
-+#endif
-+  ],[
-+    PHP_PCRE_REGEX=yes
-+  ],[
-+    AC_EGREP_CPP(yes,[
-+#include <main/php_config.h>
-+#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
-+yes
-+#endif
-+    ],[
-+      PHP_PCRE_REGEX=pecl
-+      PHP_ADD_INCLUDE($PHP_PCRE_DIR/include)
-+    ],[
-+      PHP_PCRE_REGEX=no
-+    ])
-+  ])
-+
-   PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
-+  PHP_HASH=yes
-   AC_MSG_CHECKING([for phar openssl support])
-   if test "$PHP_HASH_SHARED" != "yes"; then
-     if test "$PHP_HASH" != "no"; then
Index: archivers/php72-zip/Makefile
===================================================================
--- archivers/php72-zip/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	archivers
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-zip
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: archivers/php72-zlib/Makefile
===================================================================
--- archivers/php72-zlib/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	archivers
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-zlib
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: converters/Makefile
===================================================================
--- converters/Makefile
+++ converters/Makefile
@@ -144,7 +144,6 @@
     SUBDIR += php71-recode
     SUBDIR += php72-iconv
     SUBDIR += php72-mbstring
-    SUBDIR += php72-recode
     SUBDIR += php73-iconv
     SUBDIR += php73-mbstring
     SUBDIR += php73-recode
Index: converters/php72-recode/Makefile
===================================================================
--- converters/php72-recode/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	converters
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-recode
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: databases/Makefile
===================================================================
--- databases/Makefile
+++ databases/Makefile
@@ -632,8 +632,6 @@
     SUBDIR += php72-dba
     SUBDIR += php72-interbase
     SUBDIR += php72-mysqli
-    SUBDIR += php72-odbc
-    SUBDIR += php72-pdo
     SUBDIR += php72-pdo_dblib
     SUBDIR += php72-pdo_firebird
     SUBDIR += php72-pdo_mysql
Index: databases/php72-odbc/Makefile
===================================================================
--- databases/php72-odbc/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	databases
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-odbc
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: databases/php72-pdo/Makefile
===================================================================
--- databases/php72-pdo/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	databases
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-pdo
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/Makefile
===================================================================
--- devel/Makefile
+++ devel/Makefile
@@ -3912,15 +3912,7 @@
     SUBDIR += php71-sysvshm
     SUBDIR += php71-tokenizer
     SUBDIR += php72-gettext
-    SUBDIR += php72-intl
-    SUBDIR += php72-json
-    SUBDIR += php72-pcntl
     SUBDIR += php72-readline
-    SUBDIR += php72-shmop
-    SUBDIR += php72-sysvmsg
-    SUBDIR += php72-sysvsem
-    SUBDIR += php72-sysvshm
-    SUBDIR += php72-tokenizer
     SUBDIR += php73-gettext
     SUBDIR += php73-intl
     SUBDIR += php73-json
Index: devel/git/Makefile
===================================================================
--- devel/git/Makefile
+++ devel/git/Makefile
@@ -17,6 +17,11 @@
 LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/COPYING
 
+SELF_DEPENDS.perl=	main
+SELF_DEPENDS.gitweb=	perl
+SELF_DEPENDS.send-email=	perl
+SELF_DEPENDS.subversion=	perl
+
 CONFLICTS_INSTALL?=	git-gui-[0-9]* git-subversion-[0-9]* git-lite-[0-9]*
 
 USERS=		git_daemon
@@ -58,6 +63,10 @@
 			SUBTREE
 OPTIONS_SUB=	yes
 
+.if defined(PACKAGE_BUILDING)
+OPTIONS_DEFAULT+=	SVN
+.endif
+
 GITWEB_DESC=	Install gitweb
 CONTRIB_DESC=	Install contributed scripts
 P4_DESC=	Enable Perforce support
@@ -72,12 +81,14 @@
 
 PERL_USES=		perl5
 PERL_CONFIGURE_WITH=	perl=${PERL}
-PERL_BUILD_DEPENDS=	p5-Error>=0:lang/p5-Error
-PERL_RUN_DEPENDS=	p5-Error>=0:lang/p5-Error
+PERL_BUILD_DEPENDS.perl=	p5-Error>=0:lang/p5-Error
+PERL_RUN_DEPENDS.perl=	p5-Error>=0:lang/p5-Error
 PERL_MAKE_ARGS_OFF=	NO_PERL=1
+PERL_SUBPACKAGES=	perl
 
 GITWEB_IMPLIES=		PERL
-GITWEB_RUN_DEPENDS=	p5-CGI>=0:www/p5-CGI
+GITWEB_RUN_DEPENDS.gitweb=	p5-CGI>=0:www/p5-CGI
+GITWEB_SUBPACKAGES=	gitweb
 
 PCRE_LIB_DEPENDS=	libpcre.so:devel/pcre
 PCRE_CONFIGURE_WITH=	libpcre1
@@ -86,8 +97,9 @@
 PCRE2_CONFIGURE_WITH=	libpcre
 
 SEND_EMAIL_IMPLIES=	PERL
-SEND_EMAIL_RUN_DEPENDS=	p5-Authen-SASL>=0:security/p5-Authen-SASL \
+SEND_EMAIL_RUN_DEPENDS.send-email=	p5-Authen-SASL>=0:security/p5-Authen-SASL \
 			p5-IO-Socket-SSL>=0:security/p5-IO-Socket-SSL
+SEND_EMAIL_SUBPACKAGES=	send_email
 
 ICONV_USES=		iconv
 ICONV_MAKE_ARGS_OFF=	NO_ICONV=1
@@ -109,8 +121,10 @@
 # to have git use devel/subversion18 it will be brought in through
 # devel/p5-subversion if you set WITH_SUBVERSION_VER=18. Otherwise
 # devel/subversion will be brought in.
-SVN_RUN_DEPENDS=	p5-Term-ReadKey>=0:devel/p5-Term-ReadKey \
+SVN_IMPLIES=		PERL
+SVN_RUN_DEPENDS.subversion=	p5-Term-ReadKey>=0:devel/p5-Term-ReadKey \
 			p5-subversion>=0:devel/p5-subversion
+SVN_SUBPACKAGES=	subversion
 
 SUBTREE_BUILD_DEPENDS=	xmlto:textproc/xmlto \
 			asciidoc:textproc/asciidoc \
Index: devel/git/pkg-descr.subversion
===================================================================
--- /dev/null
+++ devel/git/pkg-descr.subversion
@@ -0,0 +1,3 @@
+Git bindings to interact with a subversion repository.
+
+WWW: http://git-scm.org/
Index: devel/git/pkg-plist
===================================================================
--- devel/git/pkg-plist
+++ devel/git/pkg-plist
@@ -16,16 +16,16 @@
 %%PERL%%%%SITE_PERL%%/Git/LoadCPAN/Error.pm
 %%PERL%%%%SITE_PERL%%/Git/LoadCPAN/Mail/Address.pm
 %%PERL%%%%SITE_PERL%%/Git/Packet.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Editor.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Fetcher.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/GlobSpec.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Log.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Memoize/YAML.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Migration.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Prompt.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Ra.pm
-%%PERL%%%%SITE_PERL%%/Git/SVN/Utils.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Editor.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Fetcher.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/GlobSpec.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Log.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Memoize/YAML.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Migration.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Prompt.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Ra.pm
+%%SVN%%@@subversion@@%%SITE_PERL%%/Git/SVN/Utils.pm
 libexec/git-core/git
 libexec/git-core/git-add
 libexec/git-core/git-add--interactive
@@ -160,7 +160,7 @@
 libexec/git-core/git-rev-parse
 libexec/git-core/git-revert
 libexec/git-core/git-rm
-%%SEND_EMAIL%%libexec/git-core/git-send-email
+%%SEND_EMAIL%%@@send_email@@libexec/git-core/git-send-email
 libexec/git-core/git-send-pack
 libexec/git-core/git-sh-i18n
 libexec/git-core/git-sh-i18n--envsubst
@@ -178,7 +178,7 @@
 libexec/git-core/git-submodule
 libexec/git-core/git-submodule--helper
 %%SUBTREE%%libexec/git-core/git-subtree
-%%SVN%%libexec/git-core/git-svn
+%%SVN%%@@subversion@@libexec/git-core/git-svn
 libexec/git-core/git-switch
 libexec/git-core/git-symbolic-ref
 libexec/git-core/git-tag
@@ -340,7 +340,7 @@
 man/man1/git-rev-parse.1.gz
 man/man1/git-revert.1.gz
 man/man1/git-rm.1.gz
-%%SEND_EMAIL%%man/man1/git-send-email.1.gz
+%%SEND_EMAIL%%@@send_email@@man/man1/git-send-email.1.gz
 man/man1/git-send-pack.1.gz
 man/man1/git-sh-i18n--envsubst.1.gz
 man/man1/git-sh-i18n.1.gz
@@ -357,7 +357,7 @@
 man/man1/git-stripspace.1.gz
 man/man1/git-submodule.1.gz
 %%SUBTREE%%man/man1/git-subtree.1.gz
-%%SVN%%man/man1/git-svn.1.gz
+%%SVN%%@@subversion@@man/man1/git-svn.1.gz
 man/man1/git-switch.1.gz
 man/man1/git-symbolic-ref.1.gz
 man/man1/git-tag.1.gz
@@ -999,8 +999,8 @@
 %%HTMLDOCS%%%%DOCSDIR%%/git-revert.txt
 %%HTMLDOCS%%%%DOCSDIR%%/git-rm.html
 %%HTMLDOCS%%%%DOCSDIR%%/git-rm.txt
-%%SEND_EMAIL%%%%HTMLDOCS%%%%DOCSDIR%%/git-send-email.html
-%%SEND_EMAIL%%%%HTMLDOCS%%%%DOCSDIR%%/git-send-email.txt
+%%SEND_EMAIL%%@@send_email@@%%HTMLDOCS%%%%DOCSDIR%%/git-send-email.html
+%%SEND_EMAIL%%@@send_email@@%%HTMLDOCS%%%%DOCSDIR%%/git-send-email.txt
 %%HTMLDOCS%%%%DOCSDIR%%/git-send-pack.html
 %%HTMLDOCS%%%%DOCSDIR%%/git-send-pack.txt
 %%HTMLDOCS%%%%DOCSDIR%%/git-sh-i18n--envsubst.html
@@ -1258,12 +1258,12 @@
 %%HTMLDOCS%%%%DOCSDIR%%/user-manual.txt
 share/emacs/site-lisp/git/git-blame.el
 share/emacs/site-lisp/git/git.el
-%%GITWEB%%@sample %%ETCDIR%%/gitweb.conf.sample
-%%GITWEB%%%%EXAMPLESDIR%%/gitweb/gitweb.cgi
-%%GITWEB%%%%EXAMPLESDIR%%/gitweb/static/git-favicon.png
-%%GITWEB%%%%EXAMPLESDIR%%/gitweb/static/git-logo.png
-%%GITWEB%%%%EXAMPLESDIR%%/gitweb/static/gitweb.css
-%%GITWEB%%%%EXAMPLESDIR%%/gitweb/static/gitweb.js
+%%GITWEB%%@@gitweb@@@sample %%ETCDIR%%/gitweb.conf.sample
+%%GITWEB%%@@gitweb@@%%EXAMPLESDIR%%/gitweb/gitweb.cgi
+%%GITWEB%%@@gitweb@@%%EXAMPLESDIR%%/gitweb/static/git-favicon.png
+%%GITWEB%%@@gitweb@@%%EXAMPLESDIR%%/gitweb/static/git-logo.png
+%%GITWEB%%@@gitweb@@%%EXAMPLESDIR%%/gitweb/static/gitweb.css
+%%GITWEB%%@@gitweb@@%%EXAMPLESDIR%%/gitweb/static/gitweb.js
 %%CONTRIB%%share/git-core/contrib/README
 %%CONTRIB%%share/git-core/contrib/buildsystems/Generators.pm
 %%CONTRIB%%share/git-core/contrib/buildsystems/Generators/QMake.pm
Index: devel/php72-intl/Makefile
===================================================================
--- devel/php72-intl/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-intl
-
-USES=		compiler:c++11-lib
-USE_CXXSTD=	gnu++11
-
-CPPFLAGS+=	-DU_USING_ICU_NAMESPACE=1
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-json/Makefile
===================================================================
--- devel/php72-json/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-json
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-pcntl/Makefile
===================================================================
--- devel/php72-pcntl/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-pcntl
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-shmop/Makefile
===================================================================
--- devel/php72-shmop/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-shmop
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-sysvmsg/Makefile
===================================================================
--- devel/php72-sysvmsg/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-sysvmsg
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-sysvsem/Makefile
===================================================================
--- devel/php72-sysvsem/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-sysvsem
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-sysvshm/Makefile
===================================================================
--- devel/php72-sysvshm/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-sysvshm
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: devel/php72-tokenizer/Makefile
===================================================================
--- devel/php72-tokenizer/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	devel
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-tokenizer
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: ftp/Makefile
===================================================================
--- ftp/Makefile
+++ ftp/Makefile
@@ -61,7 +61,6 @@
     SUBDIR += php-fastdfs
     SUBDIR += php71-curl
     SUBDIR += php71-ftp
-    SUBDIR += php72-curl
     SUBDIR += php72-ftp
     SUBDIR += php73-curl
     SUBDIR += php73-ftp
Index: ftp/php72-curl/Makefile
===================================================================
--- ftp/php72-curl/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	ftp
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-curl
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: graphics/Makefile
===================================================================
--- graphics/Makefile
+++ graphics/Makefile
@@ -742,7 +742,6 @@
     SUBDIR += php-geos
     SUBDIR += php71-exif
     SUBDIR += php71-gd
-    SUBDIR += php72-exif
     SUBDIR += php72-gd
     SUBDIR += php73-exif
     SUBDIR += php73-gd
Index: graphics/php72-exif/Makefile
===================================================================
--- graphics/php72-exif/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	graphics
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-exif
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: lang/perl5-devel/Makefile
===================================================================
--- lang/perl5-devel/Makefile
+++ lang/perl5-devel/Makefile
@@ -15,6 +15,7 @@
 
 MAINTAINER=	mat@FreeBSD.org
 COMMENT=	Practical Extraction and Report Language
+COMMENT.gdbm=	GNU Data Base Manager (gdbm) interface
 
 LICENSE=	ART10 GPLv1+
 LICENSE_COMB=	dual
@@ -25,6 +26,8 @@
 #DEPRECATED=	Support end three years after .0 release, please upgrade to a more recent version of Perl
 #EXPIRATION_DATE=<Release date of .0 + 3 years>
 
+SELF_DEPENDS.gdbm=	main
+
 # XXX releases are .tar.xz, add: tar:xz
 USES=	cpe
 
@@ -68,6 +71,9 @@
 	-Alddlflags='-L${WRKSRC} -L${PREFIX}/${_ARCH_LIB}/CORE -lperl' \
 	-Dshrpldflags='$$(LDDLFLAGS:N-L${WRKSRC}:N-L${PREFIX}/${_ARCH_LIB}/CORE:N-lperl) -Wl,-soname,$$(LIBPERL)'
 
+# Give a hint of where libperl.so can be found.
+USE_LDCONFIG=	${PREFIX}/${_ARCH_LIB}/CORE
+
 # XXX Remove
 CONFIGURE_ARGS+=	-Dusedevel -Uversiononly
 
@@ -173,7 +179,8 @@
 DTRACE_CONFIGURE_OFF=	-Uusedtrace
 GDBM_CONFIGURE_ON=	-Di_gdbm
 GDBM_CONFIGURE_OFF=	-Ui_gdbm
-GDBM_LIB_DEPENDS=	libgdbm.so:databases/gdbm
+GDBM_LIB_DEPENDS.gdbm=	libgdbm.so:databases/gdbm
+GDBM_SUBPACKAGES=	gdbm
 PERL_64BITINT_CONFIGURE_ON=	-Duse64bitint
 MULTIPLICITY_CONFIGURE_ON=	-Dusemultiplicity=y
 MULTIPLICITY_CONFIGURE_OFF=	-Dusemultiplicity=n
Index: lang/perl5-devel/pkg-descr.gdbm
===================================================================
--- /dev/null
+++ lang/perl5-devel/pkg-descr.gdbm
@@ -0,0 +1,6 @@
+GDBM_File is a perl module which allows Perl programs to make use of the
+facilities provided by the GNU gdbm library.  If you intend to use this
+module you should really have a copy of the gdbm manualpage at hand.
+
+Most of the libgdbm.a functions are available through the GDBM_File
+interface.
Index: lang/perl5-devel/pkg-plist
===================================================================
--- lang/perl5-devel/pkg-plist
+++ lang/perl5-devel/pkg-plist
@@ -786,7 +786,7 @@
 %%ARCH_LIB%%/File/Spec/VMS.pm
 %%ARCH_LIB%%/File/Spec/Win32.pm
 %%ARCH_LIB%%/Filter/Util/Call.pm
-%%GDBM%%%%ARCH_LIB%%/GDBM_File.pm
+%%GDBM%%@@gdbm@@%%ARCH_LIB%%/GDBM_File.pm
 %%ARCH_LIB%%/Hash/Util.pm
 %%ARCH_LIB%%/Hash/Util/FieldHash.pm
 %%ARCH_LIB%%/I18N/Langinfo.pm
@@ -856,7 +856,7 @@
 %%ARCH_LIB%%/auto/File/DosGlob/DosGlob.so
 %%ARCH_LIB%%/auto/File/Glob/Glob.so
 %%ARCH_LIB%%/auto/Filter/Util/Call/Call.so
-%%GDBM%%%%ARCH_LIB%%/auto/GDBM_File/GDBM_File.so
+%%GDBM%%@@gdbm@@%%ARCH_LIB%%/auto/GDBM_File/GDBM_File.so
 %%ARCH_LIB%%/auto/Hash/Util/FieldHash/FieldHash.so
 %%ARCH_LIB%%/auto/Hash/Util/Util.so
 %%ARCH_LIB%%/auto/I18N/Langinfo/Langinfo.so
@@ -1323,7 +1323,7 @@
 %%MAN3%%/Filter::Simple.3.gz
 %%MAN3%%/Filter::Util::Call.3.gz
 %%MAN3%%/FindBin.3.gz
-%%GDBM%%%%MAN3%%/GDBM_File.3.gz
+%%GDBM%%@@gdbm@@%%MAN3%%/GDBM_File.3.gz
 %%MAN3%%/Getopt::Long.3.gz
 %%MAN3%%/Getopt::Std.3.gz
 %%MAN3%%/HTTP::Tiny.3.gz
Index: lang/php72/Makefile
===================================================================
--- lang/php72/Makefile
+++ lang/php72/Makefile
@@ -5,23 +5,21 @@
 PORTREVISION?=	0
 CATEGORIES?=	lang devel www
 MASTER_SITES=	PHP/distributions
-DISTNAME=	php-${DISTVERSION}
 
 MAINTAINER=	tz@FreeBSD.org
 COMMENT=	PHP Scripting Language
 
 LICENSE=	PHP301
 
-USES+=		tar:xz cpe
+USES=		tar:xz cpe
 CPE_PRODUCT=	php
 NO_OPTIONS_SORT=yes
 
-.if !defined(PKGNAMESUFFIX)
 LIB_DEPENDS=	libpcre.so:devel/pcre \
 		libargon2.so:security/libargon2
 
 GNU_CONFIGURE=	yes
-CONFIGURE_ARGS+=--with-layout=GNU \
+CONFIGURE_ARGS=--with-layout=GNU \
 		--with-config-file-scan-dir=${PREFIX}/etc/php \
 		--disable-all \
 		--enable-libxml \
@@ -35,7 +33,7 @@
 # PR230207 Allow relocations against read-only segments (override lld default)
 LDFLAGS_i386=	-Wl,-z,notext
 
-OPTIONS_DEFINE+=CLI CGI FPM EMBED PHPDBG DEBUG DTRACE IPV6 MYSQLND LINKTHR ZTS
+OPTIONS_DEFINE=CLI CGI FPM EMBED PHPDBG DEBUG DTRACE IPV6 MYSQLND LINKTHR ZTS
 OPTIONS_DEFAULT=CLI CGI FPM EMBED MYSQLND LINKTHR DTRACE
 OPTIONS_EXCLUDE_DragonFly=	DTRACE
 # ld(1) fails to link probes: Relocations in generic ELF (EM: 0)
@@ -58,6 +56,252 @@
 LINKTHR_DESC=	Link thread lib (for threaded extensions)
 ZTS_DESC=	Force Zend Thread Safety (ZTS) build
 
+OPTIONS_GROUP=	EXTS
+OPTIONS_GROUP_EXTS=	\
+			BCMATH \
+			BZ2 \
+			CALENDAR \
+			CTYPE \
+			CURL \
+			DOM \
+			ENCHANT \
+			EXIF \
+			FILEINFO \
+			GMP \
+			HASH \
+			JSON \
+			ODBC \
+			OPCACHE \
+			PCNTL \
+			PDO \
+			PHAR \
+			POSIX \
+			PSPELL \
+			RECODE \
+			SESSION \
+			SHMOP \
+			SOAP \
+			SOCKETS \
+			SODIUM \
+			SYSVMSG \
+			SYSVSEM \
+			SYSVSHM \
+			TIDY \
+			TOKENIZER \
+			WDDX \
+			XML \
+			XMLREADER \
+			XMLWRITER \
+			XSL \
+			ZIP \
+			ZLIB \
+
+# These do not want to build as shared
+#			FILTER \
+#			INTL \
+
+BCMATH_DESC=		bc style precision math functions
+BZ2_DESC=		bzip2 library support
+CALENDAR_DESC=		calendar conversion support
+CTYPE_DESC=		ctype functions
+CURL_DESC=		CURL support
+DBA_DESC=		dba support
+DOM_DESC=		DOM support
+ENCHANT_DESC=		Enchant spelling support
+EXIF_DESC=		EXIF support
+FILEINFO_DESC=		fileinfo support
+FILTER_DESC=		input filter support
+FTP_DESC=		FTP support
+GD_DESC=		GD library support
+GETTEXT_DESC=		gettext library support
+GMP_DESC=		GNU MP support
+HASH_DESC=		HASH Message Digest Framework
+ICONV_DESC=		iconv support
+IMAP_DESC=		IMAP support
+INTL_DESC=		Internationalization(ICU)
+INTERBASE_DESC=		Interbase 6 database support (Firebird)
+JSON_DESC=		JavaScript Object Serialization support
+LDAP_DESC=		OpenLDAP support
+MBSTRING_DESC=		multibyte string support
+MYSQLI_DESC=		MySQLi database support
+ODBC_DESC=		ODBC support
+OPCACHE_DESC=		OPcache support
+OPENSSL_DESC=		OpenSSL support
+PCNTL_DESC=		pcntl support (CLI only)
+PDF_DESC=		PDFlib support (implies GD)
+PDO_DESC=		PHP Data Objects Interface (PDO)
+PDO_DBLIB_DESC=		PDO DBLIB-DB driver
+PDO_FIREBIRD_DESC=	PDO Firebird driver
+PDO_MYSQL_DESC=		PDO MySQL driver
+PDO_ODBC_DESC=		PDO ODBC driver
+PDO_PGSQL_DESC=		PDO PostgreSQL driver
+PDO_SQLITE_DESC=	PDO sqlite driver
+PGSQL_DESC=		PostgreSQL database support
+PHAR_DESC=		phar support
+POSIX_DESC=		POSIX-like functions
+PSPELL_DESC=		pspell support
+READLINE_DESC=		readline support (CLI only)
+RECODE_DESC=		recode support
+SESSION_DESC=		session support
+SHMOP_DESC=		shmop support
+SIMPLEXML_DESC=		simplexml support
+SNMP_DESC=		SNMP support
+SOAP_DESC=		SOAP support
+SOCKETS_DESC=		sockets support
+SODIUM_DESC=		Sodium encryption support
+SQLITE3_DESC=		sqlite3 support
+SYSVMSG_DESC=		System V message support
+SYSVSEM_DESC=		System V semaphore support
+SYSVSHM_DESC=		System V shared memory support
+TIDY_DESC=		TIDY support
+TOKENIZER_DESC=		tokenizer support
+WDDX_DESC=		WDDX support (implies XML)
+XML_DESC=		XML support
+XMLREADER_DESC=		XMLReader support
+XMLRPC_DESC=		XMLRPC-EPI support
+XMLWRITER_DESC=		XMLWriter support
+XSL_DESC=		XSL support (Implies DOM)
+ZIP_DESC=		ZIP support
+ZLIB_DESC=		ZLIB support
+
+# XXX
+OPTIONS_DEFAULT+=	${OPTIONS_GROUP_EXTS}
+
+CLI_SUBPACKAGES=	cli
+SELF_DEPENDS.cli=	main
+COMMENT.cli=		${COMMENT}, cli
+CGI_SUBPACKAGES=	cgi
+SELF_DEPENDS.cgi=	main
+COMMENT.cgi=		${COMMENT}, cgi
+FPM_SUBPACKAGES=	fpm
+SELF_DEPENDS.fpm=	main
+COMMENT.fpm=		${COMMENT}, fpm
+EMBED_SUBPACKAGES=	embed
+SELF_DEPENDS.embed=	main
+COMMENT.embed=		${COMMENT}, embedded library
+PHPDBG_SUBPACKAGES=	phpdbg
+SELF_DEPENDS.phpdbg=	main
+COMMENT.phpdbg=		${COMMENT}, Interactive debugger
+
+.for _o in ${OPTIONS_GROUP_EXTS}
+${_o}_SUBPACKAGES=	${_o:tl}
+SELF_DEPENDS.${_o:tl}=	main
+COMMENT.${_o:tl}=	The ${_o:tl} shared extension for php
+.endfor
+
+BZ2_CONFIGURE_WITH=	bz2=shared,/usr
+
+BCMATH_CONFIGURE_ENABLE=	bcmath=shared
+BCMATH_PHP_HEADER_DIRS=	libbcmath libbcmath/src
+
+CALENDAR_CONFIGURE_ENABLE=	calendar=shared
+
+CTYPE_CONFIGURE_ENABLE=	ctype=shared
+
+CURL_CONFIGURE_WITH=	curl=shared,${LOCALBASE}
+CURL_LIB_DEPENDS.curl=	libcurl.so:ftp/curl
+
+DOM_CONFIGURE_ENABLE=	dom=shared
+DOM_CONFIGURE_ON=	--with-libxml-dir=${LOCALBASE}
+DOM_LIB_DEPENDS.dom=	${libxml2_LIB_DEPENDS}
+
+ENCHANT_CONFIGURE_WITH=	enchant=shared,${LOCALBASE}
+ENCHANT_LIB_DEPENDS.enchant=	libenchant.so:textproc/enchant
+
+EXIF_CONFIGURE_ENABLE=	exif=shared
+
+FILEINFO_CONFIGURE_ENABLE=	fileinfo=shared
+FILEINFO_PHP_HEADER_DIRS=	libmagic
+
+FILTER_CONFIGURE_ENABLE=	filter=shared
+
+GMP_CONFIGURE_WITH=	gmp=shared,${LOCALBASE}
+GMP_LIB_DEPENDS.gmp=	libgmp.so:math/gmp
+
+HASH_CONFIGURE_ENABLE=	hash=shared
+HASH_CONFIGURE_WITH=	mhash
+
+INTL_CONFIGURE_WITH=	intl=shared,${LOCALBASE}
+INTL_LIB_DEPENDS.intl=	libicui18n.so:devel/icu
+
+JSON_CONFIGURE_ENABLE=	json=shared
+
+ODBC_LIB_DEPENDS.odbc=	libodbc.so:databases/unixODBC
+ODBC_CONFIGURE_WITH=	unixODBC=shared,${LOCALBASE}
+
+opcache.PHP_MOD_PRIO=	10
+OPCACHE_CONFIGURE_ENABLE=	opcache=shared
+OPCACHE_USES=	localbase
+
+PCNTL_CONFIGURE_ENABLE=	pcntl=shared
+
+PDO_CONFIGURE_ENABLE=	pdo=shared
+
+PHAR_CONFIGURE_ENABLE=	phar=shared
+phar_PHP_MOD_PRIO=	20
+PLIST_FILES.phar=	bin/phar bin/phar.phar man/man1/phar.1.gz man/man1/phar.phar.1.gz
+
+POSIX_CONFIGURE_ENABLE=	posix=shared
+
+PSPELL_LIB_DEPENDS.pspell=	libaspell.so:textproc/aspell
+PSPELL_CONFIGURE_WITH=	pspell=shared,${LOCALBASE}
+
+RECODE_LIB_DEPENDS.recode=	librecode.so:converters/recode
+RECODE_CONFIGURE_WITH=	recode=shared,${LOCALBASE}
+
+SESSION_CONFIGURE_ENABLE=	session=shared
+session_PHP_MOD_PRIO=	18
+
+SHMOP_CONFIGURE_ENABLE=	shmop=shared
+
+SOAP_CONFIGURE_ENABLE=	soap=shared
+SOAP_LIB_DEPENDS.soap=	${libxml2_LIB_DEPENDS}
+
+SOCKETS_CONFIGURE_ENABLE=	sockets=shared
+
+SODIUM_CONFIGURE_WITH=	sodium=shared,${LOCALBASE}
+SODIUM_LIB_DEPENDS.sodium=	libsodium.so:security/libsodium
+
+SYSVMSG_CONFIGURE_ENABLE=	sysvmsg=shared
+
+SYSVSEM_CONFIGURE_ENABLE=	sysvsem=shared
+
+SYSVSHM_CONFIGURE_ENABLE=	sysvshm=shared
+
+TIDY_CONFIGURE_WITH=	tidy=shared,${LOCALBASE}
+TIDY_LIB_DEPENDS.tidy=	libtidy.so:www/tidy-lib
+
+TOKENIZER_CONFIGURE_ENABLE=	tokenizer=shared
+
+WDDX_CONFIGURE_ENABLE=	wddx=shared
+WDDX_LIB_DEPENDS.wddx=	${libxml2_LIB_DEPENDS}
+WDDX_IMPLIES=	XML SESSION
+SELF_DEPENDS.wddx+=	xml session
+
+XML_CONFIGURE_ENABLE=	xml=shared
+XML_LIB_DEPENDS.xml=	${libxml2_LIB_DEPENDS}
+
+XMLREADER_CONFIGURE_ENABLE=	xmlreader=shared
+XMLREADER_LIB_DEPENDS.xmlreader=	${libxml2_LIB_DEPENDS}
+XMLREADER_IMPLIES=	DOM
+SELF_DEPENDS.xmlreader+=	dom
+
+XMLWRITER_CONFIGURE_ENABLE=	xmlwriter=shared
+XMLWRITER_LIB_DEPENDS.xmlwriter=	${libxml2_LIB_DEPENDS}
+
+XSL_CONFIGURE_WITH=	xsl=shared,${LOCALBASE}
+XSL_LIB_DEPENDS.xsl=	${libxml2_LIB_DEPENDS} ${libxslt_LIB_DEPENDS}
+XSL_IMPLIES=	DOM XML
+SELF_DEPENDS.xsl+=	dom xml
+
+
+ZIP_CONFIGURE_ENABLE=	zip=shared
+ZIP_CONFIGURE_WITH=	zlib-dir=/usr libzip=${LOCALBASE}
+ZIP_LIB_DEPENDS.zip=	libzip.so:archivers/libzip
+
+ZLIB_CONFIGURE_WITH=	zlib=shared,/usr
+
+
 #CONFLICTS=	php56-* php70-* php71-* php73-*
 
 DESTDIRNAME=	INSTALL_ROOT
@@ -182,7 +426,34 @@
 		${STAGEDIR}${PREFIX}/${APACHEMODDIR}
 .endif
 
-.else
-.include "${MASTERDIR}/Makefile.ext"
-.endif
+# FIXME: undefined variables:
+# PHP_EXT_DIR
+PHP_EXT_DIR= 20170718
+.for _e in ${OPTIONS_GROUP_EXTS:tl}
+${_e}_INI_FILE=	etc/php/ext-${${_e}_PHP_MOD_PRIO:U20}-${_e}.ini
+post-install-${_e:tu}-on:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/lib/php/${PHP_EXT_DIR}
+	@${INSTALL_LIB} ${WRKSRC}/modules/${_e}.so \
+		${STAGEDIR}${PREFIX}/lib/php/${PHP_EXT_DIR}
+.    for header in . ${${_e:tu}_PHP_HEADER_DIRS}
+		@${MKDIR} ${STAGEDIR}${PREFIX}/include/php/ext/${_e}/${header}
+		@${INSTALL_DATA} ${WRKSRC}/ext/${_e}/${header}/*.h \
+			${STAGEDIR}${PREFIX}/include/php/ext/${_e}/${header}
+.    endfor
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/php
+.    if defined(${_e:tu}_IS_ZEND)
+	@${ECHO_CMD} "zend_extension=${_e}.so" > ${STAGEDIR}${PREFIX}/${${_e}_INI_FILE}
+.    else
+	@${ECHO_CMD} "extension=${_e}.so" > ${STAGEDIR}${PREFIX}/${${_e}_INI_FILE}
+.    endif
+
+
+post-stage-${_e:tu}-on:
+	@${ECHO_CMD} "@@${_e}@@lib/php/${PHP_EXT_DIR}/${_e}.so" \
+		>> ${TMPPLIST}
+	@${FIND} -P ${STAGEDIR}${PREFIX}/include/php/ext/${_e} ! -type d 2>/dev/null | \
+		${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@@${_e}@@,p' >> ${TMPPLIST}
+	@${ECHO_CMD} "@@${_e}@@${${_e}_INI_FILE}" >> ${TMPPLIST}
+.endfor
+
 .include <bsd.port.post.mk>
Index: lang/php72/Makefile.ext
===================================================================
--- lang/php72/Makefile.ext
+++ lang/php72/Makefile.ext
@@ -14,30 +14,6 @@
 
 EXTRACT_AFTER_ARGS?=	${EXTSUBDIR}
 
-.if ${PHP_MODNAME} == "bcmath"
-CONFIGURE_ARGS+=--enable-bcmath
-
-PHP_HEADER_DIRS=libbcmath libbcmath/src
-.endif
-
-.if ${PHP_MODNAME} == "bz2"
-CONFIGURE_ARGS+=--with-bz2=/usr
-.endif
-
-.if ${PHP_MODNAME} == "calendar"
-CONFIGURE_ARGS+=--enable-calendar
-.endif
-
-.if ${PHP_MODNAME} == "ctype"
-CONFIGURE_ARGS+=--enable-ctype
-.endif
-
-.if ${PHP_MODNAME} == "curl"
-LIB_DEPENDS+=	libcurl.so:ftp/curl
-
-CONFIGURE_ARGS+=--with-curl=${LOCALBASE}
-.endif
-
 .if ${PHP_MODNAME} == "dba"
 CONFIGURE_ARGS+=--enable-dba
 
@@ -56,34 +32,6 @@
 PHP_HEADER_DIRS=	libcdb libflatfile libinifile
 .endif
 
-.if ${PHP_MODNAME} == "dom"
-CONFIGURE_ARGS+=--enable-dom \
-		--with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=	libxml2
-.endif
-
-.if ${PHP_MODNAME} == "enchant"
-LIB_DEPENDS+=   libenchant.so:textproc/enchant
-CONFIGURE_ARGS+=--with-enchant=${LOCALBASE}
-.endif
-
-.if ${PHP_MODNAME} == "exif"
-CONFIGURE_ARGS+=--enable-exif
-.endif
-
-.if ${PHP_MODNAME} == "fileinfo"
-CONFIGURE_ARGS+=--enable-fileinfo \
-		--with-pcre-dir=${LOCALBASE}
-
-PHP_HEADER_DIRS=	libmagic
-.endif
-
-.if ${PHP_MODNAME} == "filter"
-CONFIGURE_ARGS+=--enable-filter \
-		--with-pcre-dir=${LOCALBASE}
-.endif
-
 .if ${PHP_MODNAME} == "ftp"
 CONFIGURE_ARGS+=--enable-ftp \
 		--with-openssl-dir=${OPENSSLBASE}
@@ -122,22 +70,6 @@
 USES+=		gettext
 .endif
 
-.if ${PHP_MODNAME} == "gmp"
-LIB_DEPENDS+=	libgmp.so:math/gmp
-
-CONFIGURE_ARGS+=--with-gmp=${LOCALBASE}
-.endif
-
-.if ${PHP_MODNAME} == "hash"
-CONFIGURE_ARGS+=--enable-hash \
-		--with-mhash
-CFLAGS_mips64=		-DHAVE_SLOW_HASH3
-CFLAGS_powerpc64=	-DHAVE_SLOW_HASH3
-CFLAGS_powerpc=		-DHAVE_SLOW_HASH3
-CFLAGS_powerpcspe=	-DHAVE_SLOW_HASH3
-CFLAGS_sparc64=		-DHAVE_SLOW_HASH3
-.endif
-
 .if ${PHP_MODNAME} == "iconv"
 CONFIGURE_ARGS+=--with-iconv=${LOCALBASE}
 
@@ -163,15 +95,6 @@
 USES+=	firebird
 .endif
 
-.if ${PHP_MODNAME} == "intl"
-CONFIGURE_ARGS+=--with-intl=${LOCALBASE}
-LIB_DEPENDS=	libicui18n.so:devel/icu
-.endif
-
-.if ${PHP_MODNAME} == "json"
-CONFIGURE_ARGS+=--enable-json
-.endif
-
 .if ${PHP_MODNAME} == "ldap"
 CONFIGURE_ARGS+=--with-ldap=${LOCALBASE}
 
@@ -202,13 +125,6 @@
 MYSQLND_DESC=	Use MySQL Native Driver
 .endif
 
-.if ${PHP_MODNAME} == "odbc"
-LIB_DEPENDS+=	libodbc.so:databases/unixODBC
-
-CONFIGURE_ARGS+=--enable-odbc \
-		--with-unixODBC=${LOCALBASE}
-.endif
-
 .if ${PHP_MODNAME} == "openssl"
 CONFIGURE_ARGS+=--with-openssl=${OPENSSLBASE}
 
@@ -216,21 +132,6 @@
 USES+=	ssl
 .endif
 
-.if ${PHP_MODNAME} == "opcache"
-# This is needed by Zend extensions, keep before everything.
-PHP_MOD_PRIO=	10
-CONFIGURE_ARGS+=--enable-opcache
-USES+=	localbase
-.endif
-
-.if ${PHP_MODNAME} == "pcntl"
-CONFIGURE_ARGS+=--enable-pcntl
-.endif
-
-.if ${PHP_MODNAME} == "pdo"
-CONFIGURE_ARGS+=--enable-pdo
-.endif
-
 .if ${PHP_MODNAME} == "pdo_dblib"
 CONFIGURE_ARGS+=--with-pdo-dblib=${LOCALBASE}
 
@@ -285,43 +186,11 @@
 CONFIGURE_ARGS+=--with-pgsql=${LOCALBASE}
 .endif
 
-.if ${PHP_MODNAME} == "phar"
-CONFIGURE_ARGS+=--enable-phar \
-		--with-pcre-dir=${LOCALBASE}
-
-USE_PHP=	hash:build
-.endif
-
-.if ${PHP_MODNAME} == "posix"
-CONFIGURE_ARGS+=--enable-posix
-.endif
-
-.if ${PHP_MODNAME} == "pspell"
-LIB_DEPENDS+=	libaspell.so:textproc/aspell
-
-CONFIGURE_ARGS+=--with-pspell=${LOCALBASE}
-.endif
-
 .if ${PHP_MODNAME} == "readline"
 CONFIGURE_ARGS+=--with-readline=/usr
 USES+=		readline
 .endif
 
-.if ${PHP_MODNAME} == "recode"
-LIB_DEPENDS+=	librecode.so:converters/recode
-
-CONFIGURE_ARGS+=--with-recode=${LOCALBASE}
-.endif
-
-.if ${PHP_MODNAME} == "session"
-CONFIGURE_ARGS+=--enable-session
-PHP_MOD_PRIO=	18
-.endif
-
-.if ${PHP_MODNAME} == "shmop"
-CONFIGURE_ARGS+=--enable-shmop
-.endif
-
 .if ${PHP_MODNAME} == "simplexml"
 CONFIGURE_ARGS+=--enable-simplexml \
 		--with-pcre-dir=${LOCALBASE} \
@@ -342,74 +211,11 @@
 USES+=	ssl
 .endif
 
-.if ${PHP_MODNAME} == "soap"
-CONFIGURE_ARGS+=--enable-soap \
-		--with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=	libxml2
-.endif
-
-.if ${PHP_MODNAME} == "sockets"
-CONFIGURE_ARGS+=--enable-sockets
-.endif
-
-.if ${PHP_MODNAME} == "sodium"
-CONFIGURE_ARGS+=	--with-sodium=${LOCALBASE}
-LIB_DEPENDS+=	libsodium.so:security/libsodium
-.endif
-
 .if ${PHP_MODNAME} == "sqlite3"
 USES+=		sqlite
 CONFIGURE_ARGS+=--with-sqlite3=${LOCALBASE}
 .endif
 
-.if ${PHP_MODNAME} == "sysvmsg"
-CONFIGURE_ARGS+=--enable-sysvmsg
-.endif
-
-.if ${PHP_MODNAME} == "sysvsem"
-CONFIGURE_ARGS+=--enable-sysvsem
-.endif
-
-.if ${PHP_MODNAME} == "sysvshm"
-CONFIGURE_ARGS+=--enable-sysvshm
-.endif
-
-.if ${PHP_MODNAME} == "tidy"
-CONFIGURE_ARGS+=--with-tidy=${LOCALBASE}
-
-LIB_DEPENDS+=	libtidy.so:www/tidy-lib
-.endif
-
-.if ${PHP_MODNAME} == "tokenizer"
-CONFIGURE_ARGS+=--enable-tokenizer
-.endif
-
-.if ${PHP_MODNAME} == "wddx"
-CONFIGURE_ARGS+=--enable-wddx \
-		--with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=	libxml2
-
-USE_PHP=	xml:build session:build
-.endif
-
-.if ${PHP_MODNAME} == "xml"
-CONFIGURE_ARGS+=--enable-xml \
-		--with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=	libxml2
-.endif
-
-.if ${PHP_MODNAME} == "xmlreader"
-CONFIGURE_ARGS+=--enable-xmlreader \
-		--with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=	libxml2
-
-USE_PHP=	dom:build
-.endif
-
 .if ${PHP_MODNAME} == "xmlrpc"
 CONFIGURE_ARGS+=--with-xmlrpc \
 		--with-libxml-dir=${LOCALBASE} \
@@ -423,33 +229,6 @@
 USE_PHP=	xml:build
 .endif
 
-.if ${PHP_MODNAME} == "xmlwriter"
-CONFIGURE_ARGS+=--enable-xmlwriter \
-                --with-libxml-dir=${LOCALBASE}
-
-USE_GNOME=      libxml2
-.endif
-
-.if ${PHP_MODNAME} == "xsl"
-CONFIGURE_ARGS+=--with-xsl=${LOCALBASE}
-
-USE_GNOME=	libxslt
-USE_PHP=	dom:build xml:build
-.endif
-
-.if ${PHP_MODNAME} == "zip"
-LIB_DEPENDS+=	libzip.so:archivers/libzip
-
-CONFIGURE_ARGS+=--enable-zip \
-		--with-zlib-dir=/usr \
-		--with-pcre-dir=${LOCALBASE} \
-		--with-libzip=${LOCALBASE}
-.endif
-
-.if ${PHP_MODNAME} == "zlib"
-CONFIGURE_ARGS+=--with-zlib=/usr
-.endif
-
 .include <bsd.port.options.mk>
 
 .if ${PHP_MODNAME} == "dba"
@@ -560,14 +339,3 @@
 LIB_DEPENDS+=	libct.so:databases/freetds
 .	endif
 .endif
-
-.if ${PHP_MODNAME} == "xml"
-post-extract:
-	@${MKDIR} ${WRKSRC}/ext/xml
-	@${CP} ${WRKSRC}/expat_compat.h ${WRKSRC}/ext/xml
-.endif
-
-.if ${PHP_MODNAME} == "zlib"
-post-extract:
-	@${MV} ${WRKSRC}/config0.m4 ${WRKSRC}/config.m4
-.endif
Index: lang/php72/files/patch-ext_fileinfo_config.m4
===================================================================
--- lang/php72/files/patch-ext_fileinfo_config.m4
+++ lang/php72/files/patch-ext_fileinfo_config.m4
@@ -1,6 +1,6 @@
---- config.m4.orig	2010-09-07 15:45:30.000000000 +0200
-+++ config.m4	2010-09-07 15:46:50.000000000 +0200
-@@ -4,6 +4,9 @@
+--- ext/fileinfo/config.m4.orig	2018-07-17 05:35:51 UTC
++++ ext/fileinfo/config.m4
+@@ -4,6 +4,9 @@ dnl config.m4 for extension fileinfo
  PHP_ARG_ENABLE(fileinfo, for fileinfo support,
  [  --disable-fileinfo      Disable fileinfo support], yes)
  
@@ -10,9 +10,9 @@
  if test "$PHP_FILEINFO" != "no"; then
  
    libmagic_sources=" \
-@@ -13,6 +16,8 @@
-     libmagic/is_tar.c libmagic/magic.c libmagic/print.c \
-     libmagic/readcdf.c libmagic/readelf.c libmagic/softmagic.c"
+@@ -48,6 +51,8 @@ int main(void)
+     libmagic_sources="$libmagic_sources libmagic/strcasestr.c"
+   ])
  
 +  PHP_ADD_INCLUDE($PHP_PCRE_DIR/include)
 +
Index: lang/php72/files/patch-ext_filter_config.m4
===================================================================
--- lang/php72/files/patch-ext_filter_config.m4
+++ lang/php72/files/patch-ext_filter_config.m4
@@ -1,6 +1,6 @@
---- config.m4.orig	2009-03-06 08:25:45.000000000 +0100
-+++ config.m4	2009-03-06 08:28:10.000000000 +0100
-@@ -32,6 +32,7 @@
+--- ext/filter/config.m4.orig	2018-07-17 05:35:50 UTC
++++ ext/filter/config.m4
+@@ -32,6 +32,7 @@ yes
  #endif
        ],[
          PHP_PCRE_REGEX=pecl
Index: lang/php72/files/patch-ext_odbc_config.m4
===================================================================
--- lang/php72/files/patch-ext_odbc_config.m4
+++ lang/php72/files/patch-ext_odbc_config.m4
@@ -1,6 +1,6 @@
---- config.m4.orig	2018-11-10 15:32:27.031531000 +0100
-+++ config.m4	2018-11-10 15:37:40.815007000 +0100
-@@ -100,13 +100,16 @@ dnl
+--- ext/odbc/config.m4.orig	2016-10-25 15:23:21 UTC
++++ ext/odbc/config.m4
+@@ -100,13 +100,17 @@ dnl
  dnl configure options
  dnl
  
Index: lang/php72/files/patch-ext_opcache_zend__file__cache.c
===================================================================
--- lang/php72/files/patch-ext_opcache_zend__file__cache.c
+++ lang/php72/files/patch-ext_opcache_zend__file__cache.c
@@ -1,8 +1,8 @@
---- zend_file_cache.c.orig	2017-07-05 13:48:27 UTC
-+++ zend_file_cache.c
-@@ -24,9 +24,10 @@
- 
- #include "php.h"
+--- ext/opcache/zend_file_cache.c.orig	2018-07-17 05:35:50 UTC
++++ ext/opcache/zend_file_cache.c
+@@ -27,9 +27,10 @@
+ #include "ext/standard/md5.h"
+ #endif
  
 +#include "ZendAccelerator.h"
 +
Index: lang/php72/files/patch-ext_phar_phar.c
===================================================================
--- lang/php72/files/patch-ext_phar_phar.c
+++ lang/php72/files/patch-ext_phar_phar.c
@@ -1,6 +1,6 @@
---- phar.c.orig	2016-06-21 19:56:49 UTC
-+++ phar.c
-@@ -3589,7 +3589,7 @@ static const zend_module_dep phar_deps[]
+--- ext/phar/phar.c.orig	2018-07-17 05:35:47 UTC
++++ ext/phar/phar.c
+@@ -3587,7 +3587,7 @@ static const zend_module_dep phar_deps[]
  	ZEND_MOD_OPTIONAL("openssl")
  	ZEND_MOD_OPTIONAL("zlib")
  	ZEND_MOD_OPTIONAL("standard")
@@ -8,4 +8,4 @@
 +#if defined(HAVE_HASH)
  	ZEND_MOD_REQUIRED("hash")
  #endif
- #if HAVE_SPL
+ 	ZEND_MOD_REQUIRED("spl")
Index: lang/php72/files/patch-ext_posix_posix.c
===================================================================
--- lang/php72/files/patch-ext_posix_posix.c
+++ lang/php72/files/patch-ext_posix_posix.c
@@ -1,6 +1,6 @@
---- posix.c.orig	Fri Feb 23 00:40:39 2007
-+++ posix.c	Sun May 13 17:52:27 2007
-@@ -838,7 +838,7 @@
+--- ext/posix/posix.c.orig	2018-07-17 05:35:50 UTC
++++ ext/posix/posix.c
+@@ -1079,7 +1079,7 @@ PHP_FUNCTION(posix_getgrnam)
  #if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
  	buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
  	if (buflen < 1) {
@@ -9,8 +9,8 @@
  	}
  	buf = emalloc(buflen);
  	g = &gbuf;
-@@ -888,7 +888,7 @@
- 	
+@@ -1130,7 +1130,7 @@ PHP_FUNCTION(posix_getgrgid)
+ 
  	grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
  	if (grbuflen < 1) {
 -		RETURN_FALSE;
@@ -18,7 +18,7 @@
  	}
  
  	grbuf = emalloc(grbuflen);
-@@ -955,7 +955,7 @@
+@@ -1199,7 +1199,7 @@ PHP_FUNCTION(posix_getpwnam)
  #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
  	buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
  	if (buflen < 1) {
@@ -27,7 +27,7 @@
  	}
  	buf = emalloc(buflen);
  	pw = &pwbuf;
-@@ -1004,7 +1004,7 @@
+@@ -1249,7 +1249,7 @@ PHP_FUNCTION(posix_getpwuid)
  #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R)
  	pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
  	if (pwbuflen < 1) {
Index: lang/php72/files/patch-ext_sodium_config.m4
===================================================================
--- lang/php72/files/patch-ext_sodium_config.m4
+++ lang/php72/files/patch-ext_sodium_config.m4
@@ -1,5 +1,5 @@
---- config.m4.orig	2017-11-03 18:32:08 UTC
-+++ config.m4
+--- ext/sodium/config.m4.orig	2017-11-03 18:32:08 UTC
++++ ext/sodium/config.m4
 @@ -50,14 +50,6 @@ if test "$PHP_SODIUM" != "no"; then
      PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBSODIUM_DIR/$PHP_LIBDIR, SODIUM_SHARED_LIBADD)
    fi
Index: lang/php72/files/patch-ext_wddx_config.m4
===================================================================
--- lang/php72/files/patch-ext_wddx_config.m4
+++ lang/php72/files/patch-ext_wddx_config.m4
@@ -1,17 +1,17 @@
---- config.m4.orig	Mon Jul 26 09:05:10 2004
-+++ config.m4	Mon Jul 26 09:07:46 2004
-@@ -5,6 +5,9 @@
- PHP_ARG_ENABLE(wddx,whether to enable WDDX support,
- [  --enable-wddx           Enable WDDX support.])
+--- ext/wddx/config.m4.orig	2018-07-17 05:35:50 UTC
++++ ext/wddx/config.m4
+@@ -13,6 +13,9 @@ fi
+ PHP_ARG_WITH(libexpat-dir, libexpat dir for WDDX,
+ [  --with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)],no,no)
  
 +PHP_ARG_WITH(libxml-dir, libxml2 install dir,
 +[  --with-libxml-dir=<DIR>    WDDX: libxml2 install prefix], no, no)
 +
  if test "$PHP_WDDX" != "no"; then
-   if test "$ext_shared" != "yes" && test "$enable_xml" = "no"; then
-     AC_MSG_WARN(Activating XML)
-@@ -12,4 +15,9 @@
-   fi
+ 
+   dnl
+@@ -55,6 +58,11 @@ if test "$PHP_WDDX" != "no"; then
+ 
    AC_DEFINE(HAVE_WDDX, 1, [ ])
    PHP_NEW_EXTENSION(wddx, wddx.c, $ext_shared)
 +
@@ -19,4 +19,6 @@
 +  ], [
 +    AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.])
 +  ])
+   PHP_ADD_EXTENSION_DEP(wddx, libxml)
+   PHP_SUBST(XMLRPC_SHARED_LIBADD)
  fi
Index: lang/php72/files/patch-ext_wddx_wddx.c
===================================================================
--- lang/php72/files/patch-ext_wddx_wddx.c
+++ lang/php72/files/patch-ext_wddx_wddx.c
@@ -1,8 +1,8 @@
---- wddx.c.orig	Sun Jan  1 13:50:16 2006
-+++ wddx.c	Mon Jan 16 12:56:21 2006
-@@ -18,6 +18,10 @@
- 
- /* $Id: wddx.c,v 1.119.2.8 2006/01/01 12:50:16 sniper Exp $ */
+--- ext/wddx/wddx.c.orig	2018-07-17 05:35:50 UTC
++++ ext/wddx/wddx.c
+@@ -22,6 +22,10 @@
+ #include "config.h"
+ #endif
  
 +#ifdef HAVE_CONFIG_H
 +# include "config.h"
@@ -11,7 +11,7 @@
  #include "php.h"
  
  #if HAVE_WDDX
-@@ -223,7 +227,7 @@
+@@ -260,7 +264,7 @@ static void release_wddx_packet_rsrc(zen
  
  #include "ext/session/php_session.h"
  
@@ -20,7 +20,7 @@
  /* {{{ PS_SERIALIZER_ENCODE_FUNC
   */
  PS_SERIALIZER_ENCODE_FUNC(wddx)
-@@ -302,7 +306,7 @@
+@@ -335,7 +339,7 @@ PHP_MINIT_FUNCTION(wddx)
  {
  	le_wddx = zend_register_list_destructors_ex(release_wddx_packet_rsrc, NULL, "wddx", module_number);
  
@@ -29,7 +29,7 @@
  	php_session_register_serializer("wddx",
  									PS_SERIALIZER_ENCODE_NAME(wddx),
  									PS_SERIALIZER_DECODE_NAME(wddx));
-@@ -317,7 +321,7 @@
+@@ -350,7 +354,7 @@ PHP_MINIT_FUNCTION(wddx)
  PHP_MINFO_FUNCTION(wddx)
  {
  	php_info_print_table_start();
Index: lang/php72/files/patch-ext_xml_compat.c
===================================================================
--- lang/php72/files/patch-ext_xml_compat.c
+++ lang/php72/files/patch-ext_xml_compat.c
@@ -1,5 +1,5 @@
---- compat.c.orig	Tue Jul 20 10:55:02 2004
-+++ compat.c	Tue Jul 20 10:55:55 2004
+--- ext/xml/compat.c.orig	2018-07-17 05:35:50 UTC
++++ ext/xml/compat.c
 @@ -16,6 +16,10 @@
     +----------------------------------------------------------------------+
   */
@@ -9,5 +9,5 @@
 +#endif
 +
  #include "php.h"
- #if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT)
+ #if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT)
  #include "expat_compat.h"
Index: lang/php72/files/patch-ext_xmlrpc_config.m4
===================================================================
--- lang/php72/files/patch-ext_xmlrpc_config.m4
+++ lang/php72/files/patch-ext_xmlrpc_config.m4
@@ -1,5 +1,5 @@
---- config.m4.orig	2014-04-29 08:04:30.000000000 +0000
-+++ config.m4	2014-05-15 08:04:00.883004682 +0000
+--- ext/xmlrpc/config.m4.orig	2018-07-17 05:35:53 UTC
++++ ext/xmlrpc/config.m4
 @@ -61,11 +61,9 @@ if test "$PHP_XMLRPC" != "no"; then
      fi
    fi
Index: lang/php72/files/patch-ext_zlib_zlib.c
===================================================================
--- lang/php72/files/patch-ext_zlib_zlib.c
+++ lang/php72/files/patch-ext_zlib_zlib.c
@@ -1,6 +1,6 @@
---- zlib.c.orig	2016-06-21 19:57:08 UTC
-+++ zlib.c
-@@ -1480,6 +1480,7 @@ static PHP_MSHUTDOWN_FUNCTION(zlib)
+--- ext/zlib/zlib.c.orig	2018-07-17 05:35:47 UTC
++++ ext/zlib/zlib.c
+@@ -1562,6 +1562,7 @@ static PHP_MSHUTDOWN_FUNCTION(zlib)
  /* {{{ PHP_RINIT_FUNCTION */
  static PHP_RINIT_FUNCTION(zlib)
  {
Index: lang/php72/pkg-plist
===================================================================
--- lang/php72/pkg-plist
+++ lang/php72/pkg-plist
@@ -1,14 +1,14 @@
-%%CLI%%bin/php
-%%CGI%%bin/php-cgi
+%%CLI%%@@cli@@bin/php
+%%CGI%%@@cgi@@bin/php-cgi
 bin/php-config
-%%PHPDBG%%bin/phpdbg
+%%PHPDBG%%@@phpdbg@@bin/phpdbg
 bin/phpize
-%%FPM%%sbin/php-fpm
+%%FPM%%@@fpm@@sbin/php-fpm
 etc/php.conf
 etc/php.ini-development
 etc/php.ini-production
-%%FPM%%@sample etc/php-fpm.conf.default etc/php-fpm.conf
-%%FPM%%@sample etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
+%%FPM%%@@fpm@@@sample etc/php-fpm.conf.default etc/php-fpm.conf
+%%FPM%%@@fpm@@@sample etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
 include/php/TSRM/TSRM.h
 include/php/TSRM/readdir.h
 include/php/TSRM/tsrm_config.h
@@ -234,9 +234,9 @@
 include/php/main/streams/php_stream_transport.h
 include/php/main/streams/php_stream_userspace.h
 include/php/main/streams/php_streams_int.h
-%%CLI%%include/php/sapi/cli/cli.h
-%%EMBED%%include/php/sapi/embed/php_embed.h
-%%EMBED%%lib/libphp7.so
+%%CLI%%@@cli@@include/php/sapi/cli/cli.h
+%%EMBED%%@@embed@@include/php/sapi/embed/php_embed.h
+%%EMBED%%@@embed@@lib/libphp7.so
 lib/php/build/Makefile.global
 lib/php/build/ax_check_compile_flag.m4
 lib/php/build/acinclude.m4
@@ -249,10 +249,10 @@
 lib/php/build/run-tests.php
 lib/php/build/scan_makefile_in.awk
 lib/php/build/shtool
-%%CGI%%man/man1/php-cgi.1.gz
+%%CGI%%@@cgi@@man/man1/php-cgi.1.gz
 man/man1/php-config.1.gz
-%%CLI%%man/man1/php.1.gz
-%%PHPDBG%%man/man1/phpdbg.1.gz
+%%CLI%%@@cli@@man/man1/php.1.gz
+%%PHPDBG%%@@phpdbg@@man/man1/phpdbg.1.gz
 man/man1/phpize.1.gz
-%%FPM%%man/man8/php-fpm.8.gz
-%%FPM%%share/php/fpm/status.html
+%%FPM%%@@fpm@@man/man8/php-fpm.8.gz
+%%FPM%%@@fpm@@share/php/fpm/status.html
Index: math/Makefile
===================================================================
--- math/Makefile
+++ math/Makefile
@@ -649,8 +649,6 @@
     SUBDIR += petiga
     SUBDIR += php71-bcmath
     SUBDIR += php71-gmp
-    SUBDIR += php72-bcmath
-    SUBDIR += php72-gmp
     SUBDIR += php73-bcmath
     SUBDIR += php73-gmp
     SUBDIR += php74-bcmath
Index: math/php72-bcmath/Makefile
===================================================================
--- math/php72-bcmath/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	math
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-bcmath
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: math/php72-gmp/Makefile
===================================================================
--- math/php72-gmp/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	math
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-gmp
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: misc/Makefile
===================================================================
--- misc/Makefile
+++ misc/Makefile
@@ -355,7 +355,6 @@
     SUBDIR += pecl-timezonedb
     SUBDIR += pfm
     SUBDIR += php71-calendar
-    SUBDIR += php72-calendar
     SUBDIR += php73-calendar
     SUBDIR += php74-calendar
     SUBDIR += phraze
Index: misc/php72-calendar/Makefile
===================================================================
--- misc/php72-calendar/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	misc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-calendar
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: net/Makefile
===================================================================
--- net/Makefile
+++ net/Makefile
@@ -962,8 +962,6 @@
     SUBDIR += php71-sockets
     SUBDIR += php71-xmlrpc
     SUBDIR += php72-ldap
-    SUBDIR += php72-soap
-    SUBDIR += php72-sockets
     SUBDIR += php72-xmlrpc
     SUBDIR += php73-ldap
     SUBDIR += php73-soap
Index: net/php72-soap/Makefile
===================================================================
--- net/php72-soap/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	net
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-soap
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: net/php72-sockets/Makefile
===================================================================
--- net/php72-sockets/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	net
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-sockets
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: security/Makefile
===================================================================
--- security/Makefile
+++ security/Makefile
@@ -791,10 +791,7 @@
     SUBDIR += php71-hash
     SUBDIR += php71-mcrypt
     SUBDIR += php71-openssl
-    SUBDIR += php72-filter
-    SUBDIR += php72-hash
     SUBDIR += php72-openssl
-    SUBDIR += php72-sodium
     SUBDIR += php73-filter
     SUBDIR += php73-hash
     SUBDIR += php73-openssl
Index: security/php72-filter/Makefile
===================================================================
--- security/php72-filter/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	security
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-filter
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: security/php72-hash/Makefile
===================================================================
--- security/php72-hash/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	security
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-hash
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: security/php72-sodium/Makefile
===================================================================
--- security/php72-sodium/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	security
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-sodium
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: sysutils/Makefile
===================================================================
--- sysutils/Makefile
+++ sysutils/Makefile
@@ -895,8 +895,6 @@
     SUBDIR += phantom
     SUBDIR += php71-fileinfo
     SUBDIR += php71-posix
-    SUBDIR += php72-fileinfo
-    SUBDIR += php72-posix
     SUBDIR += php73-fileinfo
     SUBDIR += php73-posix
     SUBDIR += php74-fileinfo
Index: sysutils/php72-fileinfo/Makefile
===================================================================
--- sysutils/php72-fileinfo/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	sysutils
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-fileinfo
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: sysutils/php72-posix/Makefile
===================================================================
--- sysutils/php72-posix/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	sysutils
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-posix
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/Makefile
===================================================================
--- textproc/Makefile
+++ textproc/Makefile
@@ -1177,16 +1177,7 @@
     SUBDIR += php71-xmlreader
     SUBDIR += php71-xmlwriter
     SUBDIR += php71-xsl
-    SUBDIR += php72-ctype
-    SUBDIR += php72-dom
-    SUBDIR += php72-enchant
-    SUBDIR += php72-pspell
     SUBDIR += php72-simplexml
-    SUBDIR += php72-wddx
-    SUBDIR += php72-xml
-    SUBDIR += php72-xmlreader
-    SUBDIR += php72-xmlwriter
-    SUBDIR += php72-xsl
     SUBDIR += php73-ctype
     SUBDIR += php73-dom
     SUBDIR += php73-enchant
Index: textproc/php72-ctype/Makefile
===================================================================
--- textproc/php72-ctype/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-ctype
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-dom/Makefile
===================================================================
--- textproc/php72-dom/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-dom
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-enchant/Makefile
===================================================================
--- textproc/php72-enchant/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-enchant
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-pspell/Makefile
===================================================================
--- textproc/php72-pspell/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-pspell
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-wddx/Makefile
===================================================================
--- textproc/php72-wddx/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-wddx
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-xml/Makefile
===================================================================
--- textproc/php72-xml/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-xml
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-xmlreader/Makefile
===================================================================
--- textproc/php72-xmlreader/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-xmlreader
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-xmlwriter/Makefile
===================================================================
--- textproc/php72-xmlwriter/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-xmlwriter
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-xsl/Makefile
===================================================================
--- textproc/php72-xsl/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	textproc
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-xsl
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: textproc/php72-xsl/files/patch-php_xsl.h
===================================================================
--- textproc/php72-xsl/files/patch-php_xsl.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- php_xsl.h.orig	Sun Jan  1 13:50:17 2006
-+++ php_xsl.h	Tue Jan 17 16:23:10 2006
-@@ -43,7 +43,7 @@
- #include <libexslt/exsltconfig.h>
- #endif
- 
--#include "../dom/xml_common.h"
-+#include "ext/dom/xml_common.h"
- #include "xsl_fe.h"
- 
- #include <libxslt/extensions.h>
Index: www/Makefile
===================================================================
--- www/Makefile
+++ www/Makefile
@@ -1370,9 +1370,6 @@
     SUBDIR += php71-opcache
     SUBDIR += php71-session
     SUBDIR += php71-tidy
-    SUBDIR += php72-opcache
-    SUBDIR += php72-session
-    SUBDIR += php72-tidy
     SUBDIR += php73-opcache
     SUBDIR += php73-session
     SUBDIR += php73-tidy
Index: www/php72-opcache/Makefile
===================================================================
--- www/php72-opcache/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	www
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-opcache
-
-TEST_TARGET=    test
-
-USES=	php:zend,noflavors
-
-.include "${MASTERDIR}/Makefile"
Index: www/php72-session/Makefile
===================================================================
--- www/php72-session/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	www
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-session
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"
Index: www/php72-tidy/Makefile
===================================================================
--- www/php72-tidy/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-CATEGORIES=	www
-
-MASTERDIR=	${.CURDIR}/../../lang/php72
-
-PKGNAMESUFFIX=	-tidy
-
-TEST_TARGET=    test
-
-.include "${MASTERDIR}/Makefile"