1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0-only 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 set -eu !! 4 set -e 5 5 6 destdir=${1} 6 destdir=${1} 7 7 >> 8 test -n "${srctree}" >> 9 test -n "${SRCARCH}" >> 10 8 is_enabled() { 11 is_enabled() { 9 grep -q "^$1=y" include/config/auto.co 12 grep -q "^$1=y" include/config/auto.conf 10 } 13 } 11 14 12 find_in_scripts() { << 13 find scripts \ << 14 \( -name atomic -o -name dtc - << 15 ! -name unifdef -a ! -name mk_ << 16 } << 17 << 18 mkdir -p "${destdir}" 15 mkdir -p "${destdir}" 19 16 20 ( 17 ( 21 cd "${srctree}" 18 cd "${srctree}" 22 echo Makefile 19 echo Makefile 23 find "arch/${SRCARCH}" -maxdepth 1 -na 20 find "arch/${SRCARCH}" -maxdepth 1 -name 'Makefile*' 24 find "arch/${SRCARCH}" -name generated !! 21 find include scripts -type f -o -type l 25 find "arch/${SRCARCH}" -name Kbuild.pl 22 find "arch/${SRCARCH}" -name Kbuild.platforms -o -name Platform 26 find include \( -name config -o -name !! 23 find "arch/${SRCARCH}" -name include -type d 27 find_in_scripts << 28 ) | tar -c -f - -C "${srctree}" -T - | tar -xf 24 ) | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${destdir}" 29 25 30 { 26 { 31 if is_enabled CONFIG_OBJTOOL; then 27 if is_enabled CONFIG_OBJTOOL; then 32 echo tools/objtool/objtool 28 echo tools/objtool/objtool 33 fi 29 fi 34 30 35 echo Module.symvers !! 31 find "arch/${SRCARCH}/include" Module.symvers include scripts -type f 36 echo "arch/${SRCARCH}/include/generate << 37 echo include/config/auto.conf << 38 echo include/config/kernel.release << 39 echo include/generated << 40 find_in_scripts << 41 32 42 if is_enabled CONFIG_GCC_PLUGINS; then 33 if is_enabled CONFIG_GCC_PLUGINS; then 43 find scripts/gcc-plugins -name 34 find scripts/gcc-plugins -name '*.so' 44 fi 35 fi 45 } | tar -c -f - -T - | tar -xf - -C "${destdir 36 } | tar -c -f - -T - | tar -xf - -C "${destdir}" 46 37 47 # When ${CC} and ${HOSTCC} differ, rebuild hos !! 38 # copy .config manually to be where it's expected to be 48 # !! 39 cp "${KCONFIG_CONFIG}" "${destdir}/.config" 49 # This caters to host programs that participat << 50 # resolve_btfids are out of scope. << 51 if [ "${CC}" != "${HOSTCC}" ]; then << 52 echo "Rebuilding host programs with ${ << 53 << 54 cat <<-'EOF' > "${destdir}/Kbuild" << 55 subdir-y := scripts << 56 EOF << 57 << 58 # HOSTCXX is not overridden. The C++ c << 59 # - scripts/kconfig/qconf, which is un << 60 # - GCC plugins, which will not work o << 61 # being rebuilt. << 62 # << 63 # Use the single-target build to avoid << 64 # would overwrite Module.symvers. << 65 "${MAKE}" HOSTCC="${CC}" KBUILD_EXTMOD << 66 << 67 cat <<-'EOF' > "${destdir}/scripts/Kb << 68 subdir-y := basic << 69 hostprogs-always-y := mod/modpost << 70 mod/modpost-objs := $(addprefix mod/, << 71 EOF << 72 << 73 # Run once again to rebuild scripts/ba << 74 "${MAKE}" HOSTCC="${CC}" KBUILD_EXTMOD << 75 << 76 rm -f "${destdir}/Kbuild" "${destdir}/ << 77 fi << 78 << 79 find "${destdir}" \( -name '.*.cmd' -o -name ' <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.