Merge tag 'nfsd-5.9' of git://git.linux-nfs.org/projects/cel/cel-2.6
[linux/fpc-iii.git] / scripts / gen_autoksyms.sh
blob16c0b2ddaa4c9b9e952e031e9def3f9d8b790af5
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0-only
4 # Create an autoksyms.h header file from the list of all module's needed symbols
5 # as recorded on the second line of *.mod files and the user-provided symbol
6 # whitelist.
8 set -e
10 output_file="$1"
12 # Use "make V=1" to debug this script.
13 case "$KBUILD_VERBOSE" in
14 *1*)
15 set -x
17 esac
19 # We need access to CONFIG_ symbols
20 . include/config/auto.conf
22 ksym_wl=/dev/null
23 if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then
24 # Use 'eval' to expand the whitelist path and check if it is relative
25 eval ksym_wl="$CONFIG_UNUSED_KSYMS_WHITELIST"
26 [ "${ksym_wl}" != "${ksym_wl#/}" ] || ksym_wl="$abs_srctree/$ksym_wl"
27 if [ ! -f "$ksym_wl" ] || [ ! -r "$ksym_wl" ]; then
28 echo "ERROR: '$ksym_wl' whitelist file not found" >&2
29 exit 1
33 # Generate a new ksym list file with symbols needed by the current
34 # set of modules.
35 cat > "$output_file" << EOT
37 * Automatically generated file; DO NOT EDIT.
40 EOT
42 [ -f modules.order ] && modlist=modules.order || modlist=/dev/null
43 sed 's/ko$/mod/' $modlist |
44 xargs -n1 sed -n -e '2{s/ /\n/g;/^$/!p;}' -- |
45 cat - "$ksym_wl" |
46 sort -u |
47 sed -e 's/\(.*\)/#define __KSYM_\1 1/' >> "$output_file"
49 # Special case for modversions (see modpost.c)
50 if [ -n "$CONFIG_MODVERSIONS" ]; then
51 echo "#define __KSYM_module_layout 1" >> "$output_file"