Blackfin: bf527-ezkit: video: convert from old style MMR macros
[platform/kernel/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 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
33 while [ $# -gt 0 ] ; do
34         case "$1" in
35         --) shift ; break ;;
36         -a) shift ; APPEND=yes ;;
37         -n) shift ; BOARD_NAME="${1%_config}" ; shift ;;
38         -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
39         *)  break ;;
40         esac
41 done
42
43 [ $# -lt 4 ] && exit 1
44 [ $# -gt 6 ] && exit 1
45
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
62         exit 1
63 fi
64
65 echo "Configuring for ${BOARD_NAME} board..."
66
67 #
68 # Create link to architecture specific headers
69 #
70 if [ "$SRCTREE" != "$OBJTREE" ] ; then
71         mkdir -p ${OBJTREE}/include
72         mkdir -p ${OBJTREE}/include2
73         cd ${OBJTREE}/include2
74         rm -f asm
75         ln -s ${SRCTREE}/arch/${arch}/include/asm asm
76         LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
77         cd ../include
78         rm -f asm
79         ln -s ${SRCTREE}/arch/${arch}/include/asm asm
80 else
81         cd ./include
82         rm -f asm
83         ln -s ../arch/${arch}/include/asm asm
84 fi
85
86 rm -f asm/arch
87
88 if [ -z "${soc}" ] ; then
89         ln -s ${LNPREFIX}arch-${cpu} asm/arch
90 else
91         ln -s ${LNPREFIX}arch-${soc} asm/arch
92 fi
93
94 if [ "${arch}" = "arm" ] ; then
95         rm -f asm/proc
96         ln -s ${LNPREFIX}proc-armv asm/proc
97 fi
98
99 #
100 # Create include file for Make
101 #
102 echo "ARCH   = ${arch}"  >  config.mk
103 echo "CPU    = ${cpu}"   >> config.mk
104 echo "BOARD  = ${board}" >> config.mk
105
106 [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk
107
108 [ "${soc}"    ] && echo "SOC    = ${soc}"    >> config.mk
109
110 # Assign board directory to BOARDIR variable
111 if [ -z "${vendor}" ] ; then
112     BOARDDIR=${board}
113 else
114     BOARDDIR=${vendor}/${board}
115 fi
116
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
127
128 for i in ${TARGETS} ; do
129         echo "#define CONFIG_MK_${i} 1" >>config.h ;
130 done
131
132 cat << EOF >> config.h
133 #define CONFIG_BOARDDIR board/$BOARDDIR
134 #include <config_defaults.h>
135 #include <configs/${CONFIG_NAME}.h>
136 #include <asm/config.h>
137 EOF
138
139 exit 0