mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	- Refactor scripts/kallsyms to make it faster and easier to maintain
 
  - Clean up menuconfig
 
  - Provide Clang with hard-coded target triple instead of CROSS_COMPILE
 
  - Use -z pack-relative-relocs flags instead of --use-android-relr-tags
    for arm64 CONFIG_RELR
 
  - Add srcdeb-pkg target to build only a Debian source package
 
  - Add KDEB_SOURCE_COMPRESS option to specify the compression for a
    Debian source package
 
  - Misc cleanups and fixes
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmRM9usVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsGg+UQAKbDv/rlBLsdFOWnFgh8IUE58uUb
 UF/lmbyPQPZS1+z8WS/ec4ONigPd0gcfjI8klaZuYJ2j5xK0Nf+J8KRQlG9vLCDJ
 O0jPV77mKRMkz6UIaa5Dd8MNje8Pn+6T1qev1I9+0dBhyS2csHds3NuDuI/kDehB
 V1097moJcTEUGbNWTgnIA3LckIP51OMUgmT94gntcWcTvuGahRmn+Vvn4pijd6rn
 r3081wejYl+gZ9DGobRT7yXTsGNkHBHJcmK7VaocAL29haNt+rEULvAC1ABEUkaE
 tJMLodybbBiNH441EuUHJBA90yWUxL2EDmTz7kvvYrwem5FsFx6dpuKUXcJpCxW7
 x66qOQHrHC7ZY98heMs07TLz+5yMhAseBSGgf6QDSvX7CP20kCgf7q0IikfhByMo
 ZWrxj5Zg+P6qoqP5NuoZM4waOarz4wN96OAdB4ao3tbMb0kmzdpvI7W9ZuLaBmEP
 iTYm5r6if++a4a09V4WfWOyE0+7TYwSWwl271pIeovZy0p77ulgiYFo8/a9XqKlS
 CrUP1r85zkDHYN/RS4DcbXkqa4RnfYUBd/9h/5zAMLOWwGLRets+/xA4sD2QE9nV
 xzel3AhVrE3uX0QEPOZnFWTUb5TXkYuhrDxkqRGit61XUeP0Ohy6P1ri8f1dI74J
 2huTmg+CZkyfXEff
 =UuFY
 -----END PGP SIGNATURE-----
Merge tag 'kbuild-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada:
 - Refactor scripts/kallsyms to make it faster and easier to maintain
 - Clean up menuconfig
 - Provide Clang with hard-coded target triple instead of CROSS_COMPILE
 - Use -z pack-relative-relocs flags instead of --use-android-relr-tags
   for arm64 CONFIG_RELR
 - Add srcdeb-pkg target to build only a Debian source package
 - Add KDEB_SOURCE_COMPRESS option to specify the compression for a
   Debian source package
 - Misc cleanups and fixes
* tag 'kbuild-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: deb-pkg: specify targets in debian/rules as .PHONY
  sparc: unify sparc32/sparc64 archhelp
  kbuild: rpm-pkg: remove kernel-drm PROVIDES
  kbuild: deb-pkg: add KDEB_SOURCE_COMPRESS to specify source compression
  kbuild: add srcdeb-pkg target
  Makefile: use -z pack-relative-relocs
  kbuild: clang: do not use CROSS_COMPILE for target triple
  kconfig: menuconfig: reorder functions to remove forward declarations
  kconfig: menuconfig: remove unused M_EVENT macro
  kconfig: menuconfig: remove OLD_NCURSES macro
  kbuild: builddeb: Eliminate debian/arch use
  scripts/kallsyms: update the usage in the comment block
  scripts/kallsyms: decrease expand_symbol() / cleanup_symbol_name() calls
  scripts/kallsyms: change the output order
  scripts/kallsyms: move compiler-generated symbol patterns to mksysmap
  scripts/kallsyms: exclude symbols generated by itself dynamically
  scripts/mksysmap: use sed with in-line comments
  scripts/mksysmap: remove comments described in nm(1)
  scripts/kallsyms: remove redundant code for omitting U and N
  kallsyms: expand symbol name into comment for debugging
		
	
			
		
			
				
	
	
		
			296 lines
		
	
	
	
		
			7.4 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			296 lines
		
	
	
	
		
			7.4 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/sh
 | 
						|
#
 | 
						|
# Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
 | 
						|
#
 | 
						|
