PXA: PXAMMC: Add Monahans support
[oweals/u-boot.git] / mkconfig
1 #!/bin/sh -e
2
3 # Script to create header files and links to configure
4 # U-Boot for a specific board.
5 #
6 # Parameters:  Target  Architecture  CPU  Board [VENDOR] [SOC]
7 #
8 # (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
9 #
10
11 APPEND=no       # Default: Create new config file
12 BOARD_NAME=""   # Name to print in make output
13 TARGETS=""
14
15 while [ $# -gt 0 ] ; do
16         case "$1" in
17         --) shift ; break ;;
18         -a) shift ; APPEND=yes ;;
19         -n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
20         -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
21         *)  break ;;
22         esac
23 done
24
25 [ "${BOARD_NAME}" ] || BOARD_NAME="$1"
26
27 [ $# -lt 4 ] && exit 1
28 [ $# -gt 6 ] && exit 1
29
30 if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
31         echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
32         exit 1
33 fi
34
35 echo "Configuring for ${BOARD_NAME} board..."
36
37 #
38 # Create link to architecture specific headers
39 #
40 if [ "$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}/arch/$2/include/asm asm
46         LNPREFIX=${SRCTREE}/arch/$2/include/asm/
47         cd ../include
48         rm -f asm
49         ln -s ${SRCTREE}/arch/$2/include/asm asm
50 else
51         cd ./include
52         rm -f asm
53         ln -s ../arch/$2/include/asm asm
54 fi
55
56 rm -f asm/arch
57
58 if [ -z "$6" -o "$6" = "NULL" ] ; then
59         ln -s ${LNPREFIX}arch-$3 asm/arch
60 else
61         ln -s ${LNPREFIX}arch-$6 asm/arch
62 fi
63
64 if [ "$2" = "arm" ] ; then
65         rm -f asm/proc
66         ln -s ${LNPREFIX}proc-armv asm/proc
67 fi
68
69 #
70 # Create include file for Make
71 #
72 echo "ARCH   = $2" >  config.mk
73 echo "CPU    = $3" >> config.mk
74 echo "BOARD  = $4" >> config.mk
75
76 [ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
77
78 [ "$6" ] && [ "$6" != "NULL" ] && echo "SOC    = $6" >> config.mk
79
80 # Assign board directory to BOARDIR variable
81 if [ -z "$5" -o "$5" = "NULL" ] ; then
82     BOARDDIR=$4
83 else
84     BOARDDIR=$5/$4
85 fi
86
87 #
88 # Create board specific header file
89 #
90 if [ "$APPEND" = "yes" ]        # Append to existing config file
91 then
92         echo >> config.h
93 else
94         > config.h              # Create new config file
95 fi
96 echo "/* Automatically generated - do not edit */" >>config.h
97
98 for i in ${TARGETS} ; do
99         echo "#define CONFIG_MK_${i} 1" >>config.h ;
100 done
101
102 cat << EOF >> config.h
103 #define CONFIG_BOARDDIR board/$BOARDDIR
104 #include <config_defaults.h>
105 #include <configs/$1.h>
106 #include <asm/config.h>
107 EOF
108
109 exit 0