MAKEALL 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  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\" || \$3 ~ /$2:/)"
  78. else
  79. opt_c="(\$3 == \"$2\" || \$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. FS="[ \t]+"
  184. [ -n "$3" ] && FS="$3"
  185. awk \
  186. -v field="$1" \
  187. -v select="$2" \
  188. -F "$FS" \
  189. '($1 !~ /^#/ && $field == select) { print $1 }' \
  190. boards.cfg
  191. }
  192. boards_by_arch() { boards_by_field 2 "$@" ; }
  193. boards_by_cpu() { boards_by_field 3 "$@" "[: \t]+" ; }
  194. boards_by_soc() { boards_by_field 6 "$@" ; }
  195. #########################################################################
  196. ## MPC5xx Systems
  197. #########################################################################
  198. LIST_5xx="$(boards_by_cpu mpc5xx)"
  199. #########################################################################
  200. ## MPC5xxx Systems
  201. #########################################################################
  202. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  203. #########################################################################
  204. ## MPC512x Systems
  205. #########################################################################
  206. LIST_512x="$(boards_by_cpu mpc512x)"
  207. #########################################################################
  208. ## MPC8xx Systems
  209. #########################################################################
  210. LIST_8xx="$(boards_by_cpu mpc8xx)"
  211. #########################################################################
  212. ## PPC4xx Systems
  213. #########################################################################
  214. LIST_4xx="$(boards_by_cpu ppc4xx)"
  215. #########################################################################
  216. ## MPC8220 Systems
  217. #########################################################################
  218. LIST_8220="$(boards_by_cpu mpc8220)"
  219. #########################################################################
  220. ## MPC824x Systems
  221. #########################################################################
  222. LIST_824x="$(boards_by_cpu mpc824x)"
  223. #########################################################################
  224. ## MPC8260 Systems (includes 8250, 8255 etc.)
  225. #########################################################################
  226. LIST_8260="$(boards_by_cpu mpc8260)"
  227. #########################################################################
  228. ## MPC83xx Systems (includes 8349, etc.)
  229. #########################################################################
  230. LIST_83xx="$(boards_by_cpu mpc83xx)"
  231. #########################################################################
  232. ## MPC85xx Systems (includes 8540, 8560 etc.)
  233. #########################################################################
  234. LIST_85xx="$(boards_by_cpu mpc85xx)"
  235. #########################################################################
  236. ## MPC86xx Systems
  237. #########################################################################
  238. LIST_86xx="$(boards_by_cpu mpc86xx)"
  239. #########################################################################
  240. ## 74xx/7xx Systems
  241. #########################################################################
  242. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  243. #########################################################################
  244. ## PowerPC groups
  245. #########################################################################
  246. LIST_TSEC=" \
  247. ${LIST_83xx} \
  248. ${LIST_85xx} \
  249. ${LIST_86xx} \
  250. "
  251. LIST_powerpc=" \
  252. ${LIST_5xx} \
  253. ${LIST_512x} \
  254. ${LIST_5xxx} \
  255. ${LIST_8xx} \
  256. ${LIST_8220} \
  257. ${LIST_824x} \
  258. ${LIST_8260} \
  259. ${LIST_83xx} \
  260. ${LIST_85xx} \
  261. ${LIST_86xx} \
  262. ${LIST_4xx} \
  263. ${LIST_74xx_7xx}\
  264. "
  265. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  266. # still using "ppc" instead of "powerpc"
  267. LIST_ppc=" \
  268. ${LIST_powerpc} \
  269. "
  270. #########################################################################
  271. ## StrongARM Systems
  272. #########################################################################
  273. LIST_SA="$(boards_by_cpu sa1100)"
  274. #########################################################################
  275. ## ARM9 Systems
  276. #########################################################################
  277. LIST_ARM9="$(boards_by_cpu arm920t) \
  278. $(boards_by_cpu arm926ejs) \
  279. $(boards_by_cpu arm925t) \
  280. "
  281. #########################################################################
  282. ## ARM11 Systems
  283. #########################################################################
  284. LIST_ARM11="$(boards_by_cpu arm1136)"
  285. #########################################################################
  286. ## ARMV7 Systems
  287. #########################################################################
  288. LIST_ARMV7="$(boards_by_cpu armv7)"
  289. #########################################################################
  290. ## AT91 Systems
  291. #########################################################################
  292. LIST_at91="$(boards_by_soc at91)"
  293. #########################################################################
  294. ## Xscale Systems
  295. #########################################################################
  296. LIST_pxa="$(boards_by_cpu pxa)"
  297. LIST_ixp="$(boards_by_cpu ixp)"
  298. #########################################################################
  299. ## ARM groups
  300. #########################################################################
  301. LIST_arm=" \
  302. ${LIST_SA} \
  303. ${LIST_ARM9} \
  304. ${LIST_ARM10} \
  305. ${LIST_ARM11} \
  306. ${LIST_ARMV7} \
  307. ${LIST_at91} \
  308. ${LIST_pxa} \
  309. ${LIST_ixp} \
  310. "
  311. #########################################################################
  312. ## MIPS Systems (default = big endian)
  313. #########################################################################
  314. LIST_mips4kc=" \
  315. incaip \
  316. qemu_mips \
  317. vct_platinum \
  318. vct_platinum_small \
  319. vct_platinum_onenand \
  320. vct_platinum_onenand_small \
  321. vct_platinumavc \
  322. vct_platinumavc_small \
  323. vct_platinumavc_onenand \
  324. vct_platinumavc_onenand_small \
  325. vct_premium \
  326. vct_premium_small \
  327. vct_premium_onenand \
  328. vct_premium_onenand_small \
  329. "
  330. LIST_au1xx0=" \
  331. dbau1000 \
  332. dbau1100 \
  333. dbau1500 \
  334. dbau1550 \
  335. gth2 \
  336. "
  337. LIST_mips=" \
  338. ${LIST_mips4kc} \
  339. ${LIST_mips5kc} \
  340. ${LIST_au1xx0} \
  341. "
  342. #########################################################################
  343. ## MIPS Systems (little endian)
  344. #########################################################################
  345. LIST_xburst_el=" \
  346. qi_lb60 \
  347. "
  348. LIST_au1xx0_el=" \
  349. dbau1550_el \
  350. pb1000 \
  351. "
  352. LIST_mips_el=" \
  353. ${LIST_xburst_el} \
  354. ${LIST_au1xx0_el} \
  355. "
  356. #########################################################################
  357. ## OpenRISC Systems
  358. #########################################################################
  359. LIST_openrisc="$(boards_by_arch openrisc)"
  360. #########################################################################
  361. ## x86 Systems
  362. #########################################################################
  363. LIST_x86="$(boards_by_arch x86)"
  364. #########################################################################
  365. ## Nios-II Systems
  366. #########################################################################
  367. LIST_nios2="$(boards_by_arch nios2)"
  368. #########################################################################
  369. ## MicroBlaze Systems
  370. #########################################################################
  371. LIST_microblaze="$(boards_by_arch microblaze)"
  372. #########################################################################
  373. ## ColdFire Systems
  374. #########################################################################
  375. LIST_m68k="$(boards_by_arch m68k)
  376. EB+MCF-EV123 \
  377. EB+MCF-EV123_internal \
  378. M52277EVB \
  379. M5235EVB \
  380. M54451EVB \
  381. M54455EVB \
  382. "
  383. LIST_coldfire=${LIST_m68k}
  384. #########################################################################
  385. ## AVR32 Systems
  386. #########################################################################
  387. LIST_avr32="$(boards_by_arch avr32)"
  388. #########################################################################
  389. ## Blackfin Systems
  390. #########################################################################
  391. LIST_blackfin="$(boards_by_arch blackfin)"
  392. #########################################################################
  393. ## SH Systems
  394. #########################################################################
  395. LIST_sh2="$(boards_by_cpu sh2)"
  396. LIST_sh3="$(boards_by_cpu sh3)"
  397. LIST_sh4="$(boards_by_cpu sh4)"
  398. LIST_sh="$(boards_by_arch sh)"
  399. #########################################################################
  400. ## SPARC Systems
  401. #########################################################################
  402. LIST_sparc="$(boards_by_arch sparc)"
  403. #########################################################################
  404. ## NDS32 Systems
  405. #########################################################################
  406. LIST_nds32="$(boards_by_arch nds32)"
  407. #-----------------------------------------------------------------------
  408. get_target_location() {
  409. local target=$1
  410. local BOARD_NAME=""
  411. local CONFIG_NAME=""
  412. local board=""
  413. local vendor=""
  414. # Automatic mode
  415. local line=`egrep -i "^[[:space:]]*${target}[[:space:]]" boards.cfg`
  416. if [ -z "${line}" ] ; then echo "" ; return ; fi
  417. set ${line}
  418. # add default board name if needed
  419. [ $# = 3 ] && set ${line} ${1}
  420. CONFIG_NAME="${1%_config}"
  421. [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
  422. if [ "$4" = "-" ] ; then
  423. board=${BOARD_NAME}
  424. else
  425. board="$4"
  426. fi
  427. [ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5"
  428. [ $# -gt 6 ] && [ "$7" != "-" ] && {
  429. tmp="${7%:*}"
  430. if [ "$tmp" ] ; then
  431. CONFIG_NAME="$tmp"
  432. fi
  433. }
  434. # Assign board directory to BOARDIR variable
  435. if [ -z "${vendor}" ] ; then
  436. BOARDDIR=${board}
  437. else
  438. BOARDDIR=${vendor}/${board}
  439. fi
  440. echo "${CONFIG_NAME}:${BOARDDIR}"
  441. }
  442. get_target_maintainers() {
  443. local name=`echo $1 | cut -d : -f 1`
  444. if ! grep -qsi "[[:blank:]]${name}[[:blank:]]" MAINTAINERS ; then
  445. echo ""
  446. return ;
  447. fi
  448. local line=`tac MAINTAINERS | grep -ni "[[:blank:]]${name}[[:blank:]]" | cut -d : -f 1`
  449. local mail=`tac MAINTAINERS | tail -n +${line} | \
  450. sed -n ":start /.*@.*/ { b mail } ; n ; b start ; :mail /.*@.*/ { p ; n ; b mail } ; q" | \
  451. sed "s/^.*<//;s/>.*$//"`
  452. echo "$mail"
  453. }
  454. list_target() {
  455. if [ "$PRINT_MAINTS" != 'y' ] ; then
  456. echo "$1"
  457. return
  458. fi
  459. echo -n "$1:"
  460. local loc=`get_target_location $1`
  461. if [ -z "${loc}" ] ; then echo "ERROR" ; return ; fi
  462. local maintainers_result=`get_target_maintainers ${loc} | tr " " "\n"`
  463. if [ "$MAINTAINERS_ONLY" != 'y' ] ; then
  464. local dir=`echo ${loc} | cut -d ":" -f 2`
  465. local cfg=`echo ${loc} | cut -d ":" -f 1`
  466. local git_result=`git log --format=%aE board/${dir} \
  467. include/configs/${cfg}.h | grep "@"`
  468. local git_result_recent=`echo ${git_result} | tr " " "\n" | \
  469. head -n 3`
  470. local git_result_top=`echo ${git_result} | tr " " "\n" | \
  471. sort | uniq -c | sort -nr | head -n 3 | \
  472. sed "s/^ \+[0-9]\+ \+//"`
  473. echo -e "$git_result_recent\n$git_result_top\n$maintainers_result" | \
  474. sort -u | tr "\n" " " | sed "s/ $//" ;
  475. else
  476. echo -e "$maintainers_result" | sort -u | tr "\n" " " | \
  477. sed "s/ $//" ;
  478. fi
  479. echo ""
  480. }
  481. # Each finished build will have a file called ${donep}${n},
  482. # where n is the index of the build. Each build
  483. # we've already noted as finished will have ${skipp}${n}.
  484. # The code managing the build process will use this information
  485. # to ensure that only BUILD_NBUILDS builds are in flight at once
  486. donep="${LOG_DIR}/._done_"
  487. skipp="${LOG_DIR}/._skip_"
  488. build_target() {
  489. target=$1
  490. build_idx=$2
  491. if [ "$ONLY_LIST" == 'y' ] ; then
  492. list_target ${target}
  493. return
  494. fi
  495. if [ $BUILD_MANY == 1 ] ; then
  496. output_dir="${OUTPUT_PREFIX}/${target}"
  497. mkdir -p "${output_dir}"
  498. else
  499. output_dir="${OUTPUT_PREFIX}"
  500. fi
  501. export BUILD_DIR="${output_dir}"
  502. ${MAKE} distclean >/dev/null
  503. ${MAKE} -s ${target}_config
  504. ${MAKE} ${JOBS} all \
  505. >${LOG_DIR}/$target.MAKELOG 2> ${LOG_DIR}/$target.ERR
  506. # Check for 'make' errors
  507. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  508. RC=1
  509. fi
  510. if [ $BUILD_MANY == 1 ] ; then
  511. ${MAKE} tidy
  512. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  513. cp ${LOG_DIR}/${target}.ERR ${OUTPUT_PREFIX}/ERR/${target}
  514. else
  515. rm ${LOG_DIR}/${target}.ERR
  516. fi
  517. else
  518. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  519. if grep -iw error ${LOG_DIR}/${target}.ERR ; then
  520. : $(( ERR_CNT += 1 ))
  521. ERR_LIST="${ERR_LIST} $target"
  522. else
  523. : $(( WRN_CNT += 1 ))
  524. WRN_LIST="${WRN_LIST} $target"
  525. fi
  526. else
  527. rm ${LOG_DIR}/${target}.ERR
  528. fi
  529. fi
  530. OBJS=${output_dir}/u-boot
  531. if [ -e ${output_dir}/spl/u-boot-spl ]; then
  532. OBJS="${OBJS} ${output_dir}/spl/u-boot-spl"
  533. fi
  534. ${CROSS_COMPILE}size ${OBJS} | tee -a ${LOG_DIR}/$target.MAKELOG
  535. [ -e "${LOG_DIR}/${target}.ERR" ] && cat "${LOG_DIR}/${target}.ERR"
  536. touch "${donep}${build_idx}"
  537. }
  538. manage_builds() {
  539. search_idx=${OLDEST_IDX}
  540. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  541. while true; do
  542. if [ -e "${donep}${search_idx}" ] ; then
  543. : $(( CURRENT_CNT-- ))
  544. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  545. : $(( OLDEST_IDX++ ))
  546. # Only want to count it once
  547. rm -f "${donep}${search_idx}"
  548. touch "${skipp}${search_idx}"
  549. elif [ -e "${skipp}${search_idx}" ] ; then
  550. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  551. : $(( OLDEST_IDX++ ))
  552. fi
  553. : $(( search_idx++ ))
  554. if [ ${search_idx} -gt ${TOTAL_CNT} ] ; then
  555. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  556. search_idx=${OLDEST_IDX}
  557. sleep 1
  558. else
  559. break
  560. fi
  561. fi
  562. done
  563. }
  564. build_targets() {
  565. for t in "$@" ; do
  566. # If a LIST_xxx var exists, use it. But avoid variable
  567. # expansion in the eval when a board name contains certain
  568. # characters that the shell interprets.
  569. case ${t} in
  570. *[-+=]*) list= ;;
  571. *) list=$(eval echo '${LIST_'$t'}') ;;
  572. esac
  573. if [ -n "${list}" ] ; then
  574. build_targets ${list}
  575. else
  576. : $((TOTAL_CNT += 1))
  577. : $((CURRENT_CNT += 1))
  578. rm -f "${donep}${TOTAL_CNT}"
  579. rm -f "${skipp}${TOTAL_CNT}"
  580. if [ $BUILD_MANY == 1 ] ; then
  581. build_target ${t} ${TOTAL_CNT} &
  582. else
  583. build_target ${t} ${TOTAL_CNT}
  584. fi
  585. fi
  586. # We maintain a running count of all the builds we have done.
  587. # Each finished build will have a file called ${donep}${n},
  588. # where n is the index of the build. Each build
  589. # we've already noted as finished will have ${skipp}${n}.
  590. # We track the current index via TOTAL_CNT, and the oldest
  591. # index. When we exceed the maximum number of parallel builds,
  592. # We look from oldest to current for builds that have completed,
  593. # and update the current count and oldest index as appropriate.
  594. # If we've gone through the entire list, wait a second, and
  595. # reprocess the entire list until we find a build that has
  596. # completed
  597. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  598. manage_builds
  599. fi
  600. done
  601. }
  602. #-----------------------------------------------------------------------
  603. kill_children() {
  604. kill -- "-$1"
  605. exit
  606. }
  607. print_stats() {
  608. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  609. rm -f ${donep}* ${skipp}*
  610. if [ $BUILD_MANY == 1 ] && [ -e "${OUTPUT_PREFIX}/ERR" ] ; then
  611. ERR_LIST=`grep -riwl error ${OUTPUT_PREFIX}/ERR/`
  612. ERR_LIST=`for f in $ERR_LIST ; do echo -n " $(basename $f)" ; done`
  613. ERR_CNT=`echo $ERR_LIST | wc -w | awk '{print $1}'`
  614. WRN_LIST=`grep -riwL error ${OUTPUT_PREFIX}/ERR/`
  615. WRN_LIST=`for f in $WRN_LIST ; do echo -n " $(basename $f)" ; done`
  616. WRN_CNT=`echo $WRN_LIST | wc -w | awk '{print $1}'`
  617. fi
  618. echo ""
  619. echo "--------------------- SUMMARY ----------------------------"
  620. echo "Boards compiled: ${TOTAL_CNT}"
  621. if [ ${ERR_CNT} -gt 0 ] ; then
  622. echo "Boards with errors: ${ERR_CNT} (${ERR_LIST} )"
  623. fi
  624. if [ ${WRN_CNT} -gt 0 ] ; then
  625. echo "Boards with warnings but no errors: ${WRN_CNT} (${WRN_LIST} )"
  626. fi
  627. echo "----------------------------------------------------------"
  628. if [ $BUILD_MANY == 1 ] ; then
  629. kill_children $$ &
  630. fi
  631. exit $RC
  632. }
  633. #-----------------------------------------------------------------------
  634. # Build target groups selected by options, plus any command line args
  635. set -- ${SELECTED} "$@"
  636. # run PowerPC by default
  637. [ $# = 0 ] && set -- powerpc
  638. build_targets "$@"
  639. wait