Module Name:    src
Committed By:   matt
Date:           Mon Jun 22 05:59:59 UTC 2015

Modified Files:
        src/distrib/sets: mkvars.mk sets.subr

Log Message:
Using archdirs.mk in compat, automagically generate compat entries for
files tagged with compatfile relative to directories tagged with compatdir.
This also applies to compattestsdirs and compattestsfile when
MKCOMPAT != "no" and MKCOMPATTESTS != "no".
Using archdirs.mk in sys/modules/arch, set list entries are automatically
create for all the other defined variants in ARCHDIR_SUBDIR (if any).
This should cut down on set lists getting out-of-sync a lot.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/distrib/sets/mkvars.mk
cvs rdiff -u -r1.164 -r1.165 src/distrib/sets/sets.subr

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/mkvars.mk
diff -u src/distrib/sets/mkvars.mk:1.18 src/distrib/sets/mkvars.mk:1.19
--- src/distrib/sets/mkvars.mk:1.18	Thu May 28 14:36:44 2015
+++ src/distrib/sets/mkvars.mk	Mon Jun 22 05:59:59 2015
@@ -1,4 +1,4 @@
-# $NetBSD: mkvars.mk,v 1.18 2015/05/28 14:36:44 rjs Exp $
+# $NetBSD: mkvars.mk,v 1.19 2015/06/22 05:59:59 matt Exp $
 
 MKEXTRAVARS= \
 	MACHINE \
@@ -14,6 +14,7 @@ MKEXTRAVARS= \
 	MKMANZ \
 	MKBFD \
 	MKCOMPAT \
+	MKCOMPATTESTS \
 	MKCOMPATMODULES \
 	MKDYNAMICROOT \
 	MKMANPAGES \
@@ -31,7 +32,9 @@ MKEXTRAVARS= \
 	MAKEVERBOSE \
 	TARGET_ENDIANNESS \
 	EABI \
-	ARCH64
+	ARCH64 \
+	COMPATARCHDIRS \
+	KMODARCHDIRS
 
 #####
 
@@ -44,6 +47,16 @@ MKMANPAGES=no
 MKMANPAGES=yes
 .endif
 
+.if ${MKCOMPAT} != "no"
+.include "${NETBSDSRCDIR}/compat/archdirs.mk"
+COMPATARCHDIRS:=${ARCHDIR_SUBDIR:T}
+.endif
+
+.if ${MKKMOD} != "no"
+.include "${NETBSDSRCDIR}/sys/modules/arch/archdirs.mk"
+KMODARCHDIRS:=${ARCHDIR_SUBDIR:T}
+.endif
+
 .if ${MKX11} != "no"
 . if ${X11FLAVOUR} == "Xorg"
 MKXORG:=yes
@@ -81,6 +94,12 @@ mkextravars: .PHONY
 .for i in ${MKEXTRAVARS}
 	@echo $i="${$i}"
 .endfor
+.if ${MKCOMPAT} != "no"
+	@echo COMPATARCHDIRS=${COMPATARCHDIRS} | ${TOOL_SED} -e's/ /,/'
+.endif
+.if ${MKKMOD} != "no"
+	@echo KMODARCHDIRS=${KMODARCHDIRS} | ${TOOL_SED} -e's/ /,/'
+.endif
 
 mksolaris: .PHONY
 .if (${MKDTRACE} != "no" || ${MKZFS} != "no")

Index: src/distrib/sets/sets.subr
diff -u src/distrib/sets/sets.subr:1.164 src/distrib/sets/sets.subr:1.165
--- src/distrib/sets/sets.subr:1.164	Thu May 28 14:36:44 2015
+++ src/distrib/sets/sets.subr	Mon Jun 22 05:59:59 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: sets.subr,v 1.164 2015/05/28 14:36:44 rjs Exp $
+#	$NetBSD: sets.subr,v 1.165 2015/06/22 05:59:59 matt Exp $
 #
 
 #
@@ -179,7 +179,7 @@ SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g
 # In each file, a record consists of a path and a System Package name,
 # separated by whitespace. E.g.,
 #
-# 	# $NetBSD: sets.subr,v 1.164 2015/05/28 14:36:44 rjs Exp $
+# 	# $NetBSD: sets.subr,v 1.165 2015/06/22 05:59:59 matt Exp $
 # 	.			base-sys-root	[keyword[,...]]
 # 	./altroot		base-sys-root
 # 	./bin			base-sys-root
@@ -206,6 +206,7 @@ SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g
 #	catpages		${MKCATPAGES} != no
 #	compat			${MKCOMPAT} != no
 #	compatmodules		${MKCOMPATMODULES} != no
+#	compattests		${MKCOMPATTESTS} != no
 #	crypto			${MKCRYPTO} != no
 #	crypto_rc5		${MKCRYPTO_RC5} != no
 #	cvs			${MKCVS} != no
