2016-01-27 05:50:18 +03:00
#!/bin/sh
2019-06-04 11:11:33 +03:00
# SPDX-License-Identifier: GPL-2.0-only
2016-01-27 05:50:18 +03:00
2020-02-28 20:20:14 +03:00
# Script to update include/generated/autoksyms.h and dependency files
2016-01-27 05:50:18 +03:00
#
# Copyright: (C) 2016 Linaro Limited
# Created by: Nicolas Pitre, January 2016
#
2020-02-28 20:20:14 +03:00
# Update the include/generated/autoksyms.h file.
2016-01-27 05:50:18 +03:00
#
# For each symbol being added or removed, the corresponding dependency
# file's timestamp is updated to force a rebuild of the affected source
# file. All arguments passed to this script are assumed to be a command
# to be exec'd to trigger a rebuild of those files.
set -e
cur_ksyms_file = "include/generated/autoksyms.h"
new_ksyms_file = "include/generated/autoksyms.h.tmpnew"
info( ) {
if [ " $quiet " != "silent_" ] ; then
printf " %-7s %s\n" " $1 " " $2 "
fi
}
info "CHK" " $cur_ksyms_file "
# Use "make V=1" to debug this script.
case " $KBUILD_VERBOSE " in
*1*)
set -x
; ;
esac
2020-02-28 20:20:14 +03:00
# Generate a new symbol list file
$CONFIG_SHELL $srctree /scripts/gen_autoksyms.sh " $new_ksyms_file "
2016-01-27 05:50:18 +03:00
# Extract changes between old and new list and touch corresponding
# dependency files.
changed = $(
count = 0
sort " $cur_ksyms_file " " $new_ksyms_file " | uniq -u |
2021-08-30 11:20:33 +03:00
sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' |
2016-01-27 05:50:18 +03:00
while read sympath; do
if [ -z " $sympath " ] ; then continue ; fi
2021-08-30 11:20:33 +03:00
depfile = " include/ksym/ ${ sympath } "
2016-01-27 05:50:18 +03:00
mkdir -p " $( dirname " $depfile " ) "
touch " $depfile "
2018-03-15 23:56:20 +03:00
# Filesystems with coarse time precision may create timestamps
# equal to the one from a file that was very recently built and that
# needs to be rebuild. Let's guard against that by making sure our
# dep files are always newer than the first file we created here.
while [ ! " $depfile " -nt " $new_ksyms_file " ] ; do
touch " $depfile "
done
2016-01-27 05:50:18 +03:00
echo $(( count += 1 ))
done | tail -1 )
changed = ${ changed :- 0 }
if [ $changed -gt 0 ] ; then
# Replace the old list with tne new one
old = $( grep -c "^#define __KSYM_" " $cur_ksyms_file " || true )
new = $( grep -c "^#define __KSYM_" " $new_ksyms_file " || true )
info "KSYMS" " symbols: before= $old , after= $new , changed= $changed "
info "UPD" " $cur_ksyms_file "
mv -f " $new_ksyms_file " " $cur_ksyms_file "
# Then trigger a rebuild of affected source files
exec $@
else
rm -f " $new_ksyms_file "
fi