wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 1 | #!/bin/sh -e |
| 2 | |
| 3 | # Script to create header files and links to configure |
| 4 | # U-Boot for a specific board. |
| 5 | # |
wdenk | 1d9f410 | 2004-10-09 22:21:29 +0000 | [diff] [blame] | 6 | # Parameters: Target Architecture CPU Board [VENDOR] [SOC] |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 7 | # |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 8 | # (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <wd@denx.de> |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 9 | # |
| 10 | |
| 11 | APPEND=no # Default: Create new config file |
Wolfgang Denk | 5078cce | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 12 | BOARD_NAME="" # Name to print in make output |
Wolfgang Denk | 804d83a | 2009-09-15 22:12:31 +0200 | [diff] [blame] | 13 | TARGETS="" |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 14 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 15 | arch="" |
| 16 | cpu="" |
| 17 | board="" |
| 18 | vendor="" |
| 19 | soc="" |
| 20 | |
| 21 | if [ \( $# -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} |
| 31 | fi |
| 32 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 33 | while [ $# -gt 0 ] ; do |
| 34 | case "$1" in |
| 35 | --) shift ; break ;; |
| 36 | -a) shift ; APPEND=yes ;; |
Wolfgang Denk | ed7a196 | 2010-05-27 23:18:34 +0200 | [diff] [blame] | 37 | -n) shift ; BOARD_NAME="${1%_config}" ; shift ;; |
Wolfgang Denk | 804d83a | 2009-09-15 22:12:31 +0200 | [diff] [blame] | 38 | -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;; |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 39 | *) break ;; |
| 40 | esac |
| 41 | done |
| 42 | |
| 43 | [ $# -lt 4 ] && exit 1 |
wdenk | 1d9f410 | 2004-10-09 22:21:29 +0000 | [diff] [blame] | 44 | [ $# -gt 6 ] && exit 1 |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 45 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 46 | CONFIG_NAME="${1%_config}" |
| 47 | |
| 48 | [ "${BOARD_NAME}" ] || BOARD_NAME="${CONFIG_NAME}" |
| 49 | |
| 50 | arch="$2" |
| 51 | cpu="$3" |
| 52 | if [ "$4" = "-" ] ; then |
| 53 | board=${BOARD_NAME} |
| 54 | else |
| 55 | board="$4" |
| 56 | fi |
| 57 | [ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5" |
| 58 | [ $# -gt 5 ] && [ "$6" != "-" ] && soc="$6" |
| 59 | |
| 60 | if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then |
| 61 | echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2 |
Nishanth Menon | a8fa379 | 2009-11-02 09:40:18 -0600 | [diff] [blame] | 62 | exit 1 |
| 63 | fi |
| 64 | |
Wolfgang Denk | 5078cce | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 65 | echo "Configuring for ${BOARD_NAME} board..." |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 66 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 67 | # |
| 68 | # Create link to architecture specific headers |
| 69 | # |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 70 | if [ "$SRCTREE" != "$OBJTREE" ] ; then |
| 71 | mkdir -p ${OBJTREE}/include |
| 72 | mkdir -p ${OBJTREE}/include2 |
| 73 | cd ${OBJTREE}/include2 |
| 74 | rm -f asm |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 75 | ln -s ${SRCTREE}/arch/${arch}/include/asm asm |
| 76 | LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/ |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 77 | cd ../include |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 78 | rm -f asm |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 79 | ln -s ${SRCTREE}/arch/${arch}/include/asm asm |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 80 | else |
| 81 | cd ./include |
| 82 | rm -f asm |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 83 | ln -s ../arch/${arch}/include/asm asm |
Marian Balakowicz | f932863 | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 84 | fi |
| 85 | |
Peter Tyser | 819833a | 2010-04-12 22:28:08 -0500 | [diff] [blame] | 86 | rm -f asm/arch |
wdenk | 86c9888 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 87 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 88 | if [ -z "${soc}" ] ; then |
| 89 | ln -s ${LNPREFIX}arch-${cpu} asm/arch |
wdenk | 86c9888 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 90 | else |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 91 | ln -s ${LNPREFIX}arch-${soc} asm/arch |
wdenk | 86c9888 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 92 | fi |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 93 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 94 | if [ "${arch}" = "arm" ] ; then |
Peter Tyser | 819833a | 2010-04-12 22:28:08 -0500 | [diff] [blame] | 95 | rm -f asm/proc |
| 96 | ln -s ${LNPREFIX}proc-armv asm/proc |
wdenk | b783eda | 2003-06-25 22:26:29 +0000 | [diff] [blame] | 97 | fi |
| 98 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 99 | # |
| 100 | # Create include file for Make |
| 101 | # |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 102 | echo "ARCH = ${arch}" > config.mk |
| 103 | echo "CPU = ${cpu}" >> config.mk |
| 104 | echo "BOARD = ${board}" >> config.mk |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 105 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 106 | [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk |
wdenk | 1d9f410 | 2004-10-09 22:21:29 +0000 | [diff] [blame] | 107 | |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 108 | [ "${soc}" ] && echo "SOC = ${soc}" >> config.mk |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 109 | |
Stefan Roese | 7ec1fed | 2009-10-27 11:46:23 +0100 | [diff] [blame] | 110 | # Assign board directory to BOARDIR variable |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 111 | if [ -z "${vendor}" ] ; then |
| 112 | BOARDDIR=${board} |
Stefan Roese | 7ec1fed | 2009-10-27 11:46:23 +0100 | [diff] [blame] | 113 | else |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 114 | BOARDDIR=${vendor}/${board} |
Stefan Roese | 7ec1fed | 2009-10-27 11:46:23 +0100 | [diff] [blame] | 115 | fi |
| 116 | |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 117 | # |
| 118 | # Create board specific header file |
| 119 | # |
| 120 | if [ "$APPEND" = "yes" ] # Append to existing config file |
| 121 | then |
| 122 | echo >> config.h |
| 123 | else |
| 124 | > config.h # Create new config file |
| 125 | fi |
| 126 | echo "/* Automatically generated - do not edit */" >>config.h |
Wolfgang Denk | 804d83a | 2009-09-15 22:12:31 +0200 | [diff] [blame] | 127 | |
| 128 | for i in ${TARGETS} ; do |
| 129 | echo "#define CONFIG_MK_${i} 1" >>config.h ; |
| 130 | done |
| 131 | |
Mike Frysinger | 10c32ff | 2009-12-02 21:15:03 -0500 | [diff] [blame] | 132 | cat << EOF >> config.h |
| 133 | #define CONFIG_BOARDDIR board/$BOARDDIR |
| 134 | #include <config_defaults.h> |
Wolfgang Denk | a6862bc | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 135 | #include <configs/${CONFIG_NAME}.h> |
Mike Frysinger | 10c32ff | 2009-12-02 21:15:03 -0500 | [diff] [blame] | 136 | #include <asm/config.h> |
| 137 | EOF |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 138 | |
| 139 | exit 0 |