blob: cc8a787f88602a9d1e88e7b3d4a1515380e1184b [file] [log] [blame]
Masahiro Yamadac9c2b752014-08-21 11:44:34 +09001#!/bin/sh
2#
3# A wrapper script to adjust Kconfig for U-Boot
4#
Masahiro Yamada72fb32b2015-02-24 22:26:20 +09005# This file will be removed after cleaning up defconfig files
Masahiro Yamadac9c2b752014-08-21 11:44:34 +09006#
7# Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
8#
9# SPDX-License-Identifier: GPL-2.0+
10#
11
12set -e
13
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090014# Make a configuration target
15# Usage:
16# run_make_config <target> <objdir>
17# <target>: Make target such as "config", "menuconfig", "defconfig", etc.
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090018run_make_config () {
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090019 # Linux expects defconfig files in arch/$(SRCARCH)/configs/ directory,
20 # but U-Boot has them in configs/ directory.
21 # Give SRCARCH=.. to fake scripts/kconfig/Makefile.
Masahiro Yamada72fb32b2015-02-24 22:26:20 +090022 $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. $1
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090023}
24
25do_silentoldconfig () {
26 run_make_config silentoldconfig
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090027
28 # If the following part fails, include/config/auto.conf should be
29 # deleted so "make silentoldconfig" will be re-run on the next build.
Masahiro Yamada72fb32b2015-02-24 22:26:20 +090030 $MAKE -f $srctree/scripts/Makefile.autoconf || {
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090031 rm -f include/config/auto.conf
32 exit 1
33 }
34
35 # include/config.h has been updated after "make silentoldconfig".
36 # We need to touch include/config/auto.conf so it gets newer
37 # than include/config.h.
38 # Otherwise, 'make silentoldconfig' would be invoked twice.
39 touch include/config/auto.conf
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090040}
41
42cleanup_after_defconfig () {
43 rm -f configs/.tmp_defconfig
44 # ignore 'Directory not empty' error
45 # without using non-POSIX option '--ignore-fail-on-non-empty'
46 rmdir arch configs 2>/dev/null || true
47}
48
49# Usage:
50# do_board_defconfig <board>_defconfig
51do_board_defconfig () {
52 defconfig_path=$srctree/configs/$1
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090053
Masahiro Yamadaf396a722014-09-04 22:16:15 +090054 if [ ! -r $defconfig_path ]; then
55 echo >&2 "***"
York Sun65071d52014-10-01 08:44:55 -070056 echo >&2 "*** Can't find default configuration \"configs/$1\"!"
Masahiro Yamadaf396a722014-09-04 22:16:15 +090057 echo >&2 "***"
58 exit 1
59 fi
60
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090061 mkdir -p arch configs
Masahiro Yamada72fb32b2015-02-24 22:26:20 +090062 # prefix "*:" is deprecated. Drop it simply.
63 sed -e 's/^[+A-Z]*://' $defconfig_path > configs/.tmp_defconfig
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090064
65 run_make_config .tmp_defconfig || {
66 cleanup_after_defconfig
67 exit 1
68 }
69
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090070 cleanup_after_defconfig
71}
72
Ian Campbellfaef71b2014-10-24 21:20:50 +010073do_board_felconfig () {
74 do_board_defconfig ${1%%_felconfig}_defconfig
75 if ! grep -q CONFIG_ARCH_SUNXI=y .config || ! grep -q CONFIG_SPL=y .config ; then
76 echo "$progname: Cannot felconfig a non-sunxi or non-SPL platform" >&2
77 exit 1
78 fi
Siarhei Siamashka121161f2014-12-25 02:34:47 +020079 sed -i -e 's/\# CONFIG_SPL_FEL is not set/CONFIG_SPL_FEL=y\nCONFIG_UART0_PORT_F=n/g' \
Masahiro Yamada72fb32b2015-02-24 22:26:20 +090080 .config
Ian Campbellfaef71b2014-10-24 21:20:50 +010081}
82
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090083do_others () {
Masahiro Yamada72fb32b2015-02-24 22:26:20 +090084 run_make_config $1
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090085}
86
87progname=$(basename $0)
88target=$1
89
90case $target in
91*_defconfig)
92 do_board_defconfig $target;;
Ian Campbellfaef71b2014-10-24 21:20:50 +010093*_felconfig)
94 do_board_felconfig $target;;
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090095*_config)
Masahiro Yamadacc533e92014-08-28 10:56:55 +090096 # backward compatibility
Masahiro Yamadac9c2b752014-08-21 11:44:34 +090097 do_board_defconfig ${target%_config}_defconfig;;
98silentoldconfig)
99 do_silentoldconfig;;
Masahiro Yamadac9c2b752014-08-21 11:44:34 +0900100*)
101 do_others $target;;
102esac