MAKEALL 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. #!/bin/bash
  2. # Tool mainly for U-Boot Quality Assurance: build one or more board
  3. # configurations with minimal verbosity, showing only warnings and
  4. # errors.
  5. usage()
  6. {
  7. # if exiting with 0, write to stdout, else write to stderr
  8. local ret=${1:-0}
  9. [ "${ret}" -eq 1 ] && exec 1>&2
  10. cat <<-EOF
  11. Usage: MAKEALL [options] [--] [boards-to-build]
  12. Options:
  13. -a ARCH, --arch ARCH Build all boards with arch ARCH
  14. -c CPU, --cpu CPU Build all boards with cpu CPU
  15. -v VENDOR, --vendor VENDOR Build all boards with vendor VENDOR
  16. -s SOC, --soc SOC Build all boards with soc SOC
  17. -l, --list List all targets to be built
  18. -h, --help This help output
  19. Selections by these options are logically ANDed; if the same option
  20. is used repeatedly, such selections are ORed. So "-v FOO -v BAR"
  21. will select all configurations where the vendor is either FOO or
  22. BAR. Any additional arguments specified on the command line are
  23. always build additionally. See the boards.cfg file for more info.
  24. If no boards are specified, then the default is "powerpc".
  25. Environment variables:
  26. BUILD_NCPUS number of parallel make jobs (default: auto)
  27. CROSS_COMPILE cross-compiler toolchain prefix (default: "")
  28. MAKEALL_LOGDIR output all logs to here (default: ./LOG/)
  29. BUILD_DIR output build directory (default: ./)
  30. Examples:
  31. - build all Power Architecture boards:
  32. MAKEALL -a powerpc
  33. MAKEALL --arch powerpc
  34. MAKEALL powerpc
  35. - build all PowerPC boards manufactured by vendor "esd":
  36. MAKEALL -a powerpc -v esd
  37. - build all PowerPC boards manufactured either by "keymile" or "siemens":
  38. MAKEALL -a powerpc -v keymile -v siemens
  39. - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards:
  40. MAKEALL -c mpc83xx -v freescale 4xx
  41. EOF
  42. exit ${ret}
  43. }
  44. SHORT_OPTS="ha:c:v:s:l"
  45. LONG_OPTS="help,arch:,cpu:,vendor:,soc:,list"
  46. # Option processing based on util-linux-2.13/getopt-parse.bash
  47. # Note that we use `"$@"' to let each command-line parameter expand to a
  48. # separate word. The quotes around `$@' are essential!
  49. # We need TEMP as the `eval set --' would nuke the return value of
  50. # getopt.
  51. TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \
  52. -n 'MAKEALL' -- "$@"`
  53. [ $? != 0 ] && usage 1
  54. # Note the quotes around `$TEMP': they are essential!
  55. eval set -- "$TEMP"
  56. SELECTED=''
  57. ONLY_LIST=''
  58. while true ; do
  59. case "$1" in
  60. -a|--arch)
  61. # echo "Option ARCH: argument \`$2'"
  62. if [ "$opt_a" ] ; then
  63. opt_a="${opt_a%)} || \$2 == \"$2\")"
  64. else
  65. opt_a="(\$2 == \"$2\")"
  66. fi
  67. SELECTED='y'
  68. shift 2 ;;
  69. -c|--cpu)
  70. # echo "Option CPU: argument \`$2'"
  71. if [ "$opt_c" ] ; then
  72. opt_c="${opt_c%)} || \$3 == \"$2\")"
  73. else
  74. opt_c="(\$3 == \"$2\")"
  75. fi
  76. SELECTED='y'
  77. shift 2 ;;
  78. -s|--soc)
  79. # echo "Option SoC: argument \`$2'"
  80. if [ "$opt_s" ] ; then
  81. opt_s="${opt_s%)} || \$6 == \"$2\")"
  82. else
  83. opt_s="(\$6 == \"$2\")"
  84. fi
  85. SELECTED='y'
  86. shift 2 ;;
  87. -v|--vendor)
  88. # echo "Option VENDOR: argument \`$2'"
  89. if [ "$opt_v" ] ; then
  90. opt_v="${opt_v%)} || \$5 == \"$2\")"
  91. else
  92. opt_v="(\$5 == \"$2\")"
  93. fi
  94. SELECTED='y'
  95. shift 2 ;;
  96. -l|--list)
  97. ONLY_LIST='y'
  98. shift ;;
  99. -h|--help)
  100. usage ;;
  101. --)
  102. shift ; break ;;
  103. *)
  104. echo "Internal error!" >&2 ; exit 1 ;;
  105. esac
  106. done
  107. # echo "Remaining arguments:"
  108. # for arg do echo '--> '"\`$arg'" ; done
  109. FILTER="\$1 !~ /^#/"
  110. [ "$opt_a" ] && FILTER="${FILTER} && $opt_a"
  111. [ "$opt_c" ] && FILTER="${FILTER} && $opt_c"
  112. [ "$opt_s" ] && FILTER="${FILTER} && $opt_s"
  113. [ "$opt_v" ] && FILTER="${FILTER} && $opt_v"
  114. if [ "$SELECTED" ] ; then
  115. SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg)
  116. # Make sure some boards from boards.cfg are actually found
  117. if [ -z "$SELECTED" ] ; then
  118. echo "Error: No boards selected, invalid arguments"
  119. exit 1
  120. fi
  121. fi
  122. #########################################################################
  123. # Print statistics when we exit
  124. trap exit 1 2 3 15
  125. trap print_stats 0
  126. # Determine number of CPU cores if no default was set
  127. : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
  128. if [ "$BUILD_NCPUS" -gt 1 ]
  129. then
  130. JOBS="-j $((BUILD_NCPUS + 1))"
  131. else
  132. JOBS=""
  133. fi
  134. if [ "${CROSS_COMPILE}" ] ; then
  135. MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
  136. else
  137. MAKE=make
  138. fi
  139. if [ "${MAKEALL_LOGDIR}" ] ; then
  140. LOG_DIR=${MAKEALL_LOGDIR}
  141. else
  142. LOG_DIR="LOG"
  143. fi
  144. if [ ! "${BUILD_DIR}" ] ; then
  145. BUILD_DIR="."
  146. fi
  147. [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} || exit 1
  148. LIST=""
  149. # Keep track of the number of builds and errors
  150. ERR_CNT=0
  151. ERR_LIST=""
  152. TOTAL_CNT=0
  153. RC=0
  154. # Helper funcs for parsing boards.cfg
  155. boards_by_field()
  156. {
  157. awk \
  158. -v field="$1" \
  159. -v select="$2" \
  160. '($1 !~ /^#/ && $field == select) { print $1 }' \
  161. boards.cfg
  162. }
  163. boards_by_arch() { boards_by_field 2 "$@" ; }
  164. boards_by_cpu() { boards_by_field 3 "$@" ; }
  165. boards_by_soc() { boards_by_field 6 "$@" ; }
  166. #########################################################################
  167. ## MPC5xx Systems
  168. #########################################################################
  169. LIST_5xx="$(boards_by_cpu mpc5xx)"
  170. #########################################################################
  171. ## MPC5xxx Systems
  172. #########################################################################
  173. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  174. #########################################################################
  175. ## MPC512x Systems
  176. #########################################################################
  177. LIST_512x="$(boards_by_cpu mpc512x)"
  178. #########################################################################
  179. ## MPC8xx Systems
  180. #########################################################################
  181. LIST_8xx="$(boards_by_cpu mpc8xx)"
  182. #########################################################################
  183. ## PPC4xx Systems
  184. #########################################################################
  185. LIST_4xx="$(boards_by_cpu ppc4xx)"
  186. #########################################################################
  187. ## MPC8220 Systems
  188. #########################################################################
  189. LIST_8220="$(boards_by_cpu mpc8220)"
  190. #########################################################################
  191. ## MPC824x Systems
  192. #########################################################################
  193. LIST_824x="$(boards_by_cpu mpc824x)"
  194. #########################################################################
  195. ## MPC8260 Systems (includes 8250, 8255 etc.)
  196. #########################################################################
  197. LIST_8260="$(boards_by_cpu mpc8260)"
  198. #########################################################################
  199. ## MPC83xx Systems (includes 8349, etc.)
  200. #########################################################################
  201. LIST_83xx="$(boards_by_cpu mpc83xx)"
  202. #########################################################################
  203. ## MPC85xx Systems (includes 8540, 8560 etc.)
  204. #########################################################################
  205. LIST_85xx="$(boards_by_cpu mpc85xx)"
  206. #########################################################################
  207. ## MPC86xx Systems
  208. #########################################################################
  209. LIST_86xx="$(boards_by_cpu mpc86xx)"
  210. #########################################################################
  211. ## 74xx/7xx Systems
  212. #########################################################################
  213. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  214. #########################################################################
  215. ## PowerPC groups
  216. #########################################################################
  217. LIST_TSEC=" \
  218. ${LIST_83xx} \
  219. ${LIST_85xx} \
  220. ${LIST_86xx} \
  221. "
  222. LIST_powerpc=" \
  223. ${LIST_5xx} \
  224. ${LIST_512x} \
  225. ${LIST_5xxx} \
  226. ${LIST_8xx} \
  227. ${LIST_8220} \
  228. ${LIST_824x} \
  229. ${LIST_8260} \
  230. ${LIST_83xx} \
  231. ${LIST_85xx} \
  232. ${LIST_86xx} \
  233. ${LIST_4xx} \
  234. ${LIST_74xx_7xx}\
  235. "
  236. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  237. # still using "ppc" instead of "powerpc"
  238. LIST_ppc=" \
  239. ${LIST_powerpc} \
  240. "
  241. #########################################################################
  242. ## StrongARM Systems
  243. #########################################################################
  244. LIST_SA="$(boards_by_cpu sa1100)"
  245. #########################################################################
  246. ## ARM9 Systems
  247. #########################################################################
  248. LIST_ARM9="$(boards_by_cpu arm920t) \
  249. $(boards_by_cpu arm926ejs) \
  250. $(boards_by_cpu arm925t) \
  251. "
  252. #########################################################################
  253. ## ARM11 Systems
  254. #########################################################################
  255. LIST_ARM11="$(boards_by_cpu arm1136) \
  256. imx31_phycore \
  257. imx31_phycore_eet \
  258. mx31pdk \
  259. smdk6400 \
  260. "
  261. #########################################################################
  262. ## ARMV7 Systems
  263. #########################################################################
  264. LIST_ARMV7="$(boards_by_cpu armv7)"
  265. #########################################################################
  266. ## AT91 Systems
  267. #########################################################################
  268. LIST_at91="$(boards_by_soc at91)"
  269. #########################################################################
  270. ## Xscale Systems
  271. #########################################################################
  272. LIST_pxa="$(boards_by_cpu pxa)"
  273. LIST_ixp="$(boards_by_cpu ixp)
  274. pdnb3 \
  275. scpu \
  276. "
  277. #########################################################################
  278. ## ARM groups
  279. #########################################################################
  280. LIST_arm=" \
  281. ${LIST_SA} \
  282. ${LIST_ARM9} \
  283. ${LIST_ARM10} \
  284. ${LIST_ARM11} \
  285. ${LIST_ARMV7} \
  286. ${LIST_at91} \
  287. ${LIST_pxa} \
  288. ${LIST_ixp} \
  289. "
  290. #########################################################################
  291. ## MIPS Systems (default = big endian)
  292. #########################################################################
  293. LIST_mips4kc=" \
  294. incaip \
  295. qemu_mips \
  296. vct_platinum \
  297. vct_platinum_small \
  298. vct_platinum_onenand \
  299. vct_platinum_onenand_small \
  300. vct_platinumavc \
  301. vct_platinumavc_small \
  302. vct_platinumavc_onenand \
  303. vct_platinumavc_onenand_small \
  304. vct_premium \
  305. vct_premium_small \
  306. vct_premium_onenand \
  307. vct_premium_onenand_small \
  308. "
  309. LIST_au1xx0=" \
  310. dbau1000 \
  311. dbau1100 \
  312. dbau1500 \
  313. dbau1550 \
  314. gth2 \
  315. "
  316. LIST_mips=" \
  317. ${LIST_mips4kc} \
  318. ${LIST_mips5kc} \
  319. ${LIST_au1xx0} \
  320. "
  321. #########################################################################
  322. ## MIPS Systems (little endian)
  323. #########################################################################
  324. LIST_xburst_el=" \
  325. qi_lb60 \
  326. "
  327. LIST_au1xx0_el=" \
  328. dbau1550_el \
  329. pb1000 \
  330. "
  331. LIST_mips_el=" \
  332. ${LIST_xburst_el} \
  333. ${LIST_au1xx0_el} \
  334. "
  335. #########################################################################
  336. ## OpenRISC Systems
  337. #########################################################################
  338. LIST_openrisc="$(boards_by_arch openrisc)"
  339. #########################################################################
  340. ## x86 Systems
  341. #########################################################################
  342. LIST_x86="$(boards_by_arch x86)"
  343. #########################################################################
  344. ## Nios-II Systems
  345. #########################################################################
  346. LIST_nios2="$(boards_by_arch nios2)"
  347. #########################################################################
  348. ## MicroBlaze Systems
  349. #########################################################################
  350. LIST_microblaze="$(boards_by_arch microblaze)"
  351. #########################################################################
  352. ## ColdFire Systems
  353. #########################################################################
  354. LIST_m68k="$(boards_by_arch m68k)
  355. EB+MCF-EV123 \
  356. EB+MCF-EV123_internal \
  357. M52277EVB \
  358. M5235EVB \
  359. M54451EVB \
  360. M54455EVB \
  361. "
  362. LIST_coldfire=${LIST_m68k}
  363. #########################################################################
  364. ## AVR32 Systems
  365. #########################################################################
  366. LIST_avr32="$(boards_by_arch avr32)"
  367. #########################################################################
  368. ## Blackfin Systems
  369. #########################################################################
  370. LIST_blackfin="$(boards_by_arch blackfin)"
  371. #########################################################################
  372. ## SH Systems
  373. #########################################################################
  374. LIST_sh2="$(boards_by_cpu sh2)"
  375. LIST_sh3="$(boards_by_cpu sh3)"
  376. LIST_sh4="$(boards_by_cpu sh4)"
  377. LIST_sh="$(boards_by_arch sh)"
  378. #########################################################################
  379. ## SPARC Systems
  380. #########################################################################
  381. LIST_sparc="$(boards_by_arch sparc)"
  382. #########################################################################
  383. ## NDS32 Systems
  384. #########################################################################
  385. LIST_nds32="$(boards_by_arch nds32)"
  386. #-----------------------------------------------------------------------
  387. build_target() {
  388. target=$1
  389. if [ "$ONLY_LIST" == 'y' ] ; then
  390. echo "$target"
  391. return
  392. fi
  393. ${MAKE} distclean >/dev/null
  394. ${MAKE} -s ${target}_config
  395. ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
  396. | tee ${LOG_DIR}/$target.ERR
  397. # Check for 'make' errors
  398. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  399. RC=1
  400. fi
  401. if [ -s ${LOG_DIR}/$target.ERR ] ; then
  402. ERR_CNT=$((ERR_CNT + 1))
  403. ERR_LIST="${ERR_LIST} $target"
  404. else
  405. rm ${LOG_DIR}/$target.ERR
  406. fi
  407. TOTAL_CNT=$((TOTAL_CNT + 1))
  408. ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
  409. | tee -a ${LOG_DIR}/$target.MAKELOG
  410. }
  411. build_targets() {
  412. for t in "$@" ; do
  413. # If a LIST_xxx var exists, use it. But avoid variable
  414. # expansion in the eval when a board name contains certain
  415. # characters that the shell interprets.
  416. case ${t} in
  417. *[-+=]*) list= ;;
  418. *) list=$(eval echo '${LIST_'$t'}') ;;
  419. esac
  420. if [ -n "${list}" ] ; then
  421. build_targets ${list}
  422. else
  423. build_target ${t}
  424. fi
  425. done
  426. }
  427. #-----------------------------------------------------------------------
  428. print_stats() {
  429. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  430. echo ""
  431. echo "--------------------- SUMMARY ----------------------------"
  432. echo "Boards compiled: ${TOTAL_CNT}"
  433. if [ ${ERR_CNT} -gt 0 ] ; then
  434. echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )"
  435. fi
  436. echo "----------------------------------------------------------"
  437. exit $RC
  438. }
  439. #-----------------------------------------------------------------------
  440. # Build target groups selected by options, plus any command line args
  441. set -- ${SELECTED} "$@"
  442. # run PowerPC by default
  443. [ $# = 0 ] && set -- powerpc
  444. build_targets "$@"