2 # SPDX-License-Identifier: GPL-2.0
4 # This script generates an archive consisting of kernel headers
5 # for CONFIG_IKHEADERS_PROC.
7 spath
="$(dirname "$
(readlink
-f "$0")")"
11 cpio_dir
=$outdir/$tarfile.tmp
13 # Script filename relative to the kernel source root
14 # We add it to the archive because it is small and any changes
15 # to this script will also cause a rebuild of the archive.
16 sfile
="$(realpath --relative-to $kroot "$
(readlink
-f "$0")")"
20 arch/$SRCARCH/include/
26 arch/$SRCARCH/include/
29 # Support incremental builds by skipping archive generation
30 # if timestamps of files being archived are not changed.
32 # This block is useful for debugging the incremental builds.
33 # Uncomment it for debugging.
35 # if [ ! -f /tmp/iter ]; then echo 1 > /tmp/iter;
36 # else; iter=$(($(cat /tmp/iter) + 1)); fi
37 # find $src_file_list -type f | xargs ls -lR > /tmp/src-ls-$iter
38 # find $obj_file_list -type f | xargs ls -lR > /tmp/obj-ls-$iter
40 # include/generated/compile.h is ignored because it is touched even when none
41 # of the source files changed. This causes pointless regeneration, so let us
42 # ignore them for md5 calculation.
43 pushd $kroot > /dev
/null
44 src_files_md5
="$(find $src_file_list -type f |
45 grep -v "include
/generated
/compile.h
" |
46 xargs ls -lR | md5sum | cut -d ' ' -f1)"
48 obj_files_md5
="$(find $obj_file_list -type f |
49 grep -v "include
/generated
/compile.h
" |
50 xargs ls -lR | md5sum | cut -d ' ' -f1)"
52 if [ -f $tarfile ]; then tarfile_md5
="$(md5sum $tarfile | cut -d ' ' -f1)"; fi
53 if [ -f kernel
/kheaders.md5
] &&
54 [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] &&
55 [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] &&
56 [ "$(cat kernel/kheaders.md5|tail -1)" == "$tarfile_md5" ]; then
60 if [ "${quiet}" != "silent_" ]; then
67 pushd $kroot > /dev
/null
68 for f
in $src_file_list;
69 do find "$f" ! -name "*.cmd" ! -name ".*";
70 done |
cpio --quiet -pd $cpio_dir
73 # The second CPIO can complain if files already exist which can
74 # happen with out of tree builds. Just silence CPIO for now.
75 for f
in $obj_file_list;
76 do find "$f" ! -name "*.cmd" ! -name ".*";
77 done |
cpio --quiet -pd $cpio_dir >/dev
/null
2>&1
79 # Remove comments except SDPX lines
80 find $cpio_dir -type f
-print0 |
81 xargs -0 -P8 -n1 perl
-pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'
83 tar -Jcf $tarfile -C $cpio_dir/ .
> /dev
/null
85 echo "$src_files_md5" > kernel
/kheaders.md5
86 echo "$obj_files_md5" >> kernel
/kheaders.md5
87 echo "$(md5sum $tarfile | cut -d ' ' -f1)" >> kernel
/kheaders.md5