aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
authormat <mat@FreeBSD.org>2015-08-21 20:02:50 +0800
committermat <mat@FreeBSD.org>2015-08-21 20:02:50 +0800
commit7567a79611940fd9d87d02727b23325a89f6f2c2 (patch)
treebeac23e9dc06a60a22c29d4b47f346e86e940d9a /Mk
parent4fb7f189994e8d1ba28461dbc806f082289d48cf (diff)
downloadfreebsd-ports-gnome-7567a79611940fd9d87d02727b23325a89f6f2c2.tar.gz
freebsd-ports-gnome-7567a79611940fd9d87d02727b23325a89f6f2c2.tar.zst
freebsd-ports-gnome-7567a79611940fd9d87d02727b23325a89f6f2c2.zip
Optimize opt_IMPLIES.
PR: 191144 Submitted by: hrs Sponsored by: Absolight
Diffstat (limited to 'Mk')
-rw-r--r--Mk/bsd.options.mk32
1 files changed, 29 insertions, 3 deletions
diff --git a/Mk/bsd.options.mk b/Mk/bsd.options.mk
index 16a59fe1924c..d1359f330343 100644
--- a/Mk/bsd.options.mk
+++ b/Mk/bsd.options.mk
@@ -373,11 +373,37 @@ NEW_OPTIONS:= ${NEW_OPTIONS:N${opt}}
## Enable options implied by other options
# _PREVENTS is handled in bsd.port.mk:pre-check-config
-.for count in ${PORT_OPTIONS}
-. for opt in ${PORT_OPTIONS}
-PORT_OPTIONS+= ${${opt}_IMPLIES}
+## 1) Build dependency chain in A.B format:
+_DEPCHAIN=
+.for opt in ${COMPLETE_OPTIONS_LIST}
+. for o in ${${opt}_IMPLIES}
+_DEPCHAIN+= ${opt}.$o
. endfor
.endfor
+## 2) Check each dependency pair and if LHS is in PORT_OPTIONS then add RHS.
+## All of RHS of "RHS.*" (i.e. indirect dependency) are also added for
+## fast convergence.
+_PORT_OPTIONS:= ${PORT_OPTIONS}
+.for count in _0 ${COMPLETE_OPTIONS_LIST}
+### Check if all of the nested dependency are resolved already.
+. if ${count} == _0 || ${_PORT_OPTIONS} != ${PORT_OPTIONS}
+PORT_OPTIONS:= ${_PORT_OPTIONS}
+. for dc in ${_DEPCHAIN}
+. for opt in ${_PORT_OPTIONS}
+_opt=${opt}
+### Add all of direct and indirect dependency only if
+### they are not in ${PORT_OPTIONS}.
+. if !empty(_opt:M${dc:R})
+. for d in ${dc:E} ${_DEPCHAIN:M${dc:E}.*:E}
+. if empty(_PORT_OPTIONS:M$d)
+_PORT_OPTIONS+= $d
+. endif
+. endfor
+. endif
+. endfor
+. endfor
+. endif
+.endfor
# Finally, add options required by slave ports
PORT_OPTIONS+= ${OPTIONS_SLAVE}