Differences between current version and predecessor to the previous major change of KnowledgeBase/FreeBSD/srcsysmod_kmod.sh.
Other diffs: Previous Revision, Previous Author
| Newer page: | version 4 | Last edited on Sunday, 3 October 2010 4:25:35 | by CyberLeo | |
| Older page: | version 2 | Last edited on Monday, 9 August 2010 7:27:49 | by CyberLeo | Revert |
@@ -13,8 +13,79 @@
makefile="${dir}/Makefile"
kmod="$(sed -e "/^KMOD/"\!"d; s/^KMOD[ ${tab}]*=[ ${tab}]*//" "${makefile}")"
# Format and display the results
[ "${kmod}" ] && echo "${dir}${tab}${kmod}"
+ done
+ )
+}
+</code>
+
+Here are some more methods that I'm building to figure out how the 'device foo' lines in the kernel config relate to what modules no longer needs built
+<code brush="bash">
+# Format:
+# /*
+# * include "filename"
+# * filename [ standard | mandatory | optional ]
+# * [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ]
+# * [ compile-with "compile rule" [no-implicit-rule] ]
+# * [ dependency "dependency-list"] [ before-depend ]
+# * [ clean "file-list"] [ warning "text warning" ]
+# */
+
+depfile() {
+ [ "${#}" -gt 0 ] || set - /usr/src/sys/conf/files /usr/src/sys/conf/files.$(uname -m)
+ expand "${@}" | sed -ne '
+ s/^ *#.*$//g
+ s/ *$//g
+ /[^\\]$/ { H; s/.*//g; x; s/^\n//; s/\n/ /g; s/ */ /g; p; }
+ /\\$/ { s/\\$//; H; }
+ '
+}
+
+depfile_devices() {
+ depfile | sed -e '
+ / standard$/d
+ / standard /d
+ s/ no-obj .*$//
+ s/ compile-with .*$//
+ s/ dependency .*$//
+ s/ before-depend .*$//
+ s/ clean .*$//
+ s/ warning .*$//
+ s/ *$//
+ '
+}
+
+devices() {
+ depfile_devices | sed -e '
+ s/^.* mandatory //
+ s/^.* optional //
+ s/|/ /g
+ ' | tr ' ' '\n' | sort -u | grep -v '^$'
+}
+
+device_files() {
+ device="${1}"
+ depfile_devices | sed -e '
+ s/ mandatory / optional /g
+ / optional '${device}'$/s/ optional .*$//
+ / optional '${device}' /s/ optional .*$//
+ / optional .* '${device}' /s/ optional .*$//
+ / optional .* '${device}'$/s/ optional .*$//
+ / optional /d
+ '
+}
+
+srcsysmod_kmod_files() {
+ tab="$(printf "\t")"
+ (
+ cd /usr/src/sys/modules
+ find . -type f -name 'Makefile' | sed -e 's#^\./##' | xargs dirname | sort | while read dir
+ do
+ kmod="$(make -C "./${dir}" -V KMOD)"
+ srcs="$(make -C "./${dir}" -V SRCS | sed -e "s/${tab}/ /g" -e 's/ */ /g')"
+ # Format and display the results
+ [ "${kmod}" ] && echo "${dir}${tab}${kmod}${tab}${srcs}"
done
)
}
</code>
current version
I suggest redirecting the results into a cachefile, because the extraction is pretty slow.
srcsysmod_kmod() {
tab="$(printf "\t")"
(
cd /usr/src/sys/modules
find . -type f -name 'Makefile' | sed -e 's#^\./##' | xargs dirname | sort | while read dir
do
# Slower but more precise
#kmod="$(make -C "./${dir}" -V KMOD)"
# Faster, but might be incorrect if the makefile does voodoo
makefile="${dir}/Makefile"
kmod="$(sed -e "/^KMOD/"\!"d; s/^KMOD[ ${tab}]*=[ ${tab}]*//" "${makefile}")"
# Format and display the results
[ "${kmod}" ] && echo "${dir}${tab}${kmod}"
done
)
}
Here are some more methods that I'm building to figure out how the 'device foo' lines in the kernel config relate to what modules no longer needs built
# Format:
# /*
# * include "filename"
# * filename [ standard | mandatory | optional ]
# * [ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ]
# * [ compile-with "compile rule" [no-implicit-rule] ]
# * [ dependency "dependency-list"] [ before-depend ]
# * [ clean "file-list"] [ warning "text warning" ]
# */
depfile() {
[ "${#}" -gt 0 ] || set - /usr/src/sys/conf/files /usr/src/sys/conf/files.$(uname -m)
expand "${@}" | sed -ne '
s/^ *#.*$//g
s/ *$//g
/[^\\]$/ { H; s/.*//g; x; s/^\n//; s/\n/ /g; s/ */ /g; p; }
/\\$/ { s/\\$//; H; }
'
}
depfile_devices() {
depfile | sed -e '
/ standard$/d
/ standard /d
s/ no-obj .*$//
s/ compile-with .*$//
s/ dependency .*$//
s/ before-depend .*$//
s/ clean .*$//
s/ warning .*$//
s/ *$//
'
}
devices() {
depfile_devices | sed -e '
s/^.* mandatory //
s/^.* optional //
s/|/ /g
' | tr ' ' '\n' | sort -u | grep -v '^$'
}
device_files() {
device="${1}"
depfile_devices | sed -e '
s/ mandatory / optional /g
/ optional '${device}'$/s/ optional .*$//
/ optional '${device}' /s/ optional .*$//
/ optional .* '${device}' /s/ optional .*$//
/ optional .* '${device}'$/s/ optional .*$//
/ optional /d
'
}
srcsysmod_kmod_files() {
tab="$(printf "\t")"
(
cd /usr/src/sys/modules
find . -type f -name 'Makefile' | sed -e 's#^\./##' | xargs dirname | sort | while read dir
do
kmod="$(make -C "./${dir}" -V KMOD)"
srcs="$(make -C "./${dir}" -V SRCS | sed -e "s/${tab}/ /g" -e 's/ */ /g')"
# Format and display the results
[ "${kmod}" ] && echo "${dir}${tab}${kmod}${tab}${srcs}"
done
)
}