# Simple script to generate a debian/ directory for a Linux kernel.
 | 
						|
 | 
						|
set -e
 | 
						|
 | 
						|
is_enabled() {
 | 
						|
	grep -q "^$1=y" include/config/auto.conf
 | 
						|
}
 | 
						|
 | 
						|
if_enabled_echo() {
 | 
						|
	if is_enabled "$1"; then
 | 
						|
		echo -n "$2"
 | 
						|
	elif [ $# -ge 3 ]; then
 | 
						|
		echo -n "$3"
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
set_debarch() {
 | 
						|
	if [ -n "$KBUILD_DEBARCH" ] ; then
 | 
						|
		debarch="$KBUILD_DEBARCH"
 | 
						|
		return
 | 
						|
	fi
 | 
						|
 | 
						|
	# Attempt to find the correct Debian architecture
 | 
						|
	case "$UTS_MACHINE" in
 | 
						|
	i386|ia64|alpha|m68k|riscv*)
 | 
						|
		debarch="$UTS_MACHINE" ;;
 | 
						|
	x86_64)
 | 
						|
		debarch=amd64 ;;
 | 
						|
	sparc*)
 | 
						|
		debarch=sparc$(if_enabled_echo CONFIG_64BIT 64) ;;
 | 
						|
	s390*)
 | 
						|
		debarch=s390x ;;
 | 
						|
	ppc*)
 | 
						|
		if is_enabled CONFIG_64BIT; then
 | 
						|
			debarch=ppc64$(if_enabled_echo CONFIG_CPU_LITTLE_ENDIAN el)
 | 
						|
		else
 | 
						|
			debarch=powerpc$(if_enabled_echo CONFIG_SPE spe)
 | 
						|
		fi
 | 
						|
		;;
 | 
						|
	parisc*)
 | 
						|
		debarch=hppa ;;
 | 
						|
	mips*)
 | 
						|
		if is_enabled CONFIG_CPU_LITTLE_ENDIAN; then
 | 
						|
			debarch=mips$(if_enabled_echo CONFIG_64BIT 64)$(if_enabled_echo CONFIG_CPU_MIPSR6 r6)el
 | 
						|
		elif is_enabled CONFIG_CPU_MIPSR6; then
 | 
						|
			debarch=mips$(if_enabled_echo CONFIG_64BIT 64)r6
 | 
						|
		else
 | 
						|
			debarch=mips
 | 
						|
		fi
 | 
						|
		;;
 | 
						|
	aarch64|arm64)
 | 
						|
		debarch=arm64 ;;
 | 
						|
	arm*)
 | 
						|
		if is_enabled CONFIG_AEABI; then
 | 
						|
			debarch=arm$(if_enabled_echo CONFIG_VFP hf el)
 | 
						|
		else
 | 
						|
			debarch=arm
 | 
						|
		fi
 | 
						|
		;;
 | 
						|
	openrisc)
 | 
						|
		debarch=or1k ;;
 | 
						|
	sh)
 | 
						|
		if is_enabled CONFIG_CPU_SH3; then
 | 
						|
			debarch=sh3$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb)
 | 
						|
		elif is_enabled CONFIG_CPU_SH4; then
 | 
						|
			debarch=sh4$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb)
 | 
						|
		fi
 | 
						|
		;;
 | 
						|
	esac
 | 
						|
	if [ -z "$debarch" ]; then
 | 
						|
		debarch=$(dpkg-architecture -qDEB_HOST_ARCH)
 | 
						|
		echo "" >&2
 | 
						|
		echo "** ** **  WARNING  ** ** **" >&2
 | 
						|
		echo "" >&2
 | 
						|
		echo "Your architecture doesn't have its equivalent" >&2
 | 
						|
		echo "Debian userspace architecture defined!" >&2
 | 
						|
		echo "Falling back to the current host architecture ($debarch)." >&2
 | 
						|
		echo "Please add support for $UTS_MACHINE to ${0} ..." >&2
 | 
						|
		echo "" >&2
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
# Create debian/source/ if it is a source package build
 | 
						|
