VisionFive2 Linux kernel

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

More than 9999 Commits   33 Branches   55 Tags
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  1) #!/bin/sh
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  2) # SPDX-License-Identifier: GPL-2.0-only
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  3) #
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  4) # Print the assembler name and its version in a 5 or 6-digit form.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  5) # Also, perform the minimum version check.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  6) # (If it is the integrated assembler, return 0 as the version, and
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  7) # skip the version check.)
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  8) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900  9) set -e
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 10) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 11) # Convert the version string x.y.z to a canonical 5 or 6-digit form.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 12) get_canonical_version()
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 13) {
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 14) 	IFS=.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 15) 	set -- $1
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 16) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 17) 	# If the 2nd or 3rd field is missing, fill it with a zero.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 18) 	#
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 19) 	# The 4th field, if present, is ignored.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 20) 	# This occurs in development snapshots as in 2.35.1.20201116
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 21) 	echo $((10000 * $1 + 100 * ${2:-0} + ${3:-0}))
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 22) }
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 23) 
2185a7e4b0ade (Nathan Chancellor 2021-08-16 13:52:47 -0700 24) # Clang fails to handle -Wa,--version unless -fno-integrated-as is given.
2185a7e4b0ade (Nathan Chancellor 2021-08-16 13:52:47 -0700 25) # We check -fintegrated-as, expecting it is explicitly passed in for the
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 26) # integrated assembler case.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 27) check_integrated_as()
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 28) {
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 29) 	while [ $# -gt 0 ]; do
2185a7e4b0ade (Nathan Chancellor 2021-08-16 13:52:47 -0700 30) 		if [ "$1" = -fintegrated-as ]; then
2185a7e4b0ade (Nathan Chancellor 2021-08-16 13:52:47 -0700 31) 			# For the integrated assembler, we do not check the
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 32) 			# version here. It is the same as the clang version, and
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 33) 			# it has been already checked by scripts/cc-version.sh.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 34) 			echo LLVM 0
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 35) 			exit 0
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 36) 		fi
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 37) 		shift
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 38) 	done
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 39) }
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 40) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 41) check_integrated_as "$@"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 42) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 43) orig_args="$@"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 44) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 45) # Get the first line of the --version output.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 46) IFS='
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 47) '
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 48) set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>/dev/null)
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 49) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 50) # Split the line on spaces.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 51) IFS=' '
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 52) set -- $1
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 53) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 54) min_tool_version=$(dirname $0)/min-tool-version.sh
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 55) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 56) if [ "$1" = GNU -a "$2" = assembler ]; then
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 57) 	shift $(($# - 1))
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 58) 	version=$1
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 59) 	min_version=$($min_tool_version binutils)
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 60) 	name=GNU
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 61) else
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 62) 	echo "$orig_args: unknown assembler invoked" >&2
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 63) 	exit 1
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 64) fi
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 65) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 66) # Some distributions append a package release number, as in 2.34-4.fc32
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 67) # Trim the hyphen and any characters that follow.
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 68) version=${version%-*}
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 69) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 70) cversion=$(get_canonical_version $version)
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 71) min_cversion=$(get_canonical_version $min_version)
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 72) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 73) if [ "$cversion" -lt "$min_cversion" ]; then
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 74) 	echo >&2 "***"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 75) 	echo >&2 "*** Assembler is too old."
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 76) 	echo >&2 "***   Your $name assembler version:    $version"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 77) 	echo >&2 "***   Minimum $name assembler version: $min_version"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 78) 	echo >&2 "***"
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 79) 	exit 1
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 80) fi
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 81) 
ba64beb17493a (Masahiro Yamada   2021-03-16 01:12:56 +0900 82) echo $name $cversion