MAKEALL 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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 iontroduction 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. fi
  119. #########################################################################
  120. # Print statistics when we exit
  121. trap exit 1 2 3 15
  122. trap print_stats 0
  123. # Determine number of CPU cores if no default was set
  124. : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
  125. if [ "$BUILD_NCPUS" -gt 1 ]
  126. then
  127. JOBS="-j $((BUILD_NCPUS + 1))"
  128. else
  129. JOBS=""
  130. fi
  131. if [ "${CROSS_COMPILE}" ] ; then
  132. MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
  133. else
  134. MAKE=make
  135. fi
  136. if [ "${MAKEALL_LOGDIR}" ] ; then
  137. LOG_DIR=${MAKEALL_LOGDIR}
  138. else
  139. LOG_DIR="LOG"
  140. fi
  141. if [ ! "${BUILD_DIR}" ] ; then
  142. BUILD_DIR="."
  143. fi
  144. [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} || exit 1
  145. LIST=""
  146. # Keep track of the number of builds and errors
  147. ERR_CNT=0
  148. ERR_LIST=""
  149. TOTAL_CNT=0
  150. RC=0
  151. # Helper funcs for parsing boards.cfg
  152. boards_by_field()
  153. {
  154. awk \
  155. -v field="$1" \
  156. -v select="$2" \
  157. '($1 !~ /^#/ && $field == select) { print $1 }' \
  158. boards.cfg
  159. }
  160. boards_by_arch() { boards_by_field 2 "$@" ; }
  161. boards_by_cpu() { boards_by_field 3 "$@" ; }
  162. #########################################################################
  163. ## MPC5xx Systems
  164. #########################################################################
  165. LIST_5xx="$(boards_by_cpu mpc5xx)"
  166. #########################################################################
  167. ## MPC5xxx Systems
  168. #########################################################################
  169. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  170. #########################################################################
  171. ## MPC512x Systems
  172. #########################################################################
  173. LIST_512x="$(boards_by_cpu mpc512x)"
  174. #########################################################################
  175. ## MPC8xx Systems
  176. #########################################################################
  177. LIST_8xx="$(boards_by_cpu mpc8xx)"
  178. #########################################################################
  179. ## PPC4xx Systems
  180. #########################################################################
  181. LIST_4xx="$(boards_by_cpu ppc4xx)"
  182. #########################################################################
  183. ## MPC8220 Systems
  184. #########################################################################
  185. LIST_8220="$(boards_by_cpu mpc8220)"
  186. #########################################################################
  187. ## MPC824x Systems
  188. #########################################################################
  189. LIST_824x="$(boards_by_cpu mpc824x)"
  190. #########################################################################
  191. ## MPC8260 Systems (includes 8250, 8255 etc.)
  192. #########################################################################
  193. LIST_8260="$(boards_by_cpu mpc8260)"
  194. #########################################################################
  195. ## MPC83xx Systems (includes 8349, etc.)
  196. #########################################################################
  197. LIST_83xx="$(boards_by_cpu mpc83xx)"
  198. #########################################################################
  199. ## MPC85xx Systems (includes 8540, 8560 etc.)
  200. #########################################################################
  201. LIST_85xx="$(boards_by_cpu mpc85xx)"
  202. #########################################################################
  203. ## MPC86xx Systems
  204. #########################################################################
  205. LIST_86xx="$(boards_by_cpu mpc86xx)"
  206. #########################################################################
  207. ## 74xx/7xx Systems
  208. #########################################################################
  209. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  210. #########################################################################
  211. ## PowerPC groups
  212. #########################################################################
  213. LIST_TSEC=" \
  214. ${LIST_83xx} \
  215. ${LIST_85xx} \
  216. ${LIST_86xx} \
  217. "
  218. LIST_powerpc=" \
  219. ${LIST_5xx} \
  220. ${LIST_512x} \
  221. ${LIST_5xxx} \
  222. ${LIST_8xx} \
  223. ${LIST_8220} \
  224. ${LIST_824x} \
  225. ${LIST_8260} \
  226. ${LIST_83xx} \
  227. ${LIST_85xx} \
  228. ${LIST_86xx} \
  229. ${LIST_4xx} \
  230. ${LIST_74xx_7xx}\
  231. "
  232. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  233. # still using "ppc" instead of "powerpc"
  234. LIST_ppc=" \
  235. ${LIST_powerpc} \
  236. "
  237. #########################################################################
  238. ## StrongARM Systems
  239. #########################################################################
  240. LIST_SA="$(boards_by_cpu sa1100)"
  241. #########################################################################
  242. ## ARM7 Systems
  243. #########################################################################
  244. LIST_ARM7=" \
  245. ap7 \
  246. ap720t \
  247. armadillo \
  248. B2 \
  249. ep7312 \
  250. evb4510 \
  251. impa7 \
  252. integratorap \
  253. lpc2292sodimm \
  254. modnet50 \
  255. SMN42 \
  256. "
  257. #########################################################################
  258. ## ARM9 Systems
  259. #########################################################################
  260. LIST_ARM9=" \
  261. a320evb \
  262. ap920t \
  263. ap922_XA10 \
  264. ap926ejs \
  265. ap946es \
  266. ap966 \
  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. lpd7a400 \
  287. magnesium \
  288. mv88f6281gtw_ge \
  289. mx1ads \
  290. mx1fs2 \
  291. netstar \
  292. nhk8815 \
  293. nhk8815_onenand \
  294. omap1510inn \
  295. omap1610h2 \
  296. omap1610inn \
  297. omap5912osk \
  298. omap730p2 \
  299. openrd_base \
  300. rd6281a \
  301. sbc2410x \
  302. scb9328 \
  303. sheevaplug \
  304. smdk2400 \
  305. smdk2410 \
  306. spear300 \
  307. spear310 \
  308. spear320 \
  309. spear600 \
  310. suen3 \
  311. trab \
  312. VCMA9 \
  313. versatile \
  314. versatileab \
  315. versatilepb \
  316. voiceblue \
  317. davinci_dvevm \
  318. davinci_schmoogie \
  319. davinci_sffsdr \
  320. davinci_sonata \
  321. davinci_dm355evm \
  322. davinci_dm355leopard \
  323. davinci_dm365evm \
  324. davinci_dm6467evm \
  325. "
  326. #########################################################################
  327. ## ARM10 Systems
  328. #########################################################################
  329. LIST_ARM10=" \
  330. integratorcp \
  331. cp1026 \
  332. "
  333. #########################################################################
  334. ## ARM11 Systems
  335. #########################################################################
  336. LIST_ARM11=" \
  337. cp1136 \
  338. omap2420h4 \
  339. apollon \
  340. imx31_litekit \
  341. imx31_phycore \
  342. imx31_phycore_eet \
  343. mx31ads \
  344. mx31pdk \
  345. mx31pdk_nand \
  346. qong \
  347. smdk6400 \
  348. tnetv107x_evm \
  349. "
  350. #########################################################################
  351. ## ARMV7 Systems
  352. #########################################################################
  353. LIST_ARMV7=" \
  354. am3517_evm \
  355. ca9x4_ct_vxp \
  356. devkit8000 \
  357. igep0020 \
  358. igep0030 \
  359. mx51evk \
  360. omap3_beagle \
  361. omap3_overo \
  362. omap3_evm \
  363. omap3_pandora \
  364. omap3_sdp3430 \
  365. omap3_zoom1 \
  366. omap3_zoom2 \
  367. omap4_panda \
  368. omap4_sdp4430 \
  369. s5p_goni \
  370. smdkc100 \
  371. "
  372. #########################################################################
  373. ## AT91 Systems
  374. #########################################################################
  375. LIST_at91=" \
  376. afeb9260 \
  377. at91cap9adk \
  378. at91rm9200dk \
  379. at91rm9200ek \
  380. at91sam9260ek \
  381. at91sam9261ek \
  382. at91sam9263ek \
  383. at91sam9g10ek \
  384. at91sam9g20ek \
  385. at91sam9m10g45ek \
  386. at91sam9rlek \
  387. cmc_pu2 \
  388. CPUAT91 \
  389. CPU9260 \
  390. CPU9G20 \
  391. csb637 \
  392. eb_cpux9k2 \
  393. kb9202 \
  394. meesc \
  395. mp2usb \
  396. m501sk \
  397. otc570 \
  398. pm9261 \
  399. pm9263 \
  400. pm9g45 \
  401. SBC35_A9G20 \
  402. TNY_A9260 \
  403. TNY_A9G20 \
  404. "
  405. #########################################################################
  406. ## Xscale Systems
  407. #########################################################################
  408. LIST_pxa="$(boards_by_cpu pxa)"
  409. LIST_ixp="$(boards_by_cpu ixp)
  410. pdnb3 \
  411. scpu \
  412. "
  413. #########################################################################
  414. ## ARM groups
  415. #########################################################################
  416. LIST_arm=" \
  417. ${LIST_SA} \
  418. ${LIST_ARM7} \
  419. ${LIST_ARM9} \
  420. ${LIST_ARM10} \
  421. ${LIST_ARM11} \
  422. ${LIST_ARMV7} \
  423. ${LIST_at91} \
  424. ${LIST_pxa} \
  425. ${LIST_ixp} \
  426. "
  427. #########################################################################
  428. ## MIPS Systems (default = big endian)
  429. #########################################################################
  430. LIST_mips4kc=" \
  431. incaip \
  432. qemu_mips \
  433. vct_platinum \
  434. vct_platinum_small \
  435. vct_platinum_onenand \
  436. vct_platinum_onenand_small \
  437. vct_platinumavc \
  438. vct_platinumavc_small \
  439. vct_platinumavc_onenand \
  440. vct_platinumavc_onenand_small \
  441. vct_premium \
  442. vct_premium_small \
  443. vct_premium_onenand \
  444. vct_premium_onenand_small \
  445. "
  446. LIST_mips5kc=" \
  447. purple \
  448. "
  449. LIST_au1xx0=" \
  450. dbau1000 \
  451. dbau1100 \
  452. dbau1500 \
  453. dbau1550 \
  454. dbau1550_el \
  455. gth2 \
  456. "
  457. LIST_mips=" \
  458. ${LIST_mips4kc} \
  459. ${LIST_mips5kc} \
  460. ${LIST_au1xx0} \
  461. "
  462. #########################################################################
  463. ## MIPS Systems (little endian)
  464. #########################################################################
  465. LIST_mips4kc_el=""
  466. LIST_mips5kc_el=""
  467. LIST_au1xx0_el=" \
  468. dbau1550_el \
  469. pb1000 \
  470. "
  471. LIST_mips_el=" \
  472. ${LIST_mips4kc_el} \
  473. ${LIST_mips5kc_el} \
  474. ${LIST_au1xx0_el} \
  475. "
  476. #########################################################################
  477. ## i386 Systems
  478. #########################################################################
  479. LIST_x86="$(boards_by_arch i386)"
  480. #########################################################################
  481. ## Nios-II Systems
  482. #########################################################################
  483. LIST_nios2="$(boards_by_arch nios2)
  484. nios2-generic \
  485. "
  486. #########################################################################
  487. ## MicroBlaze Systems
  488. #########################################################################
  489. LIST_microblaze="$(boards_by_arch microblaze)"
  490. #########################################################################
  491. ## ColdFire Systems
  492. #########################################################################
  493. LIST_coldfire="$(boards_by_arch m68k)
  494. astro_mcf5373l \
  495. cobra5272 \
  496. EB+MCF-EV123 \
  497. EB+MCF-EV123_internal \
  498. M52277EVB \
  499. M5235EVB \
  500. M5329AFEE \
  501. M5373EVB \
  502. M54451EVB \
  503. M54455EVB \
  504. M5475AFE \
  505. M5485AFE \
  506. "
  507. #########################################################################
  508. ## AVR32 Systems
  509. #########################################################################
  510. LIST_avr32="$(boards_by_arch avr32)"
  511. #########################################################################
  512. ## Blackfin Systems
  513. #########################################################################
  514. LIST_blackfin="$(boards_by_arch blackfin)"
  515. #########################################################################
  516. ## SH Systems
  517. #########################################################################
  518. LIST_sh2="$(boards_by_cpu sh2)"
  519. LIST_sh3="$(boards_by_cpu sh3)"
  520. LIST_sh4="$(boards_by_cpu sh4)"
  521. LIST_sh="$(boards_by_arch sh)"
  522. #########################################################################
  523. ## SPARC Systems
  524. #########################################################################
  525. LIST_sparc="$(boards_by_arch sparc)"
  526. #-----------------------------------------------------------------------
  527. build_target() {
  528. target=$1
  529. ${MAKE} distclean >/dev/null
  530. ${MAKE} -s ${target}_config
  531. ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
  532. | tee ${LOG_DIR}/$target.ERR
  533. # Check for 'make' errors
  534. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  535. RC=1
  536. fi
  537. if [ -s ${LOG_DIR}/$target.ERR ] ; then
  538. ERR_CNT=$((ERR_CNT + 1))
  539. ERR_LIST="${ERR_LIST} $target"
  540. else
  541. rm ${LOG_DIR}/$target.ERR
  542. fi
  543. TOTAL_CNT=$((TOTAL_CNT + 1))
  544. ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
  545. | tee -a ${LOG_DIR}/$target.MAKELOG
  546. }
  547. build_targets() {
  548. for t in "$@" ; do
  549. # If a LIST_xxx var exists, use it. But avoid variable
  550. # expansion in the eval when a board name contains certain
  551. # characters that the shell interprets.
  552. case ${t} in
  553. *[-+=]*) list= ;;
  554. *) list=$(eval echo '${LIST_'$t'}') ;;
  555. esac
  556. if [ -n "${list}" ] ; then
  557. build_targets ${list}
  558. else
  559. build_target ${t}
  560. fi
  561. done
  562. }
  563. #-----------------------------------------------------------------------
  564. print_stats() {
  565. echo ""
  566. echo "--------------------- SUMMARY ----------------------------"
  567. echo "Boards compiled: ${TOTAL_CNT}"
  568. if [ ${ERR_CNT} -gt 0 ] ; then
  569. echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )"
  570. fi
  571. echo "----------------------------------------------------------"
  572. exit $RC
  573. }
  574. #-----------------------------------------------------------------------
  575. # Build target groups selected by options, plus any command line args
  576. set -- ${SELECTED} "$@"
  577. # run PowerPC by default
  578. [ $# = 0 ] && set -- powerpc
  579. build_targets "$@"