gen_source ()
 | 
						|
{
 | 
						|
	mkdir -p debian/source
 | 
						|
 | 
						|
	echo "3.0 (quilt)" > debian/source/format
 | 
						|
 | 
						|
	{
 | 
						|
		echo "diff-ignore"
 | 
						|
		echo "extend-diff-ignore = .*"
 | 
						|
	} > debian/source/local-options
 | 
						|
 | 
						|
	# Add .config as a patch
 | 
						|
	mkdir -p debian/patches
 | 
						|
	{
 | 
						|
		echo "Subject: Add .config"
 | 
						|
		echo "Author: ${maintainer}"
 | 
						|
		echo
 | 
						|
		echo "--- /dev/null"
 | 
						|
		echo "+++ linux/.config"
 | 
						|
		diff -u /dev/null "${KCONFIG_CONFIG}" | tail -n +3
 | 
						|
	} > debian/patches/config.patch
 | 
						|
	echo config.patch > debian/patches/series
 | 
						|
 | 
						|
	"${srctree}/scripts/package/gen-diff-patch" debian/patches/diff.patch
 | 
						|
	if [ -s debian/patches/diff.patch ]; then
 | 
						|
		sed -i "
 | 
						|
			1iSubject: Add local diff
 | 
						|
			1iAuthor: ${maintainer}
 | 
						|
			1i
 | 
						|
		" debian/patches/diff.patch
 | 
						|
 | 
						|
		echo diff.patch >> debian/patches/series
 | 
						|
	else
 | 
						|
		rm -f debian/patches/diff.patch
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
rm -rf debian
 | 
						|
mkdir debian
 | 
						|
 | 
						|
email=${DEBEMAIL-$EMAIL}
 | 
						|
 | 
						|
# use email string directly if it contains <email>
 | 
						|
if echo "${email}" | grep -q '<.*>'; then
 | 
						|
	maintainer=${email}
 | 
						|
else
 | 
						|
	# or construct the maintainer string
 | 
						|
	user=${KBUILD_BUILD_USER-$(id -nu)}
 | 
						|
	name=${DEBFULLNAME-${user}}
 | 
						|
	if [ -z "${email}" ]; then
 | 
						|
		buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)}
 | 
						|
		email="${user}@${buildhost}"
 | 
						|
	fi
 | 
						|
	maintainer="${name} <${email}>"
 | 
						|
fi
 | 
						|
 | 
						|
if [ "$1" = --need-source ]; then
 | 
						|
	gen_source
 | 
						|
fi
 | 
						|
 | 
						|
# Some variables and settings used throughout the script
 | 
						|
version=$KERNELRELEASE
 | 
						|
if [ -n "$KDEB_PKGVERSION" ]; then
 | 
						|
	packageversion=$KDEB_PKGVERSION
 | 
						|
else
 | 
						|
	packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/init/build-version)
 | 
						|
fi
 | 
						|
sourcename=${KDEB_SOURCENAME:-linux-upstream}
 | 
						|
 | 
						|
if [ "$ARCH" = "um" ] ; then
 | 
						|
	packagename=user-mode-linux
 | 
						|
else
 | 
						|
	packagename=linux-image
 | 
						|
fi
 | 
						|
 | 
						|
debarch=
 | 
						|
set_debarch
 | 
						|
 | 
						|
# Try to determine distribution
 | 
						|
if [ -n "$KDEB_CHANGELOG_DIST" ]; then
 | 
						|
        distribution=$KDEB_CHANGELOG_DIST
 | 
						|
# In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog
 | 
						|
elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
 | 
						|
        : # nothing to do in this case
 | 
						|
else
 | 
						|
        distribution="unstable"
 | 
						|
        echo >&2 "Using default distribution of 'unstable' in the changelog"
 | 
						|
        echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly"
 | 
						|
fi
 | 
						|
 | 
						|
echo $debarch > debian/arch
 | 
						|
extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)"
 | 
						|
extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)"
 | 
						|
 | 
						|
# Generate a simple changelog template
 | 
						|
cat <<EOF > debian/changelog
 | 
						|
$sourcename ($packageversion) $distribution; urgency=low
 | 
						|
 | 
						|
  * Custom built Linux kernel.
 | 
						|
 | 
						|
 -- $maintainer  $(date -R)
 | 
						|
EOF
 | 
						|
 | 
						|
# Generate copyright file
 | 
						|
cat <<EOF > debian/copyright
 | 
						|
This is a packaged upstream version of the Linux kernel.
 | 
						|
 | 
						|
The sources may be found at most Linux archive sites, including:
 | 
						|
https://www.kernel.org/pub/linux/kernel
 | 
						|
 | 
						|
