gen-deps.sh (2740B)
1 #!/bin/sh -e 2 3 . package/info 4 5 echo '#' 6 echo '# This file has been generated by tools/gen-deps.sh' 7 echo '#' 8 echo 9 10 internal_libs= 11 12 for dir in src/include/${package} src/* ; do 13 for file in $(ls -1 $dir | grep -- \\.h$) ; do 14 { 15 grep -F -- "#include <${package}/" < ${dir}/$file | cut -d'<' -f2 | cut -d'>' -f1 ; 16 grep -- '#include ".*\.h"' < ${dir}/$file | cut -d'"' -f2 17 } | sort -u | { 18 deps= 19 while read dep ; do 20 if echo $dep | grep -q "^${package}/" ; then 21 deps="$deps src/include/$dep" 22 elif test -f "${dir}/$dep" ; then 23 deps="$deps ${dir}/$dep" 24 else 25 deps="$deps src/include-local/$dep" 26 fi 27 done 28 if test -n "$deps" ; then 29 echo "${dir}/${file}:${deps}" 30 fi 31 } 32 done 33 done 34 35 for dir in src/* ; do 36 for file in $(ls -1 $dir | grep -- \\.c$) ; do 37 { 38 grep -F -- "#include <${package}/" < ${dir}/$file | cut -d'<' -f2 | cut -d'>' -f1 ; 39 grep -- '#include ".*\.h"' < ${dir}/$file | cut -d'"' -f2 40 } | sort -u | { 41 deps=" ${dir}/$file" 42 while read dep ; do 43 if echo $dep | grep -q "^${package}/" ; then 44 deps="$deps src/include/$dep" 45 elif test -f "${dir}/$dep" ; then 46 deps="$deps ${dir}/$dep" 47 else 48 deps="$deps src/include-local/$dep" 49 fi 50 done 51 o=$(echo $file | sed s/\\.c$/.o/) 52 lo=$(echo $file | sed s/\\.c$/.lo/) 53 echo "${dir}/${o} ${dir}/${lo}:${deps}" 54 } 55 done 56 done 57 echo 58 59 for dir in $(ls -1 src | grep -v ^include) ; do 60 for file in $(ls -1 src/$dir/deps-lib) ; do 61 deps= 62 libs= 63 while read dep ; do 64 if echo $dep | grep -q -e ^-l -e '^\${.*_LIB}' ; then 65 libs="$libs $dep" 66 else 67 deps="$deps src/$dir/$dep" 68 fi 69 done < src/$dir/deps-lib/$file 70 echo 'ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)' 71 echo "lib${file}.a.xyzzy:$deps" 72 echo else 73 echo "lib${file}.a.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" 74 echo endif 75 if grep -E "^LIB_DEFS [+:]=" package/targets.mak | grep -qF "$file" ; then 76 echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs" 77 echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" 78 else 79 internal_libs="$internal_libs lib${file}.a.xyzzy" 80 fi 81 done 82 83 for file in $(ls -1 src/$dir/deps-exe) ; do 84 deps= 85 libs= 86 while read dep ; do 87 if echo $dep | grep -q -- \\.o$ ; then 88 dep="src/$dir/$dep" 89 fi 90 if echo $dep | grep -q -e ^-l -e '^\${.*_LIB}' ; then 91 libs="$libs $dep" 92 else 93 deps="$deps $dep" 94 fi 95 done < src/$dir/deps-exe/$file 96 echo "$file: EXTRA_LIBS :=$libs" 97 echo "$file: src/$dir/$file.o$deps" 98 done 99 done 100 echo "INTERNAL_LIBS :=$internal_libs"