mkconfig 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #!/bin/sh -e
  2. # Script to create header files and links to configure
  3. # U-Boot for a specific board.
  4. #
  5. # Parameters: Target Architecture CPU Board [VENDOR] [SOC]
  6. #
  7. # (C) 2002-2010 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
  8. #
  9. APPEND=no # Default: Create new config file
  10. BOARD_NAME="" # Name to print in make output
  11. TARGETS=""
  12. arch=""
  13. cpu=""
  14. board=""
  15. vendor=""
  16. soc=""
  17. options=""
  18. if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
  19. # Automatic mode
  20. line=`egrep -i "^[[:space:]]*${2}[[:space:]]" boards.cfg` || {
  21. echo "make: *** No rule to make target \`$2_config'. Stop." >&2
  22. exit 1
  23. }
  24. set ${line}
  25. # add default board name if needed
  26. [ $# = 3 ] && set ${line} ${1}
  27. elif [ "${MAKEFLAGS+set}${MAKELEVEL+set}" = "setset" ] ; then
  28. # only warn when using a config target in the Makefile
  29. cat <<-EOF
  30. warning: Please migrate to boards.cfg. Failure to do so will
  31. mean removal of your board in the next release.
  32. EOF
  33. sleep 5
  34. fi
  35. while [ $# -gt 0 ] ; do
  36. case "$1" in
  37. --) shift ; break ;;
  38. -a) shift ; APPEND=yes ;;
  39. -n) shift ; BOARD_NAME="${1%_config}" ; shift ;;
  40. -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;;
  41. *) break ;;
  42. esac
  43. done
  44. [ $# -lt 4 ] && exit 1
  45. [ $# -gt 7 ] && exit 1
  46. # Strip all options and/or _config suffixes
  47. CONFIG_NAME="${1%_config}"
  48. [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
  49. arch="$2"
  50. cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`
  51. spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`
  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. [ $# -gt 6 ] && [ "$7" != "-" ] && {
  60. # check if we have a board config name in the options field
  61. # the options field mave have a board config name and a list
  62. # of options, both separated by a colon (':'); the options are
  63. # separated by commas (',').
  64. #
  65. # Check for board name
  66. tmp="${7%:*}"
  67. if [ "$tmp" ] ; then
  68. CONFIG_NAME="$tmp"
  69. fi
  70. # Check if we only have a colon...
  71. if [ "${tmp}" != "$7" ] ; then
  72. options=${7#*:}
  73. TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}"
  74. fi
  75. }
  76. if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then
  77. echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2
  78. exit 1
  79. fi
  80. if [ "$options" ] ; then
  81. echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}"
  82. else
  83. echo "Configuring for ${BOARD_NAME} board..."
  84. fi
  85. #
  86. # Create link to architecture specific headers
  87. #
  88. if [ "$SRCTREE" != "$OBJTREE" ] ; then
  89. mkdir -p ${OBJTREE}/include
  90. mkdir -p ${OBJTREE}/include2
  91. cd ${OBJTREE}/include2
  92. rm -f asm
  93. ln -s ${SRCTREE}/arch/${arch}/include/asm asm
  94. LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
  95. cd ../include
  96. mkdir -p asm
  97. else
  98. cd ./include
  99. rm -f asm
  100. ln -s ../arch/${arch}/include/asm asm
  101. fi
  102. rm -f asm/arch
  103. if [ -z "${soc}" ] ; then
  104. ln -s ${LNPREFIX}arch-${cpu} asm/arch
  105. else
  106. ln -s ${LNPREFIX}arch-${soc} asm/arch
  107. fi
  108. if [ "${arch}" = "arm" ] ; then
  109. rm -f asm/proc
  110. ln -s ${LNPREFIX}proc-armv asm/proc
  111. fi
  112. #
  113. # Create include file for Make
  114. #
  115. ( echo "ARCH = ${arch}"
  116. if [ ! -z "$spl_cpu" ] ; then
  117. echo 'ifeq ($(CONFIG_SPL_BUILD),y)'
  118. echo "CPU = ${spl_cpu}"
  119. echo "else"
  120. echo "CPU = ${cpu}"
  121. echo "endif"
  122. else
  123. echo "CPU = ${cpu}"
  124. fi
  125. echo "BOARD = ${board}"
  126. [ "${vendor}" ] && echo "VENDOR = ${vendor}"
  127. [ "${soc}" ] && echo "SOC = ${soc}"
  128. exit 0 ) > config.mk
  129. # Assign board directory to BOARDIR variable
  130. if [ -z "${vendor}" ] ; then
  131. BOARDDIR=${board}
  132. else
  133. BOARDDIR=${vendor}/${board}
  134. fi
  135. #
  136. # Create board specific header file
  137. #
  138. if [ "$APPEND" = "yes" ] # Append to existing config file
  139. then
  140. echo >> config.h
  141. else
  142. > config.h # Create new config file
  143. fi
  144. echo "/* Automatically generated - do not edit */" >>config.h
  145. for i in ${TARGETS} ; do
  146. i="`echo ${i} | sed '/=/ {s/=/ /;q; } ; { s/$/ 1/; }'`"
  147. echo "#define CONFIG_${i}" >>config.h ;
  148. done
  149. echo "#define CONFIG_SYS_ARCH \"${arch}\"" >> config.h
  150. echo "#define CONFIG_SYS_CPU \"${cpu}\"" >> config.h
  151. echo "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h
  152. [ "${vendor}" ] && echo "#define CONFIG_SYS_VENDOR \"${vendor}\"" >> config.h
  153. [ "${soc}" ] && echo "#define CONFIG_SYS_SOC \"${soc}\"" >> config.h
  154. cat << EOF >> config.h
  155. #define CONFIG_BOARDDIR board/$BOARDDIR
  156. #include <config_cmd_defaults.h>
  157. #include <config_defaults.h>
  158. #include <configs/${CONFIG_NAME}.h>
  159. #include <asm/config.h>
  160. #include <config_fallbacks.h>
  161. #include <config_uncmd_spl.h>
  162. EOF
  163. exit 0