Fixes: fakevim: use one handler per editor
[qt-creator-color-themes.git] / fix_makefile_header_dependencies.sh
blobeae6819a19e1db1376c83f62314ebc1eeebe6df7
1 #! /usr/bin/env bash
3 WORKER=./fill_deps.sh
4 DEPFILE=deps
6 write_deps_file() {
7 INPUT=$1
8 ESCAPED_OUTPUT=`sed 's/\//\\\\\//g' <<<"$1"`
11 echo '#! /usr/bin/env bash'
12 grep '^\(CXXFLAGS\|INCPATH\|DEFINES\)' ${INPUT} \
13 | sed \
14 -e 's/$(\([^)]\+\))/${\1}/g' \
15 -e 's/"/\\"/g' \
16 -e 's/^\([^ ]\+\) *= *\(.\+\)/\1="\2"/'
17 echo
18 echo 'touch deps'
19 grep '^.$(CXX)' ${INPUT} \
20 | grep -v '$@' \
21 | sed \
22 -e 's/^\t\$(CXX)\(.\+\)$/makedepend \1 -w 1000000 -f '${DEPFILE}' -p "" -a -o .o 2>\/dev\/null/' \
23 -e 's/$(\([^)]\+\))/${\1}/g' \
24 -e 's/\\/\//g'
25 } > "${WORKER}"
26 chmod a+x "${WORKER}"
31 PWD_BACKUP=$PWD
33 while read makefile ; do
34 dir=`dirname "${makefile}"`
35 if [ `find "${dir}" -maxdepth 1 -name '*.cpp' | wc -l 2>/dev/null` -ge 1 ]; then
36 echo "Directory: $dir"
37 cd $dir
38 rm -f "${DEPFILE}"
39 write_deps_file Makefile
40 "${WORKER}"
41 TEMPFILE=`mktemp`
42 sed 's/^.\+\/\([^\/]\+.o:\)/\1/' "${DEPFILE}" > "${TEMPFILE}"
43 mv "${TEMPFILE}" "${DEPFILE}"
44 # rm "${WORKER}"
46 cd ${PWD_BACKUP}
47 echo "include ${DEPFILE}" >> "${makefile}"
49 done < <(find src -name 'Makefile')
51 cd ${PWD_BACKUP}