mkconfig 4.2 KB

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