File: getsyslibs.sh

package info (click to toggle)
slsqlite 0.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 604 kB
  • sloc: sh: 3,107; ansic: 1,065; makefile: 183
file content (77 lines) | stat: -rwxr-xr-x 1,270 bytes parent folder | download | duplicates (24)
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
#!/bin/sh

# This script parses /etc/ld.so.conf and returns lib and include directories 
# in a form that JD_CHECK_FOR_LIBRARY can grok.

SH_TRUE=0
SH_FALSE=1

# Usage: sh_substr string a b  ==> string[a:b]  (1s-based)
sh_substr()
{
   echo "$1" | cut "-c" "$2-$3"
}

# if sh_is_comment line; then ...
sh_is_comment()
{
  ch=`sh_substr "$1" 1 1`
  if test "X$ch" = "X#" -o "X$ch" = "X"
  then
     return $SH_TRUE;
  fi
  return $SH_FALSE;
}

sh_read_ldsoconf ()
{
   file="$1"
   dirlist=""
   if test ! -f "$file"
   then
     return $SH_FALSE;
   fi

   while read line
   do
     if sh_is_comment "$line"; then continue; fi
     read p1 p2 pn << EOF
       ${line}
EOF
     if test "$p1" = "include"
     then
       for file in $p2
       do
         dirs=`sh_read_ldsoconf "$file"`
         dirlist="$dirlist $dirs"
       done
     else
       dirlist="$dirlist $p1"
     fi
   done < "$file"
   echo "$dirlist"
}

dirs=`sh_read_ldsoconf "/etc/ld.so.conf"`
XY=""
for Y in $dirs
do
   if test "/usr/lib" = `sh_substr $Y 1 8`
   then
     X="/usr/include"
   else
     if test "/lib" = `sh_substr $Y 1 4`
     then
       X="/usr/include"
     else
       X=`dirname $Y`"/include"
     fi
   fi
   if test -d "$Y"
   then
      XY="$XY $X,$Y"
   fi
done

echo $XY