mkconfig 4.3 KB

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