MAKEALL 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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. -h, --help This help output
  18. Selections by these options are logically ANDed; if the same option
  19. is used repeatedly, such selections are ORed. So "-v FOO -v BAR"
  20. will select all configurations where the vendor is either FOO or
  21. BAR. Any additional arguments specified on the command line are
  22. always build additionally. See the boards.cfg file for more info.
  23. If no boards are specified, then the default is "powerpc".
  24. Environment variables:
  25. BUILD_NCPUS number of parallel make jobs (default: auto)
  26. CROSS_COMPILE cross-compiler toolchain prefix (default: "")
  27. MAKEALL_LOGDIR output all logs to here (default: ./LOG/)
  28. BUILD_DIR output build directory (default: ./)
  29. Examples:
  30. - build all Power Architecture boards:
  31. MAKEALL -a powerpc
  32. MAKEALL --arch powerpc
  33. MAKEALL powerpc
  34. - build all PowerPC boards manufactured by vendor "esd":
  35. MAKEALL -a powerpc -v esd
  36. - build all PowerPC boards manufactured either by "keymile" or "siemens":
  37. MAKEALL -a powerpc -v keymile -v siemens
  38. - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards:
  39. MAKEALL -c mpc83xx -v freescale 4xx
  40. EOF
  41. exit ${ret}
  42. }
  43. SHORT_OPTS="ha:c:v:s:"
  44. LONG_OPTS="help,arch:,cpu:,vendor:,soc:"
  45. # Option processing based on util-linux-2.13/getopt-parse.bash
  46. # Note that we use `"$@"' to let each command-line parameter expand to a
  47. # separate word. The quotes around `$@' are essential!
  48. # We need TEMP as the `eval set --' would nuke the return value of
  49. # getopt.
  50. TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \
  51. -n 'MAKEALL' -- "$@"`
  52. [ $? != 0 ] && usage 1
  53. # Note the quotes around `$TEMP': they are essential!
  54. eval set -- "$TEMP"
  55. SELECTED=''
  56. while true ; do
  57. case "$1" in
  58. -a|--arch)
  59. # echo "Option ARCH: argument \`$2'"
  60. if [ "$opt_a" ] ; then
  61. opt_a="${opt_a%)} || \$2 == \"$2\")"
  62. else
  63. opt_a="(\$2 == \"$2\")"
  64. fi
  65. SELECTED='y'
  66. shift 2 ;;
  67. -c|--cpu)
  68. # echo "Option CPU: argument \`$2'"
  69. if [ "$opt_c" ] ; then
  70. opt_c="${opt_c%)} || \$3 == \"$2\")"
  71. else
  72. opt_c="(\$3 == \"$2\")"
  73. fi
  74. SELECTED='y'
  75. shift 2 ;;
  76. -s|--soc)
  77. # echo "Option SoC: argument \`$2'"
  78. if [ "$opt_s" ] ; then
  79. opt_s="${opt_s%)} || \$6 == \"$2\")"
  80. else
  81. opt_s="(\$6 == \"$2\")"
  82. fi
  83. SELECTED='y'
  84. shift 2 ;;
  85. -v|--vendor)
  86. # echo "Option VENDOR: argument \`$2'"
  87. if [ "$opt_v" ] ; then
  88. opt_v="${opt_v%)} || \$5 == \"$2\")"
  89. else
  90. opt_v="(\$5 == \"$2\")"
  91. fi
  92. SELECTED='y'
  93. shift 2 ;;
  94. -h|--help)
  95. usage ;;
  96. --)
  97. shift ; break ;;
  98. *)
  99. echo "Internal error!" >&2 ; exit 1 ;;
  100. esac
  101. done
  102. # echo "Remaining arguments:"
  103. # for arg do echo '--> '"\`$arg'" ; done
  104. FILTER="\$1 !~ /^#/"
  105. [ "$opt_a" ] && FILTER="${FILTER} && $opt_a"
  106. [ "$opt_c" ] && FILTER="${FILTER} && $opt_c"
  107. [ "$opt_s" ] && FILTER="${FILTER} && $opt_s"
  108. [ "$opt_v" ] && FILTER="${FILTER} && $opt_v"
  109. if [ "$SELECTED" ] ; then
  110. SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg)
  111. # Make sure some boards from boards.cfg are actually found
  112. if [ -z "$SELECTED" ] ; then
  113. echo "Error: No boards selected, invalid arguments"
  114. exit 1
  115. fi
  116. fi
  117. #########################################################################
  118. # Print statistics when we exit
  119. trap exit 1 2 3 15
  120. trap print_stats 0
  121. # Determine number of CPU cores if no default was set
  122. : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
  123. if [ "$BUILD_NCPUS" -gt 1 ]
  124. then
  125. JOBS="-j $((BUILD_NCPUS + 1))"
  126. else
  127. JOBS=""
  128. fi
  129. if [ "${CROSS_COMPILE}" ] ; then
  130. MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
  131. else
  132. MAKE=make
  133. fi
  134. if [ "${MAKEALL_LOGDIR}" ] ; then
  135. LOG_DIR=${MAKEALL_LOGDIR}
  136. else
  137. LOG_DIR="LOG"
  138. fi
  139. if [ ! "${BUILD_DIR}" ] ; then
  140. BUILD_DIR="."
  141. fi
  142. [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} || exit 1
  143. LIST=""
  144. # Keep track of the number of builds and errors
  145. ERR_CNT=0
  146. ERR_LIST=""
  147. TOTAL_CNT=0
  148. RC=0
  149. # Helper funcs for parsing boards.cfg
  150. boards_by_field()
  151. {
  152. awk \
  153. -v field="$1" \
  154. -v select="$2" \
  155. '($1 !~ /^#/ && $field == select) { print $1 }' \
  156. boards.cfg
  157. }
  158. boards_by_arch() { boards_by_field 2 "$@" ; }
  159. boards_by_cpu() { boards_by_field 3 "$@" ; }
  160. boards_by_soc() { boards_by_field 6 "$@" ; }
  161. #########################################################################
  162. ## MPC5xx Systems
  163. #########################################################################
  164. LIST_5xx="$(boards_by_cpu mpc5xx)"
  165. #########################################################################
  166. ## MPC5xxx Systems
  167. #########################################################################
  168. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  169. #########################################################################
  170. ## MPC512x Systems
  171. #########################################################################
  172. LIST_512x="$(boards_by_cpu mpc512x)"
  173. #########################################################################
  174. ## MPC8xx Systems
  175. #########################################################################
  176. LIST_8xx="$(boards_by_cpu mpc8xx)"
  177. #########################################################################
  178. ## PPC4xx Systems
  179. #########################################################################
  180. LIST_4xx="$(boards_by_cpu ppc4xx)"
  181. #########################################################################
  182. ## MPC8220 Systems
  183. #########################################################################
  184. LIST_8220="$(boards_by_cpu mpc8220)"
  185. #########################################################################
  186. ## MPC824x Systems
  187. #########################################################################
  188. LIST_824x="$(boards_by_cpu mpc824x)"
  189. #########################################################################
  190. ## MPC8260 Systems (includes 8250, 8255 etc.)
  191. #########################################################################
  192. LIST_8260="$(boards_by_cpu mpc8260)"
  193. #########################################################################
  194. ## MPC83xx Systems (includes 8349, etc.)
  195. #########################################################################
  196. LIST_83xx="$(boards_by_cpu mpc83xx)"
  197. #########################################################################
  198. ## MPC85xx Systems (includes 8540, 8560 etc.)
  199. #########################################################################
  200. LIST_85xx="$(boards_by_cpu mpc85xx)"
  201. #########################################################################
  202. ## MPC86xx Systems
  203. #########################################################################
  204. LIST_86xx="$(boards_by_cpu mpc86xx)"
  205. #########################################################################
  206. ## 74xx/7xx Systems
  207. #########################################################################
  208. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  209. #########################################################################
  210. ## PowerPC groups
  211. #########################################################################
  212. LIST_TSEC=" \
  213. ${LIST_83xx} \
  214. ${LIST_85xx} \
  215. ${LIST_86xx} \
  216. "
  217. LIST_powerpc=" \
  218. ${LIST_5xx} \
  219. ${LIST_512x} \
  220. ${LIST_5xxx} \
  221. ${LIST_8xx} \
  222. ${LIST_8220} \
  223. ${LIST_824x} \
  224. ${LIST_8260} \
  225. ${LIST_83xx} \
  226. ${LIST_85xx} \
  227. ${LIST_86xx} \
  228. ${LIST_4xx} \
  229. ${LIST_74xx_7xx}\
  230. "
  231. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  232. # still using "ppc" instead of "powerpc"
  233. LIST_ppc=" \
  234. ${LIST_powerpc} \
  235. "
  236. #########################################################################
  237. ## StrongARM Systems
  238. #########################################################################
  239. LIST_SA="$(boards_by_cpu sa1100)"
  240. #########################################################################
  241. ## ARM7 Systems
  242. #########################################################################
  243. LIST_ARM7=" \
  244. ap7 \
  245. ap720t \
  246. armadillo \
  247. B2 \
  248. ep7312 \
  249. evb4510 \
  250. impa7 \
  251. integratorap \
  252. lpc2292sodimm \
  253. modnet50 \
  254. SMN42 \
  255. "
  256. #########################################################################
  257. ## ARM9 Systems
  258. #########################################################################
  259. LIST_ARM9=" \
  260. a320evb \
  261. ap920t \
  262. ap922_XA10 \
  263. ap926ejs \
  264. ap946es \
  265. ap966 \
  266. aspenite \
  267. cp920t \
  268. cp922_XA10 \
  269. cp926ejs \
  270. cp946es \
  271. cp966 \
  272. da830evm \
  273. da850evm \
  274. edb9301 \
  275. edb9302 \
  276. edb9302a \
  277. edb9307 \
  278. edb9307a \
  279. edb9312 \
  280. edb9315 \
  281. edb9315a \
  282. edminiv2 \
  283. guruplug \
  284. imx27lite \
  285. jadecpu \
  286. km_kirkwood \
  287. lpd7a400 \
  288. magnesium \
  289. mv88f6281gtw_ge \
  290. mx1ads \
  291. mx1fs2 \
  292. netstar \
  293. nhk8815 \
  294. nhk8815_onenand \
  295. omap1510inn \
  296. omap1610h2 \
  297. omap1610inn \
  298. omap5912osk \
  299. omap730p2 \
  300. openrd_base \
  301. openrd_client \
  302. openrd_ultimate \
  303. portl2 \
  304. rd6281a \
  305. sbc2410x \
  306. scb9328 \
  307. sheevaplug \
  308. smdk2400 \
  309. smdk2410 \
  310. spear300 \
  311. spear310 \
  312. spear320 \
  313. spear600 \
  314. VCMA9 \
  315. versatile \
  316. versatileab \
  317. versatilepb \
  318. voiceblue \
  319. davinci_dvevm \
  320. davinci_schmoogie \
  321. davinci_sffsdr \
  322. davinci_sonata \
  323. davinci_dm355evm \
  324. davinci_dm355leopard \
  325. davinci_dm365evm \
  326. davinci_dm6467evm \
  327. "
  328. #########################################################################
  329. ## ARM10 Systems
  330. #########################################################################
  331. LIST_ARM10=" \
  332. integratorcp \
  333. cp1026 \
  334. "
  335. #########################################################################
  336. ## ARM11 Systems
  337. #########################################################################
  338. LIST_ARM11=" \
  339. cp1136 \
  340. omap2420h4 \
  341. apollon \
  342. imx31_litekit \
  343. imx31_phycore \
  344. imx31_phycore_eet \
  345. mx31ads \
  346. mx31pdk \
  347. mx31pdk_nand \
  348. qong \
  349. smdk6400 \
  350. tnetv107x_evm \
  351. "
  352. #########################################################################
  353. ## ARMV7 Systems
  354. #########################################################################
  355. LIST_ARMV7=" \
  356. am3517_crane \
  357. am3517_evm \
  358. ca9x4_ct_vxp \
  359. devkit8000 \
  360. dig297 \
  361. igep0020 \
  362. igep0030 \
  363. mx51evk \
  364. omap3_beagle \
  365. omap3_overo \
  366. omap3_evm \
  367. omap3_pandora \
  368. omap3_sdp3430 \
  369. omap3_zoom1 \
  370. omap3_zoom2 \
  371. omap4_panda \
  372. omap4_sdp4430 \
  373. s5p_goni \
  374. smdkc100 \
  375. "
  376. #########################################################################
  377. ## AT91 Systems
  378. #########################################################################
  379. LIST_at91="$(boards_by_soc at91)\
  380. $(boards_by_soc at91rm9200)\
  381. at91sam9260ek \
  382. at91sam9261ek \
  383. at91sam9263ek \
  384. at91sam9g10ek \
  385. at91sam9g20ek \
  386. at91sam9m10g45ek \
  387. at91sam9rlek \
  388. pm9g45 \
  389. SBC35_A9G20 \
  390. TNY_A9260 \
  391. TNY_A9G20 \
  392. "
  393. #########################################################################
  394. ## Xscale Systems
  395. #########################################################################
  396. LIST_pxa="$(boards_by_cpu pxa)"
  397. LIST_ixp="$(boards_by_cpu ixp)
  398. pdnb3 \
  399. scpu \
  400. "
  401. #########################################################################
  402. ## ARM groups
  403. #########################################################################
  404. LIST_arm=" \
  405. ${LIST_SA} \
  406. ${LIST_ARM7} \
  407. ${LIST_ARM9} \
  408. ${LIST_ARM10} \
  409. ${LIST_ARM11} \
  410. ${LIST_ARMV7} \
  411. ${LIST_at91} \
  412. ${LIST_pxa} \
  413. ${LIST_ixp} \
  414. "
  415. #########################################################################
  416. ## MIPS Systems (default = big endian)
  417. #########################################################################
  418. LIST_mips4kc=" \
  419. incaip \
  420. qemu_mips \
  421. vct_platinum \
  422. vct_platinum_small \
  423. vct_platinum_onenand \
  424. vct_platinum_onenand_small \
  425. vct_platinumavc \
  426. vct_platinumavc_small \
  427. vct_platinumavc_onenand \
  428. vct_platinumavc_onenand_small \
  429. vct_premium \
  430. vct_premium_small \
  431. vct_premium_onenand \
  432. vct_premium_onenand_small \
  433. "
  434. LIST_mips5kc=""
  435. LIST_au1xx0=" \
  436. dbau1000 \
  437. dbau1100 \
  438. dbau1500 \
  439. dbau1550 \
  440. dbau1550_el \
  441. gth2 \
  442. "
  443. LIST_mips=" \
  444. ${LIST_mips4kc} \
  445. ${LIST_mips5kc} \
  446. ${LIST_au1xx0} \
  447. "
  448. #########################################################################
  449. ## MIPS Systems (little endian)
  450. #########################################################################
  451. LIST_mips4kc_el=""
  452. LIST_mips5kc_el=""
  453. LIST_au1xx0_el=" \
  454. dbau1550_el \
  455. pb1000 \
  456. "
  457. LIST_mips_el=" \
  458. ${LIST_mips4kc_el} \
  459. ${LIST_mips5kc_el} \
  460. ${LIST_au1xx0_el} \
  461. "
  462. #########################################################################
  463. ## x86 Systems
  464. #########################################################################
  465. LIST_x86="$(boards_by_arch x86)"
  466. #########################################################################
  467. ## Nios-II Systems
  468. #########################################################################
  469. LIST_nios2="$(boards_by_arch nios2)"
  470. #########################################################################
  471. ## MicroBlaze Systems
  472. #########################################################################
  473. LIST_microblaze="$(boards_by_arch microblaze)"
  474. #########################################################################
  475. ## ColdFire Systems
  476. #########################################################################
  477. LIST_coldfire="$(boards_by_arch m68k)
  478. astro_mcf5373l \
  479. cobra5272 \
  480. EB+MCF-EV123 \
  481. EB+MCF-EV123_internal \
  482. M52277EVB \
  483. M5235EVB \
  484. M5329AFEE \
  485. M5373EVB \
  486. M54451EVB \
  487. M54455EVB \
  488. M5475AFE \
  489. M5485AFE \
  490. "
  491. #########################################################################
  492. ## AVR32 Systems
  493. #########################################################################
  494. LIST_avr32="$(boards_by_arch avr32)"
  495. #########################################################################
  496. ## Blackfin Systems
  497. #########################################################################
  498. LIST_blackfin="$(boards_by_arch blackfin)"
  499. #########################################################################
  500. ## SH Systems
  501. #########################################################################
  502. LIST_sh2="$(boards_by_cpu sh2)"
  503. LIST_sh3="$(boards_by_cpu sh3)"
  504. LIST_sh4="$(boards_by_cpu sh4)"
  505. LIST_sh="$(boards_by_arch sh)"
  506. #########################################################################
  507. ## SPARC Systems
  508. #########################################################################
  509. LIST_sparc="$(boards_by_arch sparc)"
  510. #-----------------------------------------------------------------------
  511. build_target() {
  512. target=$1
  513. ${MAKE} distclean >/dev/null
  514. ${MAKE} -s ${target}_config
  515. ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
  516. | tee ${LOG_DIR}/$target.ERR
  517. # Check for 'make' errors
  518. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  519. RC=1
  520. fi
  521. if [ -s ${LOG_DIR}/$target.ERR ] ; then
  522. ERR_CNT=$((ERR_CNT + 1))
  523. ERR_LIST="${ERR_LIST} $target"
  524. else
  525. rm ${LOG_DIR}/$target.ERR
  526. fi
  527. TOTAL_CNT=$((TOTAL_CNT + 1))
  528. ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
  529. | tee -a ${LOG_DIR}/$target.MAKELOG
  530. }
  531. build_targets() {
  532. for t in "$@" ; do
  533. # If a LIST_xxx var exists, use it. But avoid variable
  534. # expansion in the eval when a board name contains certain
  535. # characters that the shell interprets.
  536. case ${t} in
  537. *[-+=]*) list= ;;
  538. *) list=$(eval echo '${LIST_'$t'}') ;;
  539. esac
  540. if [ -n "${list}" ] ; then
  541. build_targets ${list}
  542. else
  543. build_target ${t}
  544. fi
  545. done
  546. }
  547. #-----------------------------------------------------------------------
  548. print_stats() {
  549. echo ""
  550. echo "--------------------- SUMMARY ----------------------------"
  551. echo "Boards compiled: ${TOTAL_CNT}"
  552. if [ ${ERR_CNT} -gt 0 ] ; then
  553. echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )"
  554. fi
  555. echo "----------------------------------------------------------"
  556. exit $RC
  557. }
  558. #-----------------------------------------------------------------------
  559. # Build target groups selected by options, plus any command line args
  560. set -- ${SELECTED} "$@"
  561. # run PowerPC by default
  562. [ $# = 0 ] && set -- powerpc
  563. build_targets "$@"