skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

gen-deps.sh (1343B)


      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 for dir in src/include/${package} src/lib* ; do
     11   for file in $(ls -1 $dir | grep -- \\.h$) ; do
     12     {
     13       grep -F "#include <${package}/" < ${dir}/$file | cut -d/ -f2- | cut -d'>' -f1 ;
     14       grep -- '#include ".*-internal\.h"' < ${dir}/$file | cut -d'"' -f2
     15     } | sort -u | {
     16       deps=
     17       while read dep ; do
     18         if echo $dep | grep -q -- -internal\\.h$ ; then
     19           deps="$deps ${dir}/$dep"
     20         else
     21           deps="$deps src/include/${package}/$dep"
     22         fi
     23       done
     24       if test -n "$deps" ; then
     25         echo "${dir}/${file}:${deps}"
     26       fi
     27     }
     28   done
     29 done
     30 
     31 for dir in src/lib* ; do
     32   for file in $(ls -1 $dir | grep -- \\.c$) ; do
     33     {
     34       grep -F "#include <${package}/" < ${dir}/$file | cut -d/ -f2- | cut -d'>' -f1 ;
     35       grep -- '#include ".*-internal\.h"' < ${dir}/$file | cut -d'"' -f2
     36     } | sort -u | {
     37       deps=" ${dir}/$file"
     38       while read dep ; do
     39         if echo $dep | grep -q -- -internal\\.h$ ; then
     40           deps="$deps ${dir}/$dep"
     41         else
     42           deps="$deps src/include/${package}/$dep"
     43         fi
     44       done
     45       o=$(echo $file | sed s/\\.c$/.o/)
     46       lo=$(echo $file | sed s/\\.c$/.lo/)
     47       echo "${dir}/${o} ${dir}/${lo}:${deps}"
     48     }
     49   done
     50 done