VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  1) #!/bin/sh
d2912cb15bdda (Thomas Gleixner 2019-06-04 10:11:33 +0200  2) # SPDX-License-Identifier: GPL-2.0-only
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  3) 
cd195bc4775a5 (Quentin Perret  2020-02-28 17:20:14 +0000  4) # Script to update include/generated/autoksyms.h and dependency files
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  5) #
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  6) # Copyright:	(C) 2016  Linaro Limited
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  7) # Created by:	Nicolas Pitre, January 2016
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  8) #
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500  9) 
cd195bc4775a5 (Quentin Perret  2020-02-28 17:20:14 +0000 10) # Update the include/generated/autoksyms.h file.
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 11) #
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 12) # For each symbol being added or removed, the corresponding dependency
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 13) # file's timestamp is updated to force a rebuild of the affected source
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 14) # file. All arguments passed to this script are assumed to be a command
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 15) # to be exec'd to trigger a rebuild of those files.
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 16) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 17) set -e
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 18) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 19) cur_ksyms_file="include/generated/autoksyms.h"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 20) new_ksyms_file="include/generated/autoksyms.h.tmpnew"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 21) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 22) info() {
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 23) 	if [ "$quiet" != "silent_" ]; then
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 24) 		printf "  %-7s %s\n" "$1" "$2"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 25) 	fi
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 26) }
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 27) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 28) info "CHK" "$cur_ksyms_file"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 29) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 30) # Use "make V=1" to debug this script.
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 31) case "$KBUILD_VERBOSE" in
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 32) *1*)
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 33) 	set -x
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 34) 	;;
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 35) esac
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 36) 
cd195bc4775a5 (Quentin Perret  2020-02-28 17:20:14 +0000 37) # Generate a new symbol list file
cd195bc4775a5 (Quentin Perret  2020-02-28 17:20:14 +0000 38) $CONFIG_SHELL $srctree/scripts/gen_autoksyms.sh "$new_ksyms_file"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 39) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 40) # Extract changes between old and new list and touch corresponding
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 41) # dependency files.
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 42) changed=$(
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 43) count=0
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 44) sort "$cur_ksyms_file" "$new_ksyms_file" | uniq -u |
bc7cd2dd1f8e5 (Masahiro Yamada 2021-08-30 17:20:33 +0900 45) sed -n 's/^#define __KSYM_\(.*\) 1/\1/p' |
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 46) while read sympath; do
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 47) 	if [ -z "$sympath" ]; then continue; fi
bc7cd2dd1f8e5 (Masahiro Yamada 2021-08-30 17:20:33 +0900 48) 	depfile="include/ksym/${sympath}"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 49) 	mkdir -p "$(dirname "$depfile")"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 50) 	touch "$depfile"
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 51) 	# Filesystems with coarse time precision may create timestamps
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 52) 	# equal to the one from a file that was very recently built and that
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 53) 	# needs to be rebuild. Let's guard against that by making sure our
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 54) 	# dep files are always newer than the first file we created here.
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 55) 	while [ ! "$depfile" -nt "$new_ksyms_file" ]; do
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 56) 		touch "$depfile"
825d487583089 (Nicolas Pitre   2018-03-15 16:56:20 -0400 57) 	done
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 58) 	echo $((count += 1))
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 59) done | tail -1 )
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 60) changed=${changed:-0}
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 61) 
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 62) if [ $changed -gt 0 ]; then
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 63) 	# Replace the old list with tne new one
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 64) 	old=$(grep -c "^#define __KSYM_" "$cur_ksyms_file" || true)
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 65) 	new=$(grep -c "^#define __KSYM_" "$new_ksyms_file" || true)
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 66) 	info "KSYMS" "symbols: before=$old, after=$new, changed=$changed"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 67) 	info "UPD" "$cur_ksyms_file"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 68) 	mv -f "$new_ksyms_file" "$cur_ksyms_file"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 69) 	# Then trigger a rebuild of affected source files
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 70) 	exec $@
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 71) else
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 72) 	rm -f "$new_ksyms_file"
23121ca2b56b5 (Nicolas Pitre   2016-01-26 21:50:18 -0500 73) fi