MAKEALL 21 KB

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