mkconfig 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 [ "$cpu" = "-" ] ; then
  49. cpu=
  50. fi
  51. [ "$6" != "-" ] && board="$6"
  52. [ "$5" != "-" ] && vendor="$5"
  53. [ "$4" != "-" ] && soc="$4"
  54. [ $# -gt 7 ] && [ "$8" != "-" ] && {
  55. # check if we have a board config name in the options field
  56. # the options field mave have a board config name and a list
  57. # of options, both separated by a colon (':'); the options are
  58. # separated by commas (',').
  59. #
  60. # Check for board name
  61. tmp="${8%:*}"
  62. if [ "$tmp" ] ; then
  63. CONFIG_NAME="$tmp"
  64. fi
  65. # Check if we only have a colon...
  66. if [ "${tmp}" != "$8" ] ; then
  67. options=${8#*:}
  68. TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}"
  69. fi
  70. }
  71. if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then
  72. echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2
  73. exit 1
  74. fi
  75. #
  76. # Test above needed aarch64, now we need arm
  77. #
  78. if [ "${arch}" = "aarch64" ]; then
  79. arch="arm"
  80. fi
  81. if [ "$options" ] ; then
  82. echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}"
  83. else
  84. echo "Configuring for ${BOARD_NAME} board..."
  85. fi
  86. #
  87. # Create link to architecture specific headers
  88. #
  89. if [ -n "$KBUILD_SRC" ] ; then
  90. mkdir -p ${objtree}/include
  91. LNPREFIX=${srctree}/arch/${arch}/include/asm/
  92. cd ${objtree}/include
  93. mkdir -p asm
  94. else
  95. cd arch/${arch}/include
  96. fi
  97. rm -f asm/arch
  98. if [ "${soc}" ] ; then
  99. ln -s ${LNPREFIX}arch-${soc} asm/arch
  100. elif [ "${cpu}" ] ; then
  101. ln -s ${LNPREFIX}arch-${cpu} asm/arch
  102. fi
  103. if [ -z "$KBUILD_SRC" ] ; then
  104. cd ${srctree}/include
  105. fi
  106. #
  107. # Create include file for Make
  108. #
  109. ( echo "ARCH = ${arch}"
  110. if [ ! -z "$spl_cpu" ] ; then
  111. echo 'ifeq ($(CONFIG_SPL_BUILD),y)'
  112. echo "CPU = ${spl_cpu}"
  113. echo "else"
  114. echo "CPU = ${cpu}"
  115. echo "endif"
  116. else
  117. echo "CPU = ${cpu}"
  118. fi
  119. echo "BOARD = ${board}"
  120. [ "${vendor}" ] && echo "VENDOR = ${vendor}"
  121. [ "${soc}" ] && echo "SOC = ${soc}"
  122. exit 0 ) > config.mk
  123. # Assign board directory to BOARDIR variable
  124. if [ -z "${vendor}" ] ; then
  125. BOARDDIR=${board}
  126. else
  127. BOARDDIR=${vendor}/${board}
  128. fi
  129. #
  130. # Create board specific header file
  131. #
  132. if [ "$APPEND" = "yes" ] # Append to existing config file
  133. then
  134. echo >> config.h
  135. else
  136. > config.h # Create new config file
  137. fi
  138. echo "/* Automatically generated - do not edit */" >>config.h
  139. for i in ${TARGETS} ; do
  140. i="`echo ${i} | sed '/=/ {s/=/ /;q; } ; { s/$/ 1/; }'`"
  141. echo "#define CONFIG_${i}" >>config.h ;
  142. done
  143. echo "#define CONFIG_SYS_ARCH \"${arch}\"" >> config.h
  144. echo "#define CONFIG_SYS_CPU \"${cpu}\"" >> config.h
  145. echo "#define CONFIG_SYS_BOARD \"${board}\"" >> config.h
  146. [ "${vendor}" ] && echo "#define CONFIG_SYS_VENDOR \"${vendor}\"" >> config.h
  147. [ "${soc}" ] && echo "#define CONFIG_SYS_SOC \"${soc}\"" >> config.h
  148. [ "${board}" ] && echo "#define CONFIG_BOARDDIR board/$BOARDDIR" >> config.h
  149. cat << EOF >> config.h
  150. #include <config_cmd_defaults.h>
  151. #include <config_defaults.h>
  152. #include <configs/${CONFIG_NAME}.h>
  153. #include <asm/config.h>
  154. #include <config_fallbacks.h>
  155. #include <config_uncmd_spl.h>
  156. EOF
  157. exit 0