ath10k: add support for controlling tx power to a station
[linux/fpc-iii.git] / kernel / gen_ikh_data.sh
blob591a94f7b3874ffb5d3f31541db2b78c07b98f6d
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # This script generates an archive consisting of kernel headers
5 # for CONFIG_IKHEADERS_PROC.
6 set -e
7 spath="$(dirname "$(readlink -f "$0")")"
8 kroot="$spath/.."
9 outdir="$(pwd)"
10 tarfile=$1
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")")"
18 src_file_list="
19 include/
20 arch/$SRCARCH/include/
21 $sfile
24 obj_file_list="
25 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.
34 # iter=1
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)"
47 popd > /dev/null
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
57 exit
60 if [ "${quiet}" != "silent_" ]; then
61 echo " GEN $tarfile"
64 rm -rf $cpio_dir
65 mkdir $cpio_dir
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
71 popd > /dev/null
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
89 rm -rf $cpio_dir