^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # List of exported symbols
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # If the object has no symbol, $NM warns 'no symbols'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # Suppress the stderr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # TODO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # Use -q instead of 2>/dev/null when we upgrade the minimum version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # binutils to 2.37, llvm to 13.0.0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ksyms=$($NM $1 2>/dev/null | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) if [ -z "$ksyms" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) echo "ksymdeps_$1 := \\"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) for s in $ksyms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) echo $s | sed -e 's:^_*: $(wildcard include/ksym/:' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) -e 's:__*:/:g' -e 's/$/.h) \\/'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) echo "$1: \$(ksymdeps_$1)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) echo "\$(ksymdeps_$1):"