@@ -291,17 +292,39 @@ list_set_files()
 	print_set_lists "$@" | \
 	${AWK} -v obsolete=${obsolete} '
 		BEGIN {
+			x="tmp.out"
 			if (obsolete)
 				wanted["obsolete"] = 1
 		
 			split("'"${MKVARS}"'", needvars)
+			doingcompat = 0
+			doingcompattests = 0
+			ignoredkeywords["compatdir"] = 1
+			ignoredkeywords["compatfile"] = 1
+			ignoredkeywords["compattestdir"] = 1
+			ignoredkeywords["compattestfile"] = 1
 			for (vi in needvars) {
 				nv = needvars[vi]
 				kw = tolower(nv)
 				sub(/^mk/, "", kw)
 				sub(/^have_/, "", kw)
 				sub(/^target_endianness/, "endian", kw)
-				if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no")
+				if (kw == "compat" && ENVIRON[nv] != "no") {
+					doingcompat = 1;
+					split("'"${COMPATARCHDIRS}"'", compatarchdirs, ",");
+					wanted[kw] = 1 
+					compatdirkeywords["compatdir"] = 1
+					compatfilekeywords["compatfile"] = 1
+				} else if (kw == "compattests" && ENVIRON[nv] != "no") {
+					doingcompattests = 1;
+					compatdirkeywords["compattestdir"] = 1
+					compatfilekeywords["compattestfile"] = 1
+				} else if (kw == "kmod" && ENVIRON[nv] != "no") {
+					split("'"${KMODARCHDIRS}"'", kmodarchdirs, ",");
+					wanted[kw] = 1
+					kmodpat = "./stand/" ENVIRON["MACHINE"]
+					l_kmodpat = length(kmodpat)
+				} else if (nv != "HAVE_GCC" && nv != "HAVE_GDB" && ENVIRON[nv] != "no" && nv != "COMPATDIRS" && nv != "MODULEARCHDIRS")
 					wanted[kw] = 1 
 			}
 
@@ -344,6 +367,9 @@ list_set_files()
 			split($3, keywords, ",")
 			show = 1
 			haveobs = 0
+			havecompat = 0
+			havekmod = 0
+			iscompatdir = 0
 			for (ki in keywords) {
 				kw = keywords[ki]
 				if (("manz" in wanted) &&
@@ -353,22 +379,60 @@ list_set_files()
 					kw = substr(kw, 2)
 					if (kw in wanted)
 						show = 0
+				} else if (kw in compatdirkeywords) {
+					iscompatdir = 1
+				} else if (kw in compatfilekeywords) {
+					havecompat = 1
+				} else if (kw in ignoredkeywords) {
+					# ignore
 				} else {
 					if (! (kw in wanted))
 						show = 0
+					else if (kw == "kmod")
+						havekmod = 1
 				}
 				if (kw == "obsolete")
 					haveobs = 1
 			}
 			if (obsolete && ! haveobs)
 				next
-			if (show)
-				list[$1] = $0
+			if (!show)
+				next
+
+			list[$1] = $0
+			if (havekmod && substr($1,1,l_kmodpat) == kmodpat) {
+				for (d in kmodarchdirs) {
+					xd = "./stand/" kmodarchdirs[d]
+					xfile = xd substr($1, l_kmodpat+1)
+					tmp = xd substr($0, l_kmodpat+1)
+					list[xfile] = tmp;
+				}
+				next
+			}
+
+			if (!doingcompat || !(havecompat || iscompatdir))
+				next
+
+			if (havecompat) {
+				emitcompat[$1] = 1;
+				next;
+			}
+			cpaths[ncpaths++] = $1 "/"
+			for (d in compatarchdirs) {
+				tmp = $0
+				xfile = $1 "/" compatarchdirs[d]
+				tmp = xfile substr(tmp, length($1) + 1)
+				if (xfile in notwanted)
+					continue;
+				sub("compatdir","compat",tmp);
+				sub("compattestdir","compat",tmp);
+				list[xfile] = tmp
+			}
 			next
 		}
 
 		{
-			if (notwanted[$1] != "")
+			if ($1 in notwanted)
 				next;
 			if (! obsolete)
 				list[$1] = $0
@@ -377,6 +441,31 @@ list_set_files()
 		END {
 			for (i in list) {
 				print list[i]
+				if (! (i in emitcompat))
+					continue;
+				l_i = length(i)
+				l = 0
+				for (j in cpaths) {
+					lx = length(cpaths[j])
+					if (lx >= l_i || cpaths[j] != substr(i, 1, lx)) {
+						continue;
+					}
+					if (lx > l) {
+						l = lx;
+						cpath = cpaths[j];
+					}
+				}
+				for (d in compatarchdirs) {
+					tmp = list[i]
+					extrapath = compatarchdirs[d] "/"
+					xfile = cpath extrapath substr(i, l + 1)
+					if (xfile in notwanted)
+						continue;
+					sub("compatfile","compat",tmp);
+					sub("compattestfile","compat",tmp);
+					tmp = xfile substr(tmp, l_i + 1)
+					print tmp;
+				}
 			}
 		}'
 

Reply via email to