#!/bin/bash# $1: TOPDIR if specifiedCURDIR=$(pwd)TOPDIR=$CURDIRTMPHDR=/tmp/.tmp.headers[ -n "$1" ] && TOPDIR=$1header_files=$(find ${TOPDIR} -name "*.h")echo -n > $TMPHDRfor h in $header_filesdo echo ${h#${TOPDIR}/} >> $TMPHDRdoneunhandled_headers=target_files=$(find ${CURDIR} -name "*.c" -o -name "*.h")for t in $target_filesdo echo "Handling ${t#${CURDIR}/}..." _headers=$(grep "#include" $t | awk '{print $2}') for h in ${_headers} do echo -n " $h" [ "${h:0:1}" == "<" ] && echo && continue # 1 for the double-quote nh=$(grep -w ${h:1:0-1} $TMPHDR 2>/dev/null) if [ -z "$nh" ]; then unhandled_headers="$unhandled_headers $h" echo continue fi [ "${nh:0:8}" == "include/" ] && nh=${nh#"include/"} echo " ---> <$nh>" sed -i "s@$h@<$nh>@g" $t donedoneecho "Header files not handled: $unhandled_headers"#rm -f $TMPHDR