summaryrefslogtreecommitdiff
path: root/package/pkgmaker
blob: 23e2a25a55434d82186c282d96801374c39e8871 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cd "$(dirname "$0")"
export TOPDIR=$(realpath ..)
if gmake --help >/dev/null 2>&1; then
	export GMAKE=gmake
else
	export GMAKE=make
fi

rm -rf pkglist.d pkgopts.d
mkdir pkglist.d pkgopts.d
for sd in */Makefile; do
	sd=${sd%/*}
	cd $sd
	pa=$($GMAKE show=ALL_PKGOPTS)		# pa: all subpackage options
	print -r -- $pa >../pkgopts.d/pa-"$sd"
	xa=
	for xu in $pa; do			# xu: package option uppercase
		x=$($GMAKE show=PKGNAME_$xu)	# x: subpackage name
		print -r -- "$xu" >../pkglist.d/"$x"
		xa="$xa $x"
	done
	print -r -- $xa >../pkgopts.d/xa-"$sd"
	cd ..
done

for sd in */Makefile; do
	sd=${sd%/*}
	cd $sd
	pn=$($GMAKE show=PKG_NAME)		# pn: package name
	pfl=$($GMAKE show=PKG_FLAVOURS)		# pfl: all package flavours
	typeset -u dnu=${sd//-/_}		# dnu: subdir name uppercase
	dnu=${dnu//+/X}
	pd=$($GMAKE show=PKG_DESCR)		# pd: package description
	ph=$($GMAKE show=PKG_URL)		# ph: package homepage
	usecxx=$($GMAKE show=PKG_CXX)

	(
	print "config ADK_COMPILE_$dnu"
	print \\ttristate
	print -n \\tdepends on
	sp=' '					# local sp: space (or ' || ')
	for xu in $(<../pkgopts.d/pa-"$sd"); do	# xu: package option uppercase
		print -n "${sp}ADK_PACKAGE_$xu"
		sp=' || '
	done
	print
	print \\tdefault n

	for x in $(<../pkgopts.d/xa-"$sd"); do	# x: subpackage name
		xu=$(<../pkglist.d/"$x")	# xu: package option uppercase
		print \\nconfig ADK_PACKAGE_$xu
		xf=$x				# xf: subpackage name ........
		while (( ${#xf} < 34 )); do
			xf=$xf.
		done
		print "\tprompt \"$xf ${pd:-$pn}\""
		print \\ttristate
		print \\tdefault n
		deps=$($GMAKE show=PKGDEPS_$xu)
		for dep in $deps; do
			[[ -n $usecxx && $dep = @(uclibc++|libstdcxx) ]] && \
			    continue
			case $dep {
			(kmod-*)
				typeset -u udep=${dep//-/_}
				print "\tselect ADK_KPACKAGE_$udep"
				;;
			(*)
				print '\tselect' \
				    ADK_PACKAGE_$(<../pkglist.d/"$dep")
				;;
			}
		done
		print \\tselect ADK_COMPILE_$dnu
		dep=$($GMAKE show=CFLINE_$xu)	# one free-format line
		[[ -n $dep ]] && print "\t$dep"
		if [[ -n $pd$ph ]]; then
			print \\thelp
			[[ -n $pd ]] && print "\t  $pd"
			[[ -n $pd && -n $ph ]] && print '\t  '
			[[ -n $ph ]] && print "\t  $ph"
		fi
	done

	[[ -n $usecxx ]] && cat <<EOF

choice
prompt "C++ library to use"
depends on ADK_COMPILE_$dnu
default ADK_COMPILE_${usecxx}_WITH_STDCXX if ADK_TARGET_LIB_GLIBC || ADK_TARGET_LIB_EGLIBC
default ADK_COMPILE_${usecxx}_WITH_UCLIBCXX if ADK_TARGET_LIB_UCLIBC

config ADK_COMPILE_${usecxx}_WITH_STDCXX
	bool "GNU C++ library"
	select ADK_PACKAGE_LIBSTDCXX

config ADK_COMPILE_${usecxx}_WITH_UCLIBCXX
	bool "uClibc++ library"
	select ADK_PACKAGE_UCLIBCXX

endchoice
EOF

	for pf in $pfl; do			# pf: package flavour
		pfd=$($GMAKE show=PKGFD_$pf)
		print
		print config ADK_PACKAGE_${dnu}_$pf
		print "\tbool \"${pfd:-flavour ADK_PACKAGE_${dnu}_$pf}\""
		print \\tdefault n
		print \\tdepends on ADK_COMPILE_$dnu
		print \\thelp
		print "\t  flavour ADK_PACKAGE_${dnu}_$pf"
	done
	) >Config.new
	cd ..
done