Copyright: 1991 - 2018 Linus Torvalds and others.
 | 
						|
 | 
						|
The git repository for mainline kernel development is at:
 | 
						|
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
 | 
						|
 | 
						|
    This program is free software; you can redistribute it and/or modify
 | 
						|
    it under the terms of the GNU General Public License as published by
 | 
						|
    the Free Software Foundation; version 2 dated June, 1991.
 | 
						|
 | 
						|
On Debian GNU/Linux systems, the complete text of the GNU General Public
 | 
						|
License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
 | 
						|
EOF
 | 
						|
 | 
						|
# Generate a control file
 | 
						|
cat <<EOF > debian/control
 | 
						|
Source: $sourcename
 | 
						|
Section: kernel
 | 
						|
Priority: optional
 | 
						|
Maintainer: $maintainer
 | 
						|
Rules-Requires-Root: no
 | 
						|
Build-Depends: bc, debhelper, rsync, kmod, cpio, bison, flex $extra_build_depends
 | 
						|
Homepage: https://www.kernel.org/
 | 
						|
 | 
						|
Package: $packagename-$version
 | 
						|
Architecture: $debarch
 | 
						|
Description: Linux kernel, version $version
 | 
						|
 This package contains the Linux kernel, modules and corresponding other
 | 
						|
 files, version: $version.
 | 
						|
EOF
 | 
						|
 | 
						|
if [ "${SRCARCH}" != um ]; then
 | 
						|
cat <<EOF >> debian/control
 | 
						|
 | 
						|
Package: linux-libc-dev
 | 
						|
Section: devel
 | 
						|
Provides: linux-kernel-headers
 | 
						|
Architecture: $debarch
 | 
						|
Description: Linux support headers for userspace development
 | 
						|
 This package provides userspaces headers from the Linux kernel.  These headers
 | 
						|
 are used by the installed headers for GNU glibc and other system libraries.
 | 
						|
Multi-Arch: same
 | 
						|
EOF
 | 
						|
 | 
						|
if is_enabled CONFIG_MODULES; then
 | 
						|
cat <<EOF >> debian/control
 | 
						|
 | 
						|
Package: linux-headers-$version
 | 
						|
Architecture: $debarch
 | 
						|
Description: Linux kernel headers for $version on $debarch
 | 
						|
 This package provides kernel header files for $version on $debarch
 | 
						|
 .
 | 
						|
 This is useful for people who need to build external modules
 | 
						|
EOF
 | 
						|
fi
 | 
						|
fi
 | 
						|
 | 
						|
if is_enabled CONFIG_DEBUG_INFO; then
 | 
						|
cat <<EOF >> debian/control
 | 
						|
 | 
						|
Package: linux-image-$version-dbg
 | 
						|
Section: debug
 | 
						|
Architecture: $debarch
 | 
						|
Description: Linux kernel debugging symbols for $version
 | 
						|
 This package will come in handy if you need to debug the kernel. It provides
 | 
						|
 all the necessary debug symbols for the kernel and its modules.
 | 
						|
EOF
 | 
						|
fi
 | 
						|
 | 
						|
cat <<EOF > debian/rules
 | 
						|
#!$(command -v $MAKE) -f
 | 
						|
 | 
						|
srctree ?= .
 | 
						|
KERNELRELEASE = ${KERNELRELEASE}
 | 
						|
 | 
						|
.PHONY: clean build build-arch build-indep binary binary-arch binary-indep
 | 
						|
 | 
						|
build-indep:
 | 
						|
build-arch:
 | 
						|
	\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
 | 
						|
	KERNELRELEASE=\$(KERNELRELEASE) \
 | 
						|
	\$(shell \$(srctree)/scripts/package/deb-build-option) \
 | 
						|
	olddefconfig all
 | 
						|
 | 
						|
build: build-arch
 | 
						|
 | 
						|
binary-indep:
 | 
						|
binary-arch: build-arch
 | 
						|
	\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
 | 
						|
	KERNELRELEASE=\$(KERNELRELEASE) intdeb-pkg
 | 
						|
 | 
						|
clean:
 | 
						|
	rm -rf debian/files debian/linux-*
 | 
						|
	\$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} clean
 | 
						|
 | 
						|
binary: binary-arch
 | 
						|
EOF
 | 
						|
chmod +x debian/rules
 | 
						|
 | 
						|
exit 0
 |