add missing stuff from tg@
[openadk.git] / scripts / update-sys
blob925b72a1efef1a35a3af5b0d498ab09113e5dfa3
1 #!/usr/bin/env bash
2 #set -x
3 # 1. create Config.in.systems with all available target systems for each architecture
4 # 2. if ADK configuration exist, create Config.in.arch/Config.in.system with fixed values
5 # 3. exit when native system build is detected
7 topdir=$(readlink -nf $(dirname $0)/.. 2>/dev/null || (cd $(dirname $0)/..; pwd -P))
9 defaults() {
10 echo 'source "target/config/Config.in.arch.default"' > $topdir/target/config/Config.in.arch
11 echo 'source "target/config/Config.in.arch.choice"' >> $topdir/target/config/Config.in.arch
12 echo 'source "target/config/Config.in.system.default"' > $topdir/target/config/Config.in.system
13 echo 'source "target/config/Config.in.system.choice"' >> $topdir/target/config/Config.in.system
14 exit 0
17 check_native() {
18 native=$(grep ^ADK_LINUX_NATIVE $topdir/.config)
19 if [ ! -z "$native" ];then
20 exit 0
24 touch $topdir/target/config/Config.in.native
26 for i in $(ls $topdir/target/);do
27 if [ -d "$topdir/target/$i/sys-enabled" ];then
28 cat $topdir/target/$i/sys-enabled/* > $topdir/target/$i/Config.in.systems 2>/dev/null
30 done
31 if [ -f $topdir/.config ];then
33 check_native
35 arch=$(grep ^ADK_TARGET_ARCH $topdir/.config|cut -f 2 -d = | sed -e 's#"##g')
36 systemsym=$(grep ^ADK_TARGET_SYSTEM_ $topdir/.config|cut -f 1 -d =)
37 system=$(grep ^ADK_TARGET_SYSTEM= $topdir/.config|cut -f 2 -d = | sed -e 's#"##g')
38 systems=$(grep ^ADK_TARGET_SYSTEM= $topdir/.config|cut -f 2 -d = | sed -e 's#"##g'|sed -e 's#-#_#g')
39 archsym=$(echo ADK_LINUX_$arch|tr '[:lower:]' '[:upper:]')
41 if [ -z "$arch" -o -z "$system" ];then
42 defaults
45 cat > $topdir/target/config/Config.in.arch << EOF
46 source "target/config/Config.in.arch.default"
47 config $archsym
48 boolean
49 EOF
51 if [ "${system}" = "toolchain" -o "${system}" = "qemu" ];then
52 sys=${system}-$arch
53 else
54 sys=$system
57 cat > $topdir/target/config/Config.in.system << EOF
58 source "target/config/Config.in.system.default"
59 comment "Architecture: $arch"
60 comment "System: $system"
62 config $systemsym
63 boolean
64 select $archsym
65 $(grep select $topdir/target/$arch/sys-available/$sys)
66 default y
67 EOF
68 else
69 defaults
71 exit 0