blob: d3109e412c4b7837d57b5b8971410d7c013fa7ca [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
15while [ $# -gt 0 ] ; do
16 case "$1" in
17 --) shift ; break ;;
18 -a) shift ; APPEND=yes ;;
Wolfgang Denk5078cce2006-07-21 11:16:34 +020019 -n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
Wolfgang Denk804d83a2009-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 Denk5078cce2006-07-21 11:16:34 +020025[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
26
wdenk7ebf7442002-11-02 23:17:16 +000027[ $# -lt 4 ] && exit 1
wdenk1d9f4102004-10-09 22:21:29 +000028[ $# -gt 6 ] && exit 1
wdenk7ebf7442002-11-02 23:17:16 +000029
Nishanth Menona8fa3792009-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 Denk5078cce2006-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 Balakowiczf9328632006-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
Peter Tyser819833a2010-04-12 22:28:08 -050045 ln -s ${SRCTREE}/arch/$2/include/asm asm
46 LNPREFIX=${SRCTREE}/arch/$2/include/asm/
Marian Balakowiczf9328632006-09-01 19:49:50 +020047 cd ../include
Marian Balakowiczf9328632006-09-01 19:49:50 +020048 rm -f asm
Peter Tyser819833a2010-04-12 22:28:08 -050049 ln -s ${SRCTREE}/arch/$2/include/asm asm
Marian Balakowiczf9328632006-09-01 19:49:50 +020050else
51 cd ./include
52 rm -f asm
Peter Tyser819833a2010-04-12 22:28:08 -050053 ln -s ../arch/$2/include/asm asm
Marian Balakowiczf9328632006-09-01 19:49:50 +020054fi
55
Peter Tyser819833a2010-04-12 22:28:08 -050056rm -f asm/arch
wdenk86c98882005-04-03 14:26:46 +000057
Wolfgang Denk507d3b02005-08-03 22:58:55 +020058if [ -z "$6" -o "$6" = "NULL" ] ; then
Peter Tyser819833a2010-04-12 22:28:08 -050059 ln -s ${LNPREFIX}arch-$3 asm/arch
wdenk86c98882005-04-03 14:26:46 +000060else
Peter Tyser819833a2010-04-12 22:28:08 -050061 ln -s ${LNPREFIX}arch-$6 asm/arch
wdenk86c98882005-04-03 14:26:46 +000062fi
wdenk7ebf7442002-11-02 23:17:16 +000063
wdenkb783eda2003-06-25 22:26:29 +000064if [ "$2" = "arm" ] ; then
Peter Tyser819833a2010-04-12 22:28:08 -050065 rm -f asm/proc
66 ln -s ${LNPREFIX}proc-armv asm/proc
wdenkb783eda2003-06-25 22:26:29 +000067fi
68
wdenk7ebf7442002-11-02 23:17:16 +000069#
70# Create include file for Make
71#
wdenk1d9f4102004-10-09 22:21:29 +000072echo "ARCH = $2" > config.mk
73echo "CPU = $3" >> config.mk
74echo "BOARD = $4" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +000075
wdenk1d9f4102004-10-09 22:21:29 +000076[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
77
78[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk
wdenk7ebf7442002-11-02 23:17:16 +000079
Stefan Roese7ec1fed2009-10-27 11:46:23 +010080# Assign board directory to BOARDIR variable
81if [ -z "$5" -o "$5" = "NULL" ] ; then
82 BOARDDIR=$4
83else
84 BOARDDIR=$5/$4
85fi
86
wdenk7ebf7442002-11-02 23:17:16 +000087#
88# Create board specific header file
89#
90if [ "$APPEND" = "yes" ] # Append to existing config file
91then
92 echo >> config.h
93else
94 > config.h # Create new config file
95fi
96echo "/* Automatically generated - do not edit */" >>config.h
Wolfgang Denk804d83a2009-09-15 22:12:31 +020097
98for i in ${TARGETS} ; do
99 echo "#define CONFIG_MK_${i} 1" >>config.h ;
100done
101
Mike Frysinger10c32ff2009-12-02 21:15:03 -0500102cat << EOF >> config.h
103#define CONFIG_BOARDDIR board/$BOARDDIR
104#include <config_defaults.h>
105#include <configs/$1.h>
106#include <asm/config.h>
107EOF
wdenk7ebf7442002-11-02 23:17:16 +0000108
109exit 0