4 export TOPDIR=$(realpath ..)
5 if gmake --help >/dev/null 2>&1; then
10 GMAKE="$GMAKE --no-print-directory"
11 (( x_cols = (COLUMNS > 10) ? COLUMNS - 2 : 80 ))
12 typeset -L$x_cols pbar
14 # build a cache of “ipkg package name” → “package conf option” for
15 # use with dependency resolution
18 for dn in */Makefile; do
20 pbar="Pass 1: $dn ..."
24 # ALL_PKGOPTS: all subpackage conf options
25 # PKGNAME_*: subpackage (ipkg) package name, by subpackage option
26 eval $($GMAKE dump="ALL_PKGOPTS \
27 \$(foreach x,\${ALL_PKGOPTS},PKGNAME_\${x})")
30 if [[ -z $ALL_PKGOPTS ]]; then
31 #print -u2 "Warning: $dn/Makefile contains no packages, skipped"
35 for spcu in $ALL_PKGOPTS; do # spcu: package option, ucase
36 eval sppn=\$PKGNAME_$spcu # sppn: subpackage (ipkg) name
37 # once mksh R40 is out, use its new associative arrays here!
38 print -r -- "$spcu" >pkglist.d/"$sppn"
42 # build Config.in files and resolve dependencies
43 for dn in */Makefile; do
45 # skip if we take care of this one manually
46 [[ -s $dn/Config.in.manual ]] && continue
47 pbar="Pass 2: $dn ..."
51 # PKG_NAME: package name (directory, free-format)
52 # PKG_FLAVOURS: all package flavours (boolean options), uppercase
53 # PKG_DESCR: package description (directory)
54 # PKG_URL: package homepage
55 # PKG_CXX: uppercase varname part to use for CFrustFrust checks
56 # ALL_PKGOPTS: all subpackage conf options
57 # PKGNAME_*: subpackage (ipkg) package name, by subpackage option
58 # PKGDESC_*: subpackage description, by subpackage option
59 # PKGDEPS_*: subpackage depends on ipkg packages, by subpkg option
60 # PKGDFLT_*: subpackage 'default {:-n}', by subpackage option
61 # CFLINE_*: one free-format Config.in line per subpackage option
62 # PKGFD_*: flavour description, per package flavour option
63 # PKG_{HOST,TARGET}_DEPENDS: add host or target dependencies
64 eval $($GMAKE dump="PKG_NAME PKG_FLAVOURS PKG_DESCR PKG_URL PKG_MULTI PKG_CXX \
65 ALL_PKGOPTS \$(foreach x,\${ALL_PKGOPTS},PKGNAME_\${x} \
66 PKGDESC_\${x} PKGDEPS_\${x} PKGDFLT_\${x} CFLINE_\${x}) \
67 \$(foreach x,\${PKG_FLAVOURS},PKGFD_\${x}) \
68 PKG_HOST_DEPENDS PKG_TARGET_DEPENDS")
70 # dnu: directory name, uppercase, y/-+/_X/
71 typeset -u dnu=${dn//-/_}
74 ( # fd 4 = Config.in; fd 5 = Config.in.lib
77 # Handle master package (directory)
78 print -u4 "config ADK_COMPILE_$dnu"
79 if [[ -z $ALL_PKGOPTS ]]; then
80 # pseudo package, does not produce an ipkg package
81 ppnf=$PKG_NAME # ppnf: pseudopkg name, filled
82 if [[ -n $PKG_DESCR ]]; then
83 while (( ${#ppnf} < 34 )); do
86 ppnf="$ppnf $PKG_DESCR"
88 print -u4 "\tprompt \"$ppnf\""
91 if [[ -n $ALL_PKGOPTS ]]; then
92 # real (master) package, contains 1+ ipkg (sub)packages
93 print -nu4 \\tdepends on
94 sp=' ' # local sp: space (or ' || ')
95 for spcu in $ALL_PKGOPTS; do # spcu: package option, ucase
96 if [[ -n $PKG_MULTI ]]; then
97 if [[ $dnu != $spcu ]]; then
98 print -nu4 "${sp}ADK_PACKAGE_$spcu"
101 print -nu4 "${sp}ADK_HAVE_DOT_CONFIG"
105 print -nu4 "${sp}ADK_PACKAGE_$spcu"
111 print -u4 \\tdefault n
113 # Handle NOT/ONLY_FOR_PLATFORM alikes
114 phd= # phd: PKG_HOST_DEPENDS expand.
115 if [[ -n $PKG_HOST_DEPENDS ]]; then
117 if [[ $PKG_HOST_DEPENDS = *\!* ]]; then
122 for x in $PKG_HOST_DEPENDS; do
124 phd="$phd${sp}ADK_HOST_$x"
125 if [[ $PKG_HOST_DEPENDS = *\!* ]]; then
132 ptd= # ptd: PKG_TARGET_DEPENDS exp.
133 if [[ -n $PKG_TARGET_DEPENDS ]]; then
135 sp=' ' # local sp: space (or ' || ')
136 if [[ $PKG_TARGET_DEPENDS = *\!* ]]; then
141 for x in $PKG_TARGET_DEPENDS; do
143 #XXX cache this with mksh R40+
145 while read friendlyname sym; do
146 [[ $friendlyname = $x ]] || continue
149 done <../../target/target.lst
150 if (( !found )); then
151 print -u2 "$dn: Target '$x' not found!"
155 if [[ $PKG_TARGET_DEPENDS = *\!* ]]; then
163 # Handle subpackages / multipackages
164 for spcu in $ALL_PKGOPTS; do # spcu: package option, ucase
165 eval sppn=\$PKGNAME_$spcu # sppn: subpackage (ipkg) name
166 eval desc=\$PKGDESC_$spcu # desc: subpackage description
167 : ${desc:=$PKG_DESCR} # take from main pkg if empty
168 eval deps=\$PKGDEPS_$spcu # deps: subpackage dependencies
169 eval dflt=\$PKGDFLT_$spcu # dflt: config 'default' opt.
170 eval xline=\$CFLINE_$spcu # xline: one free-format line
172 if [[ $spcu = LIB* ]]; then
173 h=5 # divert to Config.in.lib
174 (( g5++ )) && print -u5 # been here before
176 h=4 # divert to Config.in
180 print -u$h config ADK_PACKAGE_$spcu
181 spnf=$sppn # spnf: subpackage name, filled
182 if [[ -n ${desc:-$PKG_NAME} ]]; then
183 while (( ${#spnf} < 34 )); do
186 spnf="$spnf ${desc:-$PKG_NAME}"
188 print -u$h "\tprompt \"$spnf\""
189 print -u$h \\ttristate
190 if [[ -n $PKG_MULTI ]]; then
191 if [[ $spcu != $dnu ]]; then
192 print -u$h "\tdepends on ADK_PACKAGE_$dnu"
195 [[ -n $phd ]] && print -u$h "$phd"
196 [[ -n $ptd ]] && print -u$h "$ptd"
197 print -u$h "\tdefault ${dflt:-n}"
198 for dep in $deps; do # dep: ipkg name of one rundep.
199 # skip dependencies on uclibc++ and libstdcxx iff
200 # we produce these automatically
201 [[ -n $PKG_CXX && $dep = @(uclibc++|libstdcxx) ]] && \
205 # produce dependency on kernel package
206 # which have special name→sym mangling
207 typeset -u udep=${dep//-/_}
208 print -u$h "\tselect ADK_KPACKAGE_$udep"
211 # produce dependency on regular package
212 # where the symbol is cached (see above)
213 print -u$h '\tselect' \
214 ADK_PACKAGE_$(<../pkglist.d/"$dep")
218 print -u$h \\tselect ADK_COMPILE_$dnu
219 [[ -n $xline ]] && print -u$h "\t$xline"
220 if [[ -n $desc$PKG_URL ]]; then
221 # produce (optional) help text
223 [[ -n $desc ]] && print -u$h "\t $desc"
224 [[ -n $desc && -n $PKG_URL ]] && print -u$h '\t '
225 [[ -n $PKG_URL ]] && print -u$h "\t WWW: $PKG_URL"
229 # Handle CFrustFrust library selection, if necessary
230 [[ -n $PKG_CXX ]] && cat >&4 <<EOF
233 prompt "C++ library to use"
234 depends on ADK_COMPILE_$dnu
235 default ADK_COMPILE_${PKG_CXX}_WITH_STDCXX if ADK_TARGET_LIB_GLIBC || ADK_TARGET_LIB_EGLIBC
236 default ADK_COMPILE_${PKG_CXX}_WITH_UCLIBCXX if ADK_TARGET_LIB_UCLIBC
238 config ADK_COMPILE_${PKG_CXX}_WITH_STDCXX
239 bool "GNU C++ library"
240 select ADK_PACKAGE_LIBSTDCXX
242 config ADK_COMPILE_${PKG_CXX}_WITH_UCLIBCXX
243 bool "uClibc++ library"
244 select ADK_PACKAGE_UCLIBCXX
249 # Handle flavours (per directory)
250 for pfcu in $PKG_FLAVOURS; do # pfcu: pkg flavour conf opt.
251 eval pfd=\$PKGFD_$pfcu # pfd: pkg flavour description
253 print config ADK_PACKAGE_${dnu}_$pfcu
254 print "\tbool \"${pfd:-$PKG_NAME -> flavour $pfcu}\""
256 print \\tdepends on ADK_COMPILE_$dnu
258 print "\t flavour ADK_PACKAGE_${dnu}_$pfcu for $PKG_NAME"
261 ) 4>Config.in 5>Config.in.lib