aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gen-dotpc.sh
blob: 802c78edf1c4ccac075ca5f844423bed3219c2d4 (plain)
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
#!/bin/sh -e

isunique () {
  x=$1
  set -- $2
  while test "$#" -gt 0 ; do
    if test "$x" = "$1" ; then
      return 1
    fi
    shift
  done
  return 0
}

uniqit () {
  res=
  while test "$#" -gt 0 ; do
    if isunique "$1" "$res" ; then
      res="${res}${res:+ }${1}"
    fi
    shift
  done
  printf %s\\n "$res"
}

filterout () {
  res=
  filter="$1"
  shift
  while test "$#" -gt 0 ; do
    if isunique "$1" "$filter" ; then
      res="${res}${res:+ }${1}"
    fi
    shift
  done
  printf %s\\n "$res"
}

print_requires () {
  line=
  oldifs="$IFS"
  while IFS=" 	" read condvar usedinlibs pkg ver libs ; do
    IFS="$oldifs"
    for h ; do
      i=lib${h##-l}
      for j in $libs ; do
        if test "$i" = "$j" ; then
          line="${line}${line:+, }${i} >= ${ver}"
        fi
      done
    done
  done < package/deps-build
  IFS="$oldifs"
  echo "Requires: $line"
}

. package/info

ilist=
dlist=
slist=

if test "${includedir}" != /usr/include ; then
  ilist="-I${includedir}"
fi
if test -n "${extra_includedirs}" ; then
  ilist="${ilist}${ilist:+ }${extra_includedirs}"
fi
ilist=`uniqit ${ilist}`

if test "${dynlibdir}" != /usr/lib && test "${dynlibdir}" != /lib ; then
  dlist="-L${dynlibdir}"
fi

if test "${libdir}" != /usr/lib && test "${libdir}" != /lib ; then
 slist="-L${libdir}"
fi
if test -n "${extra_libdirs}" ; then
  slist="${slist}${slist:+ }${extra_libdirs}"
fi
slist="$(filterout "${dlist}" $(uniqit ${slist}))"

echo "prefix=${prefix}"
echo "includedir=${includedir}"
echo "libdir=${libdir}"
echo "dynlibdir=${dynlibdir}"
echo
echo "Name: lib${library}"
echo "Version: ${version}"
echo "Description: ${description:-The ${library} library.}"
echo "URL: ${url:-https://skarnet.org/software/${package}/}"
if test -n "${extra_libs}" ; then
  print_requires ${extra_libs}
fi
if test -n "$ilist" ; then
  echo "Cflags: ${ilist}"
fi
echo "Libs: ${dlist}${dlist:+ }-l${library}${ldlibs:+ }${ldlibs}"
if test -n "${extra_libs}" ; then
  echo "Libs.private: ${slist}${slist:+ }${extra_libs}"
fi