mkconfig 3.8 KB

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