summaryrefslogtreecommitdiff
path: root/scripts/update-sys
blob: 925b72a1efef1a35a3af5b0d498ab09113e5dfa3 (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
#!/usr/bin/env bash
#set -x
# 1. create Config.in.systems with all available target systems for each architecture
# 2. if ADK configuration exist, create Config.in.arch/Config.in.system with fixed values
# 3. exit when native system build is detected

topdir=$(readlink -nf $(dirname $0)/.. 2>/dev/null || (cd $(dirname $0)/..; pwd -P))

defaults() {
	echo 'source "target/config/Config.in.arch.default"' > $topdir/target/config/Config.in.arch
	echo 'source "target/config/Config.in.arch.choice"' >> $topdir/target/config/Config.in.arch
	echo 'source "target/config/Config.in.system.default"' > $topdir/target/config/Config.in.system
	echo 'source "target/config/Config.in.system.choice"' >> $topdir/target/config/Config.in.system
	exit 0
}

check_native() {
	native=$(grep ^ADK_LINUX_NATIVE $topdir/.config)
	if [ ! -z "$native" ];then
		exit 0
	fi
}

touch $topdir/target/config/Config.in.native

for i in $(ls $topdir/target/);do
	if [ -d "$topdir/target/$i/sys-enabled" ];then
		cat $topdir/target/$i/sys-enabled/* > $topdir/target/$i/Config.in.systems 2>/dev/null
	fi
done
if [ -f $topdir/.config ];then

check_native

arch=$(grep ^ADK_TARGET_ARCH $topdir/.config|cut -f 2 -d = | sed -e 's#"##g')
systemsym=$(grep ^ADK_TARGET_SYSTEM_ $topdir/.config|cut -f 1 -d =) 
system=$(grep ^ADK_TARGET_SYSTEM= $topdir/.config|cut -f 2 -d = | sed -e 's#"##g')
systems=$(grep ^ADK_TARGET_SYSTEM= $topdir/.config|cut -f 2 -d = | sed -e 's#"##g'|sed -e 's#-#_#g')
archsym=$(echo ADK_LINUX_$arch|tr '[:lower:]' '[:upper:]')

if [ -z "$arch" -o -z "$system" ];then
	defaults
fi

cat > $topdir/target/config/Config.in.arch << EOF 	
source "target/config/Config.in.arch.default"
config $archsym
	boolean
EOF

if [ "${system}" = "toolchain" -o "${system}" = "qemu" ];then
	sys=${system}-$arch
else
	sys=$system
fi

cat > $topdir/target/config/Config.in.system << EOF 	
source "target/config/Config.in.system.default"
comment "Architecture: $arch"
comment "System: $system"

config $systemsym
	boolean
	select $archsym
$(grep select $topdir/target/$arch/sys-available/$sys)
	default y
EOF
else
	defaults
fi
exit 0