MAKEALL 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  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. -m, --maintainers List all targets and maintainer email
  19. -M, --mails List all targets and all affilated emails
  20. -h, --help This help output
  21. Selections by these options are logically ANDed; if the same option
  22. is used repeatedly, such selections are ORed. So "-v FOO -v BAR"
  23. will select all configurations where the vendor is either FOO or
  24. BAR. Any additional arguments specified on the command line are
  25. always build additionally. See the boards.cfg file for more info.
  26. If no boards are specified, then the default is "powerpc".
  27. Environment variables:
  28. BUILD_NCPUS number of parallel make jobs (default: auto)
  29. CROSS_COMPILE cross-compiler toolchain prefix (default: "")
  30. MAKEALL_LOGDIR output all logs to here (default: ./LOG/)
  31. BUILD_DIR output build directory (default: ./)
  32. BUILD_NBUILDS number of parallel targets (default: 1)
  33. Examples:
  34. - build all Power Architecture boards:
  35. MAKEALL -a powerpc
  36. MAKEALL --arch powerpc
  37. MAKEALL powerpc
  38. - build all PowerPC boards manufactured by vendor "esd":
  39. MAKEALL -a powerpc -v esd
  40. - build all PowerPC boards manufactured either by "keymile" or "siemens":
  41. MAKEALL -a powerpc -v keymile -v siemens
  42. - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards:
  43. MAKEALL -c mpc83xx -v freescale 4xx
  44. EOF
  45. exit ${ret}
  46. }
  47. SHORT_OPTS="ha:c:v:s:lmM"
  48. LONG_OPTS="help,arch:,cpu:,vendor:,soc:,list,maintainers,mails"
  49. # Option processing based on util-linux-2.13/getopt-parse.bash
  50. # Note that we use `"$@"' to let each command-line parameter expand to a
  51. # separate word. The quotes around `$@' are essential!
  52. # We need TEMP as the `eval set --' would nuke the return value of
  53. # getopt.
  54. TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \
  55. -n 'MAKEALL' -- "$@"`
  56. [ $? != 0 ] && usage 1
  57. # Note the quotes around `$TEMP': they are essential!
  58. eval set -- "$TEMP"
  59. SELECTED=''
  60. ONLY_LIST=''
  61. PRINT_MAINTS=''
  62. MAINTAINERS_ONLY=''
  63. while true ; do
  64. case "$1" in
  65. -a|--arch)
  66. # echo "Option ARCH: argument \`$2'"
  67. if [ "$opt_a" ] ; then
  68. opt_a="${opt_a%)} || \$2 == \"$2\")"
  69. else
  70. opt_a="(\$2 == \"$2\")"
  71. fi
  72. SELECTED='y'
  73. shift 2 ;;
  74. -c|--cpu)
  75. # echo "Option CPU: argument \`$2'"
  76. if [ "$opt_c" ] ; then
  77. opt_c="${opt_c%)} || \$3 == \"$2\")"
  78. else
  79. opt_c="(\$3 == \"$2\")"
  80. fi
  81. SELECTED='y'
  82. shift 2 ;;
  83. -s|--soc)
  84. # echo "Option SoC: argument \`$2'"
  85. if [ "$opt_s" ] ; then
  86. opt_s="${opt_s%)} || \$6 == \"$2\")"
  87. else
  88. opt_s="(\$6 == \"$2\")"
  89. fi
  90. SELECTED='y'
  91. shift 2 ;;
  92. -v|--vendor)
  93. # echo "Option VENDOR: argument \`$2'"
  94. if [ "$opt_v" ] ; then
  95. opt_v="${opt_v%)} || \$5 == \"$2\")"
  96. else
  97. opt_v="(\$5 == \"$2\")"
  98. fi
  99. SELECTED='y'
  100. shift 2 ;;
  101. -l|--list)
  102. ONLY_LIST='y'
  103. shift ;;
  104. -m|--maintainers)
  105. ONLY_LIST='y'
  106. PRINT_MAINTS='y'
  107. MAINTAINERS_ONLY='y'
  108. shift ;;
  109. -M|--mails)
  110. ONLY_LIST='y'
  111. PRINT_MAINTS='y'
  112. shift ;;
  113. -h|--help)
  114. usage ;;
  115. --)
  116. shift ; break ;;
  117. *)
  118. echo "Internal error!" >&2 ; exit 1 ;;
  119. esac
  120. done
  121. # echo "Remaining arguments:"
  122. # for arg do echo '--> '"\`$arg'" ; done
  123. FILTER="\$1 !~ /^#/"
  124. [ "$opt_a" ] && FILTER="${FILTER} && $opt_a"
  125. [ "$opt_c" ] && FILTER="${FILTER} && $opt_c"
  126. [ "$opt_s" ] && FILTER="${FILTER} && $opt_s"
  127. [ "$opt_v" ] && FILTER="${FILTER} && $opt_v"
  128. if [ "$SELECTED" ] ; then
  129. SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg)
  130. # Make sure some boards from boards.cfg are actually found
  131. if [ -z "$SELECTED" ] ; then
  132. echo "Error: No boards selected, invalid arguments"
  133. exit 1
  134. fi
  135. fi
  136. #########################################################################
  137. # Print statistics when we exit
  138. trap exit 1 2 3 15
  139. trap print_stats 0
  140. # Determine number of CPU cores if no default was set
  141. : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
  142. if [ "$BUILD_NCPUS" -gt 1 ]
  143. then
  144. JOBS="-j $((BUILD_NCPUS + 1))"
  145. else
  146. JOBS=""
  147. fi
  148. if [ "${CROSS_COMPILE}" ] ; then
  149. MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
  150. else
  151. MAKE=make
  152. fi
  153. if [ "${MAKEALL_LOGDIR}" ] ; then
  154. LOG_DIR=${MAKEALL_LOGDIR}
  155. else
  156. LOG_DIR="LOG"
  157. fi
  158. : ${BUILD_NBUILDS:=1}
  159. BUILD_MANY=0
  160. if [ "${BUILD_NBUILDS}" -gt 1 ] ; then
  161. BUILD_MANY=1
  162. : ${BUILD_DIR:=./build}
  163. mkdir -p "${BUILD_DIR}/ERR"
  164. find "${BUILD_DIR}/ERR/" -type f -exec rm -f {} +
  165. fi
  166. : ${BUILD_DIR:=.}
  167. OUTPUT_PREFIX="${BUILD_DIR}"
  168. [ -d ${LOG_DIR} ] || mkdir "${LOG_DIR}" || exit 1
  169. find "${LOG_DIR}/" -type f -exec rm -f {} +
  170. LIST=""
  171. # Keep track of the number of builds and errors
  172. ERR_CNT=0
  173. ERR_LIST=""
  174. WRN_CNT=0
  175. WRN_LIST=""
  176. TOTAL_CNT=0
  177. CURRENT_CNT=0
  178. OLDEST_IDX=1
  179. RC=0
  180. # Helper funcs for parsing boards.cfg
  181. boards_by_field()
  182. {
  183. awk \
  184. -v field="$1" \
  185. -v select="$2" \
  186. '($1 !~ /^#/ && $field == select) { print $1 }' \
  187. boards.cfg
  188. }
  189. boards_by_arch() { boards_by_field 2 "$@" ; }
  190. boards_by_cpu() { boards_by_field 3 "$@" ; }
  191. boards_by_soc() { boards_by_field 6 "$@" ; }
  192. #########################################################################
  193. ## MPC5xx Systems
  194. #########################################################################
  195. LIST_5xx="$(boards_by_cpu mpc5xx)"
  196. #########################################################################
  197. ## MPC5xxx Systems
  198. #########################################################################
  199. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  200. #########################################################################
  201. ## MPC512x Systems
  202. #########################################################################
  203. LIST_512x="$(boards_by_cpu mpc512x)"
  204. #########################################################################
  205. ## MPC8xx Systems
  206. #########################################################################
  207. LIST_8xx="$(boards_by_cpu mpc8xx)"
  208. #########################################################################
  209. ## PPC4xx Systems
  210. #########################################################################
  211. LIST_4xx="$(boards_by_cpu ppc4xx)"
  212. #########################################################################
  213. ## MPC8220 Systems
  214. #########################################################################
  215. LIST_8220="$(boards_by_cpu mpc8220)"
  216. #########################################################################
  217. ## MPC824x Systems
  218. #########################################################################
  219. LIST_824x="$(boards_by_cpu mpc824x)"
  220. #########################################################################
  221. ## MPC8260 Systems (includes 8250, 8255 etc.)
  222. #########################################################################
  223. LIST_8260="$(boards_by_cpu mpc8260)"
  224. #########################################################################
  225. ## MPC83xx Systems (includes 8349, etc.)
  226. #########################################################################
  227. LIST_83xx="$(boards_by_cpu mpc83xx)"
  228. #########################################################################
  229. ## MPC85xx Systems (includes 8540, 8560 etc.)
  230. #########################################################################
  231. LIST_85xx="$(boards_by_cpu mpc85xx)"
  232. #########################################################################
  233. ## MPC86xx Systems
  234. #########################################################################
  235. LIST_86xx="$(boards_by_cpu mpc86xx)"
  236. #########################################################################
  237. ## 74xx/7xx Systems
  238. #########################################################################
  239. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  240. #########################################################################
  241. ## PowerPC groups
  242. #########################################################################
  243. LIST_TSEC=" \
  244. ${LIST_83xx} \
  245. ${LIST_85xx} \
  246. ${LIST_86xx} \
  247. "
  248. LIST_powerpc=" \
  249. ${LIST_5xx} \
  250. ${LIST_512x} \
  251. ${LIST_5xxx} \
  252. ${LIST_8xx} \
  253. ${LIST_8220} \
  254. ${LIST_824x} \
  255. ${LIST_8260} \
  256. ${LIST_83xx} \
  257. ${LIST_85xx} \
  258. ${LIST_86xx} \
  259. ${LIST_4xx} \
  260. ${LIST_74xx_7xx}\
  261. "
  262. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  263. # still using "ppc" instead of "powerpc"
  264. LIST_ppc=" \
  265. ${LIST_powerpc} \
  266. "
  267. #########################################################################
  268. ## StrongARM Systems
  269. #########################################################################
  270. LIST_SA="$(boards_by_cpu sa1100)"
  271. #########################################################################
  272. ## ARM9 Systems
  273. #########################################################################
  274. LIST_ARM9="$(boards_by_cpu arm920t) \
  275. $(boards_by_cpu arm926ejs) \
  276. $(boards_by_cpu arm925t) \
  277. "
  278. #########################################################################
  279. ## ARM11 Systems
  280. #########################################################################
  281. LIST_ARM11="$(boards_by_cpu arm1136)"
  282. #########################################################################
  283. ## ARMV7 Systems
  284. #########################################################################
  285. LIST_ARMV7="$(boards_by_cpu armv7)"
  286. #########################################################################
  287. ## AT91 Systems
  288. #########################################################################
  289. LIST_at91="$(boards_by_soc at91)"
  290. #########################################################################
  291. ## Xscale Systems
  292. #########################################################################
  293. LIST_pxa="$(boards_by_cpu pxa)"
  294. LIST_ixp="$(boards_by_cpu ixp)"
  295. #########################################################################
  296. ## ARM groups
  297. #########################################################################
  298. LIST_arm=" \
  299. ${LIST_SA} \
  300. ${LIST_ARM9} \
  301. ${LIST_ARM10} \
  302. ${LIST_ARM11} \
  303. ${LIST_ARMV7} \
  304. ${LIST_at91} \
  305. ${LIST_pxa} \
  306. ${LIST_ixp} \
  307. "
  308. #########################################################################
  309. ## MIPS Systems (default = big endian)
  310. #########################################################################
  311. LIST_mips4kc=" \
  312. incaip \
  313. qemu_mips \
  314. vct_platinum \
  315. vct_platinum_small \
  316. vct_platinum_onenand \
  317. vct_platinum_onenand_small \
  318. vct_platinumavc \
  319. vct_platinumavc_small \
  320. vct_platinumavc_onenand \
  321. vct_platinumavc_onenand_small \
  322. vct_premium \
  323. vct_premium_small \
  324. vct_premium_onenand \
  325. vct_premium_onenand_small \
  326. "
  327. LIST_au1xx0=" \
  328. dbau1000 \
  329. dbau1100 \
  330. dbau1500 \
  331. dbau1550 \
  332. gth2 \
  333. "
  334. LIST_mips=" \
  335. ${LIST_mips4kc} \
  336. ${LIST_mips5kc} \
  337. ${LIST_au1xx0} \
  338. "
  339. #########################################################################
  340. ## MIPS Systems (little endian)
  341. #########################################################################
  342. LIST_xburst_el=" \
  343. qi_lb60 \
  344. "
  345. LIST_au1xx0_el=" \
  346. dbau1550_el \
  347. pb1000 \
  348. "
  349. LIST_mips_el=" \
  350. ${LIST_xburst_el} \
  351. ${LIST_au1xx0_el} \
  352. "
  353. #########################################################################
  354. ## OpenRISC Systems
  355. #########################################################################
  356. LIST_openrisc="$(boards_by_arch openrisc)"
  357. #########################################################################
  358. ## x86 Systems
  359. #########################################################################
  360. LIST_x86="$(boards_by_arch x86)"
  361. #########################################################################
  362. ## Nios-II Systems
  363. #########################################################################
  364. LIST_nios2="$(boards_by_arch nios2)"
  365. #########################################################################
  366. ## MicroBlaze Systems
  367. #########################################################################
  368. LIST_microblaze="$(boards_by_arch microblaze)"
  369. #########################################################################
  370. ## ColdFire Systems
  371. #########################################################################
  372. LIST_m68k="$(boards_by_arch m68k)
  373. EB+MCF-EV123 \
  374. EB+MCF-EV123_internal \
  375. M52277EVB \
  376. M5235EVB \
  377. M54451EVB \
  378. M54455EVB \
  379. "
  380. LIST_coldfire=${LIST_m68k}
  381. #########################################################################
  382. ## AVR32 Systems
  383. #########################################################################
  384. LIST_avr32="$(boards_by_arch avr32)"
  385. #########################################################################
  386. ## Blackfin Systems
  387. #########################################################################
  388. LIST_blackfin="$(boards_by_arch blackfin)"
  389. #########################################################################
  390. ## SH Systems
  391. #########################################################################
  392. LIST_sh2="$(boards_by_cpu sh2)"
  393. LIST_sh3="$(boards_by_cpu sh3)"
  394. LIST_sh4="$(boards_by_cpu sh4)"
  395. LIST_sh="$(boards_by_arch sh)"
  396. #########################################################################
  397. ## SPARC Systems
  398. #########################################################################
  399. LIST_sparc="$(boards_by_arch sparc)"
  400. #########################################################################
  401. ## NDS32 Systems
  402. #########################################################################
  403. LIST_nds32="$(boards_by_arch nds32)"
  404. #-----------------------------------------------------------------------
  405. get_target_location() {
  406. local target=$1
  407. local BOARD_NAME=""
  408. local CONFIG_NAME=""
  409. local board=""
  410. local vendor=""
  411. # Automatic mode
  412. local line=`egrep -i "^[[:space:]]*${target}[[:space:]]" boards.cfg`
  413. if [ -z "${line}" ] ; then echo "" ; return ; fi
  414. set ${line}
  415. # add default board name if needed
  416. [ $# = 3 ] && set ${line} ${1}
  417. CONFIG_NAME="${1%_config}"
  418. [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
  419. if [ "$4" = "-" ] ; then
  420. board=${BOARD_NAME}
  421. else
  422. board="$4"
  423. fi
  424. [ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5"
  425. [ $# -gt 6 ] && [ "$7" != "-" ] && {
  426. tmp="${7%:*}"
  427. if [ "$tmp" ] ; then
  428. CONFIG_NAME="$tmp"
  429. fi
  430. }
  431. # Assign board directory to BOARDIR variable
  432. if [ -z "${vendor}" ] ; then
  433. BOARDDIR=${board}
  434. else
  435. BOARDDIR=${vendor}/${board}
  436. fi
  437. echo "${CONFIG_NAME}:${BOARDDIR}"
  438. }
  439. get_target_maintainers() {
  440. local name=`echo $1 | cut -d : -f 1`
  441. if ! grep -qsi "[[:blank:]]${name}[[:blank:]]" MAINTAINERS ; then
  442. echo ""
  443. return ;
  444. fi
  445. local line=`tac MAINTAINERS | grep -ni "[[:blank:]]${name}[[:blank:]]" | cut -d : -f 1`
  446. local mail=`tac MAINTAINERS | tail -n +${line} | \
  447. sed -n ":start /.*@.*/ { b mail } ; n ; b start ; :mail /.*@.*/ { p ; n ; b mail } ; q" | \
  448. sed "s/^.*<//;s/>.*$//"`
  449. echo "$mail"
  450. }
  451. list_target() {
  452. if [ "$PRINT_MAINTS" != 'y' ] ; then
  453. echo "$1"
  454. return
  455. fi
  456. echo -n "$1:"
  457. local loc=`get_target_location $1`
  458. if [ -z "${loc}" ] ; then echo "ERROR" ; return ; fi
  459. local maintainers_result=`get_target_maintainers ${loc} | tr " " "\n"`
  460. if [ "$MAINTAINERS_ONLY" != 'y' ] ; then
  461. local dir=`echo ${loc} | cut -d ":" -f 2`
  462. local cfg=`echo ${loc} | cut -d ":" -f 1`
  463. local git_result=`git log --format=%aE board/${dir} \
  464. include/configs/${cfg}.h | grep "@"`
  465. local git_result_recent=`echo ${git_result} | tr " " "\n" | \
  466. head -n 3`
  467. local git_result_top=`echo ${git_result} | tr " " "\n" | \
  468. sort | uniq -c | sort -nr | head -n 3 | \
  469. sed "s/^ \+[0-9]\+ \+//"`
  470. echo -e "$git_result_recent\n$git_result_top\n$maintainers_result" | \
  471. sort -u | tr "\n" " " | sed "s/ $//" ;
  472. else
  473. echo -e "$maintainers_result" | sort -u | tr "\n" " " | \
  474. sed "s/ $//" ;
  475. fi
  476. echo ""
  477. }
  478. # Each finished build will have a file called ${donep}${n},
  479. # where n is the index of the build. Each build
  480. # we've already noted as finished will have ${skipp}${n}.
  481. # The code managing the build process will use this information
  482. # to ensure that only BUILD_NBUILDS builds are in flight at once
  483. donep="${LOG_DIR}/._done_"
  484. skipp="${LOG_DIR}/._skip_"
  485. build_target() {
  486. target=$1
  487. build_idx=$2
  488. if [ "$ONLY_LIST" == 'y' ] ; then
  489. list_target ${target}
  490. return
  491. fi
  492. if [ $BUILD_MANY == 1 ] ; then
  493. output_dir="${OUTPUT_PREFIX}/${target}"
  494. mkdir -p "${output_dir}"
  495. else
  496. output_dir="${OUTPUT_PREFIX}"
  497. fi
  498. export BUILD_DIR="${output_dir}"
  499. ${MAKE} distclean >/dev/null
  500. ${MAKE} -s ${target}_config
  501. ${MAKE} ${JOBS} all \
  502. >${LOG_DIR}/$target.MAKELOG 2> ${LOG_DIR}/$target.ERR
  503. # Check for 'make' errors
  504. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  505. RC=1
  506. fi
  507. if [ $BUILD_MANY == 1 ] ; then
  508. ${MAKE} tidy
  509. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  510. cp ${LOG_DIR}/${target}.ERR ${OUTPUT_PREFIX}/ERR/${target}
  511. else
  512. rm ${LOG_DIR}/${target}.ERR
  513. fi
  514. else
  515. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  516. if grep -iw error ${LOG_DIR}/${target}.ERR ; then
  517. : $(( ERR_CNT += 1 ))
  518. ERR_LIST="${ERR_LIST} $target"
  519. else
  520. : $(( WRN_CNT += 1 ))
  521. WRN_LIST="${WRN_LIST} $target"
  522. fi
  523. else
  524. rm ${LOG_DIR}/${target}.ERR
  525. fi
  526. fi
  527. OBJS=${output_dir}/u-boot
  528. if [ -e ${output_dir}/spl/u-boot-spl ]; then
  529. OBJS="${OBJS} ${output_dir}/spl/u-boot-spl"
  530. fi
  531. ${CROSS_COMPILE}size ${OBJS} | tee -a ${LOG_DIR}/$target.MAKELOG
  532. [ -e "${LOG_DIR}/${target}.ERR" ] && cat "${LOG_DIR}/${target}.ERR"
  533. touch "${donep}${build_idx}"
  534. }
  535. manage_builds() {
  536. search_idx=${OLDEST_IDX}
  537. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  538. while true; do
  539. if [ -e "${donep}${search_idx}" ] ; then
  540. : $(( CURRENT_CNT-- ))
  541. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  542. : $(( OLDEST_IDX++ ))
  543. # Only want to count it once
  544. rm -f "${donep}${search_idx}"
  545. touch "${skipp}${search_idx}"
  546. elif [ -e "${skipp}${search_idx}" ] ; then
  547. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  548. : $(( OLDEST_IDX++ ))
  549. fi
  550. : $(( search_idx++ ))
  551. if [ ${search_idx} -gt ${TOTAL_CNT} ] ; then
  552. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  553. search_idx=${OLDEST_IDX}
  554. sleep 1
  555. else
  556. break
  557. fi
  558. fi
  559. done
  560. }
  561. build_targets() {
  562. for t in "$@" ; do
  563. # If a LIST_xxx var exists, use it. But avoid variable
  564. # expansion in the eval when a board name contains certain
  565. # characters that the shell interprets.
  566. case ${t} in
  567. *[-+=]*) list= ;;
  568. *) list=$(eval echo '${LIST_'$t'}') ;;
  569. esac
  570. if [ -n "${list}" ] ; then
  571. build_targets ${list}
  572. else
  573. : $((TOTAL_CNT += 1))
  574. : $((CURRENT_CNT += 1))
  575. rm -f "${donep}${TOTAL_CNT}"
  576. rm -f "${skipp}${TOTAL_CNT}"
  577. if [ $BUILD_MANY == 1 ] ; then
  578. build_target ${t} ${TOTAL_CNT} &
  579. else
  580. build_target ${t} ${TOTAL_CNT}
  581. fi
  582. fi
  583. # We maintain a running count of all the builds we have done.
  584. # Each finished build will have a file called ${donep}${n},
  585. # where n is the index of the build. Each build
  586. # we've already noted as finished will have ${skipp}${n}.
  587. # We track the current index via TOTAL_CNT, and the oldest
  588. # index. When we exceed the maximum number of parallel builds,
  589. # We look from oldest to current for builds that have completed,
  590. # and update the current count and oldest index as appropriate.
  591. # If we've gone through the entire list, wait a second, and
  592. # reprocess the entire list until we find a build that has
  593. # completed
  594. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  595. manage_builds
  596. fi
  597. done
  598. }
  599. #-----------------------------------------------------------------------
  600. kill_children() {
  601. kill -- "-$1"
  602. exit
  603. }
  604. print_stats() {
  605. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  606. rm -f ${donep}* ${skipp}*
  607. if [ $BUILD_MANY == 1 ] && [ -e "${OUTPUT_PREFIX}/ERR" ] ; then
  608. ERR_LIST=`grep -iwl error ${OUTPUT_PREFIX}/ERR/*`
  609. ERR_LIST=`for f in $ERR_LIST ; do echo -n " $(basename $f)" ; done`
  610. ERR_CNT=`echo $ERR_LIST | wc -w | awk '{print $1}'`
  611. WRN_LIST=`grep -iwL error ${OUTPUT_PREFIX}/ERR/*`
  612. WRN_LIST=`for f in $WRN_LIST ; do echo -n " $(basename $f)" ; done`
  613. WRN_CNT=`echo $WRN_LIST | wc -w | awk '{print $1}'`
  614. fi
  615. echo ""
  616. echo "--------------------- SUMMARY ----------------------------"
  617. echo "Boards compiled: ${TOTAL_CNT}"
  618. if [ ${ERR_CNT} -gt 0 ] ; then
  619. echo "Boards with errors: ${ERR_CNT} (${ERR_LIST} )"
  620. fi
  621. if [ ${WRN_CNT} -gt 0 ] ; then
  622. echo "Boards with warnings but no errors: ${WRN_CNT} (${WRN_LIST} )"
  623. fi
  624. echo "----------------------------------------------------------"
  625. if [ $BUILD_MANY == 1 ] ; then
  626. kill_children $$ &
  627. fi
  628. exit $RC
  629. }
  630. #-----------------------------------------------------------------------
  631. # Build target groups selected by options, plus any command line args
  632. set -- ${SELECTED} "$@"
  633. # run PowerPC by default
  634. [ $# = 0 ] && set -- powerpc
  635. build_targets "$@"
  636. wait