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 | f8e9a23 | 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 | d62379d | 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 | 9975314 | 2006-07-21 11:16:34 +0200 | [diff] [blame] | 12 | BOARD_NAME="" # Name to print in make output |
Wolfgang Denk | 61cf051 | 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 | f2c7ea8 | 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 | a97b6ab | 2010-05-27 23:18:34 +0200 | [diff] [blame] | 37 | -n) shift ; BOARD_NAME="${1%_config}" ; shift ;; |
Wolfgang Denk | 61cf051 | 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 | f8e9a23 | 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 | f2c7ea8 | 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 | e83cc36 | 2009-11-02 09:40:18 -0600 | [diff] [blame] | 62 | exit 1 |
| 63 | fi |
| 64 | |
Wolfgang Denk | 9975314 | 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 | d62379d | 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 | f2c7ea8 | 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 | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 77 | cd ../include |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 78 | rm -f asm |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 79 | ln -s ${SRCTREE}/arch/${arch}/include/asm asm |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 80 | else |
| 81 | cd ./include |
| 82 | rm -f asm |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 83 | ln -s ../arch/${arch}/include/asm asm |
Marian Balakowicz | d62379d | 2006-09-01 19:49:50 +0200 | [diff] [blame] | 84 | fi |
| 85 | |
Peter Tyser | 3cba3c1 | 2010-04-12 22:28:08 -0500 | [diff] [blame] | 86 | rm -f asm/arch |
wdenk | f9c57a2 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 87 | |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 88 | if [ -z "${soc}" ] ; then |
| 89 | ln -s ${LNPREFIX}arch-${cpu} asm/arch |
wdenk | f9c57a2 | 2005-04-03 14:26:46 +0000 | [diff] [blame] | 90 | else |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 91 | ln -s ${LNPREFIX}arch-${soc} asm/arch |
wdenk | f9c57a2 | 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 | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 94 | if [ "${arch}" = "arm" ] ; then |
Peter Tyser | 3cba3c1 | 2010-04-12 22:28:08 -0500 | [diff] [blame] | 95 | rm -f asm/proc |
| 96 | ln -s ${LNPREFIX}proc-armv asm/proc |
wdenk | bb2d927 | 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 | f2c7ea8 | 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 | f8e9a23 | 2004-10-09 22:21:29 +0000 | [diff] [blame] | 105 | |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 106 | [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk |
wdenk | 7ebf744 | 2002-11-02 23:17:16 +0000 | [diff] [blame] | 107 | |
Wolfgang Denk | f2c7ea8 | 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 | 995611e | 2009-10-27 11:46:23 +0100 | [diff] [blame] | 110 | # Assign board directory to BOARDIR variable |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 111 | if [ -z "${vendor}" ] ; then |
| 112 | BOARDDIR=${board} |
Stefan Roese | 995611e | 2009-10-27 11:46:23 +0100 | [diff] [blame] | 113 | else |
Wolfgang Denk | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 114 | BOARDDIR=${vendor}/${board} |
Stefan Roese | 995611e | 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 | 61cf051 | 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 | d595458 | 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 | f2c7ea8 | 2010-05-27 23:18:36 +0200 | [diff] [blame] | 135 | #include <configs/${CONFIG_NAME}.h> |
Mike Frysinger | d595458 | 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 |