mkconfig 3.5 KB

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