Debian Codegraph @

third-party/pjproject/dependency_utils

raw symbols SCIP
1 #!/bin/sh
2
3 [ "x${SED}" = "x" ] && SED=sed
4 [ "x${GREP}" = "x" ] && GREP=grep
5 [ "x${REALPATH}" = "x" ] && REALPATH=realpath
6 [ "x${DIRNAME}" = "x" ] && DIRNAME=dirname
7 [ "x${BASENAME}" = "x" ] && BASENAME=basename
8 [ "x${GREP}" = "x" ] && GREP=grep
9 if [ "x${TARGET_NAME}" = "x" ] ; then
10 if [ ! -f build.mak ] ; then
11 exit 0;
12 fi
13 TARGET_NAME=$(${SED} -n -r -e "s/export\s+TARGET_NAME\s*:=\s*(.*)/\1/gp" build.mak)
14 fi
15
16 getlibname() {
17 dep="$1"
18 libdir=$(${DIRNAME} $(${DIRNAME} "${dep}"))/lib
19 depname=$(${BASENAME} "${dep}")
20 depprefix="${depname%%-${TARGET_NAME}.depend}"
21 case ${depprefix} in
22 .pjlib)
23 libfile=libpj
24 ;;
25 .*)
26 libfile=lib${depprefix#.*}
27 ;;
28 esac
29 echo "${libdir}/${libfile}-${TARGET_NAME}.a"
30 }
31
32 gendepfile() {
33 pjdf="$1"
34 astdf="${pjdf%*.depend}.astdep"
35 dirname=$(${DIRNAME} "${astdf}")
36 lines=$(grep -E -o -- "[.][.]/[^ ]+" "${pjdf}" | sort -u | wc -l)
37 libname=$(getlibname "${pjdf}")
38 backslash="\\"
39 echo "${libname}: ${backslash}" >"${astdf}"
40 for dep in $(grep -E -o -- "[.][.]/[^ ]+" "${pjdf}" | sort -u) ; do
41 ( echo "${dep}" | grep -Eq "(test|/bin/)" ; ) && continue
42 newdep=$( cd "${dirname}" ; ${REALPATH} -L --relative-to=../../ "${dep}" ; )
43 lines=$(( ${lines} - 1 ))
44 if [ ${lines} -eq 0 ] ; then
45 echo "source/${newdep}" >>"${astdf}"
46 else
47 echo "source/${newdep} ${backslash}" >>"${astdf}"
48 fi
49 done
50 echo >>"${astdf}"
51 }
52
53 getpjdepname () {
54 lib="$1"
55 builddir=$(${DIRNAME} $(${DIRNAME} "${lib}"))/build
56 libname=$(${BASENAME} "${lib}")
57 libprefix="${libname%%-${TARGET_NAME}.a}"
58 nolib=$(echo "${libprefix}" | ${SED} -r -e "s@^lib@@g")
59 case ${nolib} in
60 pj)
61 depfile=.pjlib
62 ;;
63 resample)
64 depfile=resample/.libresample
65 ;;
66 *)
67 depfile=.${nolib}
68 ;;
69 esac
70 echo "${builddir}/${depfile}-${TARGET_NAME}.depend"
71 }
72
73 case $1 in
74 getpjdepname)
75 shift
76 for lib in $@ ; do getpjdepname "${lib}" ; done
77 ;;
78 gendepfile)
79 shift
80 for dep in $@ ; do gendepfile "${dep}" ; done
81 ;;
82 getlibname)
83 shift
84 for dep in $@ ; do getlibname "${dep}" ; done
85 ;;
86 *)
87 echo Invalid command
88 exit 1
89 ;;
90 esac