MAKEALL 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. ## ARM9 Systems
  242. #########################################################################
  243. LIST_ARM9="$(boards_by_cpu arm920t) \
  244. $(boards_by_cpu arm926ejs) \
  245. $(boards_by_cpu arm925t) \
  246. omap1610h2 \
  247. omap1610inn \
  248. omap730p2 \
  249. "
  250. #########################################################################
  251. ## ARM11 Systems
  252. #########################################################################
  253. LIST_ARM11="$(boards_by_cpu arm1136) \
  254. apollon \
  255. imx31_phycore \
  256. imx31_phycore_eet \
  257. mx31pdk \
  258. mx31pdk_nand \
  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_mips5kc=""
  310. LIST_au1xx0=" \
  311. dbau1000 \
  312. dbau1100 \
  313. dbau1500 \
  314. dbau1550 \
  315. dbau1550_el \
  316. gth2 \
  317. "
  318. LIST_mips=" \
  319. ${LIST_mips4kc} \
  320. ${LIST_mips5kc} \
  321. ${LIST_au1xx0} \
  322. "
  323. #########################################################################
  324. ## MIPS Systems (little endian)
  325. #########################################################################
  326. LIST_mips4kc_el=" \
  327. qi_lb60 \
  328. "
  329. LIST_mips5kc_el=""
  330. LIST_au1xx0_el=" \
  331. dbau1550_el \
  332. pb1000 \
  333. "
  334. LIST_mips_el=" \
  335. ${LIST_mips4kc_el} \
  336. ${LIST_mips5kc_el} \
  337. ${LIST_au1xx0_el} \
  338. "
  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. ${MAKE} distclean >/dev/null
  390. ${MAKE} -s ${target}_config
  391. ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
  392. | tee ${LOG_DIR}/$target.ERR
  393. # Check for 'make' errors
  394. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  395. RC=1
  396. fi
  397. if [ -s ${LOG_DIR}/$target.ERR ] ; then
  398. ERR_CNT=$((ERR_CNT + 1))
  399. ERR_LIST="${ERR_LIST} $target"
  400. else
  401. rm ${LOG_DIR}/$target.ERR
  402. fi
  403. TOTAL_CNT=$((TOTAL_CNT + 1))
  404. ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
  405. | tee -a ${LOG_DIR}/$target.MAKELOG
  406. }
  407. build_targets() {
  408. for t in "$@" ; do
  409. # If a LIST_xxx var exists, use it. But avoid variable
  410. # expansion in the eval when a board name contains certain
  411. # characters that the shell interprets.
  412. case ${t} in
  413. *[-+=]*) list= ;;
  414. *) list=$(eval echo '${LIST_'$t'}') ;;
  415. esac
  416. if [ -n "${list}" ] ; then
  417. build_targets ${list}
  418. else
  419. build_target ${t}
  420. fi
  421. done
  422. }
  423. #-----------------------------------------------------------------------
  424. print_stats() {
  425. echo ""
  426. echo "--------------------- SUMMARY ----------------------------"
  427. echo "Boards compiled: ${TOTAL_CNT}"
  428. if [ ${ERR_CNT} -gt 0 ] ; then
  429. echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )"
  430. fi
  431. echo "----------------------------------------------------------"
  432. exit $RC
  433. }
  434. #-----------------------------------------------------------------------
  435. # Build target groups selected by options, plus any command line args
  436. set -- ${SELECTED} "$@"
  437. # run PowerPC by default
  438. [ $# = 0 ] && set -- powerpc
  439. build_targets "$@"