blob: b661071834e42836b2fc81c88ac1158fcdad2140 [file] [log] [blame]
wdenk7ebf7442002-11-02 23:17:16 +00001#!/bin/sh -e
2
3# Script to create header files and links to configure
4# U-Boot for a specific board.
5#
wdenk1d9f4102004-10-09 22:21:29 +00006# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
wdenk7ebf7442002-11-02 23:17:16 +00007#
Marian Balakowiczf9328632006-09-01 19:49:50 +02008# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
wdenk7ebf7442002-11-02 23:17:16 +00009#
10
11APPEND=no # Default: Create new config file
Wolfgang Denk5078cce2006-07-21 11:16:34 +020012BOARD_NAME="" # Name to print in make output
Wolfgang Denk804d83a2009-09-15 22:12:31 +020013TARGETS=""
wdenk7ebf7442002-11-02 23:17:16 +000014
Wolfgang Denka6862bc2010-05-27 23:18:36 +020015arch=""
16cpu=""
17board=""
18vendor=""
19soc=""
20
21if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
22 # Automatic mode
23 line=`egrep -i "^[[:space:]]*${2}[[:space:]]" boards.cfg` || {
24 echo "make: *** No rule to make target \`$2_config'. Stop." >&2
25 exit 1
26 }
27
28 set ${line}
29 # add default board name if needed
30 [ $# = 3 ] && set ${line} ${1}
31fi
32
wdenk7ebf7442002-11-02 23:17:16 +000033while [ $# -gt 0 ] ; do
34 case "$1" in
35 --) shift ; break ;;
36 -a) shift ; APPEND=yes ;;
Wolfgang Denked7a1962010-05-27 23:18:34 +020037 -n) shift ; BOARD_NAME="${1%_config}" ; shift ;;
Wolfgang Denk804d83a2009-09-15 22:12:31 +020038 -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
wdenk7ebf7442002-11-02 23:17:16 +000039 *) break ;;
40 esac
41done
42
43[ $# -lt 4 ] && exit 1
wdenk1d9f4102004-10-09 22:21:29 +000044[ $# -gt 6 ] && exit 1
wdenk7ebf7442002-11-02 23:17:16 +000045
Wolfgang Denka6862bc2010-05-27 23:18:36 +020046CONFIG_NAME="${1%_config}"
47
48[ "${BOARD_NAME}" ] || BOARD_NAME="${CONFIG_NAME}"
49
50arch="$2"
51cpu="$3"
52if [ "$4" = "-" ] ; then
53 board=${BOARD_NAME}
54else
55 board="$4"
56fi
57[ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5"
58[ $# -gt 5 ] && [ "$6" != "-" ] && soc="$6"
59
60if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then
61 echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2
Nishanth Menona8fa3792009-11-02 09:40:18 -060062 exit 1
63fi
64
Wolfgang Denk5078cce2006-07-21 11:16:34 +020065echo "Configuring for ${BOARD_NAME} board..."
wdenk7ebf7442002-11-02 23:17:16 +000066
wdenk7ebf7442002-11-02 23:17:16 +000067#
68# Create link to architecture specific headers
69#
Marian Balakowiczf9328632006-09-01 19:49:50 +020070if [ "$SRCTREE" != "$OBJTREE" ] ; then
71 mkdir -p ${OBJTREE}/include
72 mkdir -p ${OBJTREE}/include2
73 cd ${OBJTREE}/include2
74 rm -f asm
Wolfgang Denka6862bc2010-05-27 23:18:36 +020075 ln -s ${SRCTREE}/arch/${arch}/include/asm asm
76 LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
Marian Balakowiczf9328632006-09-01 19:49:50 +020077 cd ../include
Marian Balakowiczf9328632006-09-01 19:49:50 +020078 rm -f asm
Wolfgang Denka6862bc2010-05-27 23:18:36 +020079 ln -s ${SRCTREE}/arch/${arch}/include/asm asm
Marian Balakowiczf9328632006-09-01 19:49:50 +020080else
81 cd ./include
82 rm -f asm
Wolfgang Denka6862bc2010-05-27 23:18:36 +020083 ln -s ../arch/${arch}/include/asm asm
Marian Balakowiczf9328632006-09-01 19:49:50 +020084fi
85
Peter Tyser819833a2010-04-12 22:28:08 -050086rm -f asm/arch
wdenk86c98882005-04-03 14:26:46 +000087
Wolfgang Denka6862bc2010-05-27 23:18:36 +020088if [ -z "${soc}" ] ; then
89 ln -s ${LNPREFIX}arch-${cpu} asm/arch
wdenk86c98882005-04-03 14:26:46 +000090else
Wolfgang Denka6862bc2010-05-27 23:18:36 +020091 ln -s ${LNPREFIX}arch-${soc} asm/arch
wdenk86c98882005-04-03 14:26:46 +000092fi
wdenk7ebf7442002-11-02 23:17:16 +000093
Wolfgang Denka6862bc2010-05-27 23:18:36 +020094if [ "${arch}" = "arm" ] ; then
Peter Tyser819833a2010-04-12 22:28:08 -050095 rm -f asm/proc
96 ln -s ${LNPREFIX}proc-armv asm/proc
wdenkb783eda2003-06-25 22:26:29 +000097fi
98
wdenk7ebf7442002-11-02 23:17:16 +000099#
100# Create include file for Make
101#
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200102echo "ARCH = ${arch}" > config.mk
103echo "CPU = ${cpu}" >> config.mk
104echo "BOARD = ${board}" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +0000105
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200106[ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk
wdenk1d9f4102004-10-09 22:21:29 +0000107
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200108[ "${soc}" ] && echo "SOC = ${soc}" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +0000109
Stefan Roese7ec1fed2009-10-27 11:46:23 +0100110# Assign board directory to BOARDIR variable
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200111if [ -z "${vendor}" ] ; then
112 BOARDDIR=${board}
Stefan Roese7ec1fed2009-10-27 11:46:23 +0100113else
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200114 BOARDDIR=${vendor}/${board}
Stefan Roese7ec1fed2009-10-27 11:46:23 +0100115fi
116
wdenk7ebf7442002-11-02 23:17:16 +0000117#
118# Create board specific header file
119#
120if [ "$APPEND" = "yes" ] # Append to existing config file
121then
122 echo >> config.h
123else
124 > config.h # Create new config file
125fi
126echo "/* Automatically generated - do not edit */" >>config.h
Wolfgang Denk804d83a2009-09-15 22:12:31 +0200127
128for i in ${TARGETS} ; do
129 echo "#define CONFIG_MK_${i} 1" >>config.h ;
130done
131
Mike Frysinger10c32ff2009-12-02 21:15:03 -0500132cat << EOF >> config.h
133#define CONFIG_BOARDDIR board/$BOARDDIR
134#include <config_defaults.h>
Wolfgang Denka6862bc2010-05-27 23:18:36 +0200135#include <configs/${CONFIG_NAME}.h>
Mike Frysinger10c32ff2009-12-02 21:15:03 -0500136#include <asm/config.h>
137EOF
wdenk7ebf7442002-11-02 23:17:16 +0000138
139exit 0