MAKEALL 16 KB

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