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
-a -x "$DEPMOD"; then
18 # older versions of depmod don't support -P <symbol-prefix>
19 # support was added in module-init-tools 3.13
20 if test -n "$SYMBOL_PREFIX"; then
21 release
=$
("$DEPMOD" --version)
22 package
=$
(echo "$release" | cut
-d' ' -f 1)
23 if test "$package" = "module-init-tools"; then
24 version
=$
(echo "$release" | cut
-d' ' -f 2)
25 later
=$
(printf '%s\n' "$version" "3.13" |
sort -V |
tail -n 1)
26 if test "$later" != "$version"; then
27 # module-init-tools < 3.13, drop the symbol prefix
31 if test -n "$SYMBOL_PREFIX"; then
32 SYMBOL_PREFIX
="-P $SYMBOL_PREFIX"
36 # older versions of depmod require the version string to start with three
37 # numbers, so we cheat with a symlink here
38 depmod_hack_needed
=true
39 tmp_dir
=$
(mktemp
-d ${TMPDIR:-/tmp}/depmod.XXXXXX
)
40 mkdir
-p "$tmp_dir/lib/modules/$KERNELRELEASE"
41 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev
/null
; then
42 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
43 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
44 depmod_hack_needed
=false
48 if $depmod_hack_needed; then
49 symlink
="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
50 ln -s "$KERNELRELEASE" "$symlink"
51 KERNELRELEASE
=99.98.
$KERNELRELEASE
54 set -- -ae -F System.map
55 if test -n "$INSTALL_MOD_PATH"; then
56 set -- "$@" -b "$INSTALL_MOD_PATH"
58 "$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX
61 if $depmod_hack_needed; then