3 src_files=( $(find -type f -name '*.c') )
4 hdr_files=( $(find -type f -name '*.h') )
6 # Is this a meson build?
8 if [[ -f meson.build ]]; then
12 for hdr in $(find -type f -name '*.h') ; do
13 h_dir="$(basename $(dirname $hdr))"
14 h_file="$(basename $hdr .h)"
16 # Is it listed in the Makefile.am or meson.build?
17 if [[ 1 -eq $isMeson ]]; then
18 if [[ 0 -lt $(grep -c "$h_dir/${h_file}.c" meson.build) ]] || \
19 [[ 0 -lt $(grep -c "$h_dir/${h_file}.h" meson.build) ]]; then
24 if [[ 0 -lt $(grep -c "$h_dir/${h_file}.c" Makefile.am) ]] || \
25 [[ 0 -lt $(grep -c "$h_dir/${h_file}.h" Makefile.am) ]]; then
31 # Is it included in any source files?
32 for src in "${src_files[@]}" ; do
33 is_inc=$(grep -P '^#include' $src | grep -c "${h_file}.h")
34 if [[ 0 -lt $is_inc ]]; then
40 # Is it included in any header files?
41 for src in "${hdr_files[@]}" ; do
43 # If we already removed $src, skip it
44 [ -f "$src" ] || continue 1
46 is_inc=$(grep '#include' $src | grep -c "${h_file}.h")
47 if [[ 0 -lt $is_inc ]]; then
53 # As it was not included, remove it.