blob: 0f7f13e3a4d836d6bb8a1ab18b34e63a4125cc2c [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#
wdenkf8e9a232004-10-09 22:21:29 +00006# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
wdenk7ebf7442002-11-02 23:17:16 +00007#
Marian Balakowiczd62379d2006-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 Denk99753142006-07-21 11:16:34 +020012BOARD_NAME="" # Name to print in make output
Wolfgang Denk61cf0512009-09-15 22:12:31 +020013TARGETS=""
wdenk7ebf7442002-11-02 23:17:16 +000014
15while [ $# -gt 0 ] ; do
16 case "$1" in
17 --) shift ; break ;;
18 -a) shift ; APPEND=yes ;;
Wolfgang Denk99753142006-07-21 11:16:34 +020019 -n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
Wolfgang Denk61cf0512009-09-15 22:12:31 +020020 -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
wdenk7ebf7442002-11-02 23:17:16 +000021 *) break ;;
22 esac
23done
24
Wolfgang Denk99753142006-07-21 11:16:34 +020025[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
26
wdenk7ebf7442002-11-02 23:17:16 +000027[ $# -lt 4 ] && exit 1
wdenkf8e9a232004-10-09 22:21:29 +000028[ $# -gt 6 ] && exit 1
wdenk7ebf7442002-11-02 23:17:16 +000029
Nishanth Menone83cc362009-11-02 09:40:18 -060030if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
31 echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
32 exit 1
33fi
34
Wolfgang Denk99753142006-07-21 11:16:34 +020035echo "Configuring for ${BOARD_NAME} board..."
wdenk7ebf7442002-11-02 23:17:16 +000036
wdenk7ebf7442002-11-02 23:17:16 +000037#
38# Create link to architecture specific headers
39#
Marian Balakowiczd62379d2006-09-01 19:49:50 +020040if [ "$SRCTREE" != "$OBJTREE" ] ; then
41 mkdir -p ${OBJTREE}/include
42 mkdir -p ${OBJTREE}/include2
43 cd ${OBJTREE}/include2
44 rm -f asm
45 ln -s ${SRCTREE}/include/asm-$2 asm
46 LNPREFIX="../../include2/asm/"
47 cd ../include
48 rm -rf asm-$2
49 rm -f asm
50 mkdir asm-$2
51 ln -s asm-$2 asm
52else
53 cd ./include
54 rm -f asm
55 ln -s asm-$2 asm
56fi
57
wdenk7ebf7442002-11-02 23:17:16 +000058rm -f asm-$2/arch
wdenkf9c57a22005-04-03 14:26:46 +000059
Wolfgang Denk31c939b2005-08-03 22:58:55 +020060if [ -z "$6" -o "$6" = "NULL" ] ; then
Marian Balakowiczd62379d2006-09-01 19:49:50 +020061 ln -s ${LNPREFIX}arch-$3 asm-$2/arch
wdenkf9c57a22005-04-03 14:26:46 +000062else
Marian Balakowiczd62379d2006-09-01 19:49:50 +020063 ln -s ${LNPREFIX}arch-$6 asm-$2/arch
wdenkf9c57a22005-04-03 14:26:46 +000064fi
wdenk7ebf7442002-11-02 23:17:16 +000065
wdenkbb2d9272003-06-25 22:26:29 +000066if [ "$2" = "arm" ] ; then
67 rm -f asm-$2/proc
Marian Balakowiczd62379d2006-09-01 19:49:50 +020068 ln -s ${LNPREFIX}proc-armv asm-$2/proc
wdenkbb2d9272003-06-25 22:26:29 +000069fi
70
wdenk7ebf7442002-11-02 23:17:16 +000071#
72# Create include file for Make
73#
wdenkf8e9a232004-10-09 22:21:29 +000074echo "ARCH = $2" > config.mk
75echo "CPU = $3" >> config.mk
76echo "BOARD = $4" >> config.mk
77
78[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +000079
wdenkf8e9a232004-10-09 22:21:29 +000080[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +000081
Stefan Roese995611e2009-10-27 11:46:23 +010082# Assign board directory to BOARDIR variable
83if [ -z "$5" -o "$5" = "NULL" ] ; then
84 BOARDDIR=$4
85else
86 BOARDDIR=$5/$4
87fi
88
wdenk7ebf7442002-11-02 23:17:16 +000089#
90# Create board specific header file
91#
92if [ "$APPEND" = "yes" ] # Append to existing config file
93then
94 echo >> config.h
95else
96 > config.h # Create new config file
97fi
98echo "/* Automatically generated - do not edit */" >>config.h
Wolfgang Denk61cf0512009-09-15 22:12:31 +020099
100for i in ${TARGETS} ; do
101 echo "#define CONFIG_MK_${i} 1" >>config.h ;
102done
103
Mike Frysingerd5954582009-12-02 21:15:03 -0500104cat << EOF >> config.h
105#define CONFIG_BOARDDIR board/$BOARDDIR
106#include <config_defaults.h>
107#include <configs/$1.h>
108#include <asm/config.h>
109EOF
wdenk7ebf7442002-11-02 23:17:16 +0000110
111exit 0