2 # SPDX-License-Identifier: GPL-2.0
4 # A depmod wrapper used by the toplevel Makefile
7 echo "Usage: $0 /sbin/depmod <kernelrelease> <symbolprefix>" >&2
14 if ! test -r System.map
; then
18 if [ -z $
(command -v $DEPMOD) ]; then
19 echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2
20 echo "This is probably in the kmod package." >&2
24 # older versions of depmod don't support -P <symbol-prefix>
25 # support was added in module-init-tools 3.13
26 if test -n "$SYMBOL_PREFIX"; then
27 release
=$
("$DEPMOD" --version)
28 package
=$
(echo "$release" | cut
-d' ' -f 1)
29 if test "$package" = "module-init-tools"; then
30 version
=$
(echo "$release" | cut
-d' ' -f 2)
31 later
=$
(printf '%s\n' "$version" "3.13" |
sort -V |
tail -n 1)
32 if test "$later" != "$version"; then
33 # module-init-tools < 3.13, drop the symbol prefix
37 if test -n "$SYMBOL_PREFIX"; then
38 SYMBOL_PREFIX
="-P $SYMBOL_PREFIX"
42 # older versions of depmod require the version string to start with three
43 # numbers, so we cheat with a symlink here
44 depmod_hack_needed
=true
45 tmp_dir
=$
(mktemp
-d ${TMPDIR:-/tmp}/depmod.XXXXXX
)
46 mkdir
-p "$tmp_dir/lib/modules/$KERNELRELEASE"
47 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev
/null
; then
48 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
49 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
50 depmod_hack_needed
=false
54 if $depmod_hack_needed; then
55 symlink
="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
56 ln -s "$KERNELRELEASE" "$symlink"
57 KERNELRELEASE
=99.98.
$KERNELRELEASE
60 set -- -ae -F System.map
61 if test -n "$INSTALL_MOD_PATH"; then
62 set -- "$@" -b "$INSTALL_MOD_PATH"
64 "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX
67 if $depmod_hack_needed; then