MIPS: eBPF: Always return sign extended 32b values
[linux-stable.git] / scripts / depmod.sh
blobcf5b2b24b3cf13b256e2d9952ff2f2232a8ffd0c
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # A depmod wrapper used by the toplevel Makefile
6 if test $# -ne 3; then
7 echo "Usage: $0 /sbin/depmod <kernelrelease> <symbolprefix>" >&2
8 exit 1
9 fi
10 DEPMOD=$1
11 KERNELRELEASE=$2
12 SYMBOL_PREFIX=$3
14 if ! test -r System.map ; then
15 exit 0
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
21 exit 0
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
34 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
53 rm -rf "$tmp_dir"
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
65 ret=$?
67 if $depmod_hack_needed; then
68 rm -f "$symlink"
71 exit $ret