2021-09-16 06:50:03 +02:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
echo "Usage: $0 <cfilepath>...; removes #includes one at a time and checks compile" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
CCMD=$(make show-flags | sed -n 's/CC://p')
|
|
|
|
for file; do
|
|
|
|
i=1
|
|
|
|
echo "$file":
|
|
|
|
while true; do
|
|
|
|
# Don't eliminate config.h includes!
|
|
|
|
LINE="$(grep '^#include <' "$file" | grep -v '[<"]config.h[">]' | tail -n +$i | head -n1)"
|
|
|
|
[ -n "$LINE" ] || break
|
|
|
|
# Make sure even headers end in .c
|
|
|
|
grep -F -v "$LINE" "$file" > "$file".c
|
|
|
|
|
|
|
|
if $CCMD /tmp/out.$$.o "$file".c 2>/dev/null; then
|
2022-11-09 03:32:01 +01:00
|
|
|
printf "%s" "-$LINE"
|
2021-09-16 06:50:03 +02:00
|
|
|
mv "$file".c "$file"
|
|
|
|
else
|
2022-11-09 03:32:01 +01:00
|
|
|
# shellcheck disable=SC2039,SC3037
|
|
|
|
printf "."
|
2021-09-16 06:50:03 +02:00
|
|
|
rm -f "$file".c
|
|
|
|
i=$((i + 1))
|
|
|
|
fi
|
|
|
|
rm -f /tmp/out.$$.o
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
done
|