File: mkreqlib.sh

package info (click to toggle)
di 6.2.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 896 kB
  • sloc: ansic: 9,364; sh: 5,211; perl: 1,749; awk: 463; makefile: 398
file content (108 lines) | stat: -rwxr-xr-x 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
#
# Copyright 2009-2018 Brad Lanam Walnut Creek, CA USA
# Copyright 2020 Brad Lanam Pleasant Hill CA
#

set -f

unset CDPATH
# this is a workaround for ksh93 on solaris
if [ "$1" = "-d" ]; then
  cd $2
  shift
  shift
fi
. ${_MKCONFIG_DIR}/bin/shellfuncs.sh
doshelltest $0 $@

RUNTOPDIR=`pwd`
MKC_FILES=${MKC_FILES:-mkc_files}
CACHEFILE="${MKC_FILES}/mkconfig.cache"

unset GREP_OPTIONS
unset ENV

getlibdata () {
    var=$1
    gdname=$2
    lang=$3

    cmd="${var}=\${mkc_lnk_${gdname}}"
    eval $cmd
}

mkconfigversion

debug=F
OUTLIBFILE="${MKC_FILES}/mkconfig.reqlibs"
while test $# -gt 1; do
  case $1 in
    -X)
      shift
      debug=T
      ;;
    -c)
      shift
      CACHEFILE=$1
      shift
      ;;
    -o|-l)   # -l backwards compatibility
      shift
      OUTLIBFILE=$1
      shift
      ;;
  esac
done

CONFH=$1

ok=1
if [ ! -f "${CONFH}" ]; then
  echo "Unable to locate ${CONFH}"
  ok=0
fi
if [ ! -f "$RUNTOPDIR/$CACHEFILE" ]; then
  echo "Unable to locate $RUNTOPDIR/$CACHEFILE"
  ok=0
fi
if [ $ok -eq 0 ]; then
  exit 1
fi

reqlibs=""
. $RUNTOPDIR/$CACHEFILE

exec 7<&0 < ${CONFH}
dver=0
while read cline; do
  if [ $debug = T ]; then
    echo "cline:$cline:"
  fi
  case $cline in
    "#define _lib_"*1)
      lang=c
      ;;
    *)
      continue
      ;;
  esac

  dosubst cline '#define ' '' ' 1' ''
  getlibdata var $cline $lang
  if [ $debug = T ]; then
    echo "cline:$cline:lang:$lang:var:$var:"
  fi
  if [ "$var" != "" ]; then
    echo $reqlibs | grep -- $var > /dev/null 2>&1
    rc=$?
    if [ $rc -ne 0 ]; then
      doappend reqlibs " $var"
      if [ $debug = T ]; then
        echo "append:$var"
      fi
    fi
  fi
done
exec <&7 7<&-
echo $reqlibs > $OUTLIBFILE