2 # SPDX-License-Identifier: GPL-2.0
4 # A depmod wrapper used by the toplevel Makefile
7 echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
13 if ! test -r System.map ; then
14 echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
18 # legacy behavior: "depmod" in /sbin, no /sbin in PATH
20 if [ -z $(command -v $DEPMOD) ]; then
21 echo "Warning: 'make modules_install' requires $DEPMOD. Please install it." >&2
22 echo "This is probably in the kmod package." >&2
26 # older versions of depmod require the version string to start with three
27 # numbers, so we cheat with a symlink here
28 depmod_hack_needed=true
29 tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX)
30 mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE"
31 if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then
32 if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \
33 -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then
34 depmod_hack_needed=false
38 if $depmod_hack_needed; then
39 symlink="$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE"
40 ln -s "$KERNELRELEASE" "$symlink"
41 KERNELRELEASE=99.98.$KERNELRELEASE
44 set -- -ae -F System.map
45 if test -n "$INSTALL_MOD_PATH"; then
46 set -- "$@" -b "$INSTALL_MOD_PATH"
48 "$DEPMOD" "$@" "$KERNELRELEASE"
51 if $depmod_hack_needed; then