Merge branch 'master' of git://git.denx.de/u-boot-arm
[oweals/u-boot.git] / mkconfig
index b96c81fbc2b50336e279cd3d78495badaf1fb9de..84f5a7765b94b9bad19c8c345861d3253bd193f1 100755 (executable)
--- a/mkconfig
+++ b/mkconfig
@@ -23,7 +23,7 @@ options=""
 
 if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
        # Automatic mode
-       line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' boards.cfg`
+       line=`awk '($0 !~ /^#/ && $7 ~ /^'"$2"'$/) { print $1, $2, $3, $4, $5, $6, $7, $8 }' $srctree/boards.cfg`
        if [ -z "$line" ] ; then
                echo "make: *** No rule to make target \`$2_config'.  Stop." >&2
                exit 1
@@ -55,11 +55,12 @@ CONFIG_NAME="${7%_config}"
 arch="$2"
 cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`
 spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`
-if [ "$6" = "-" ] ; then
-       board=${BOARD_NAME}
-else
-       board="$6"
+
+if [ "$cpu" = "-" ] ; then
+       cpu=
 fi
+
+[ "$6" != "-" ] && board="$6"
 [ "$5" != "-" ] && vendor="$5"
 [ "$4" != "-" ] && soc="$4"
 [ $# -gt 7 ] && [ "$8" != "-" ] && {
@@ -101,10 +102,10 @@ fi
 #
 # Create link to architecture specific headers
 #
-if [ "$SRCTREE" != "$OBJTREE" ] ; then
-       mkdir -p ${OBJTREE}/include
-       LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
-       cd ${OBJTREE}/include
+if [ -n "$KBUILD_SRC" ] ; then
+       mkdir -p ${objtree}/include
+       LNPREFIX=${srctree}/arch/${arch}/include/asm/
+       cd ${objtree}/include
        mkdir -p asm
 else
        cd arch/${arch}/include
@@ -112,19 +113,14 @@ fi
 
 rm -f asm/arch
 
-if [ -z "${soc}" ] ; then
-       ln -s ${LNPREFIX}arch-${cpu} asm/arch
-else
+if [ "${soc}" ] ; then
        ln -s ${LNPREFIX}arch-${soc} asm/arch
+elif [ "${cpu}" ] ; then
+       ln -s ${LNPREFIX}arch-${cpu} asm/arch
 fi
 
-if [ "${arch}" = "arm" ] ; then
-       rm -f asm/proc
-       ln -s ${LNPREFIX}proc-armv asm/proc
-fi
-
-if [ "$SRCTREE" = "$OBJTREE" ] ; then
-       cd ${SRCTREE}/include
+if [ -z "$KBUILD_SRC" ] ; then
+       cd ${srctree}/include
 fi
 
 #
@@ -177,8 +173,8 @@ echo "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h
 
 [ "${soc}"    ] && echo "#define CONFIG_SYS_SOC    \"${soc}\""    >> config.h
 
+[ "${board}"  ] && echo "#define CONFIG_BOARDDIR board/$BOARDDIR" >> config.h
 cat << EOF >> config.h
-#define CONFIG_BOARDDIR board/$BOARDDIR
 #include <config_cmd_defaults.h>
 #include <config_defaults.h>
 #include <configs/${CONFIG_NAME}.h>