lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Tool mainly for U-Boot Quality Assurance: build one or more board |
| 3 | # configurations with minimal verbosity, showing only warnings and |
| 4 | # errors. |
| 5 | |
| 6 | usage() |
| 7 | { |
| 8 | # if exiting with 0, write to stdout, else write to stderr |
| 9 | local ret=${1:-0} |
| 10 | [ "${ret}" -eq 1 ] && exec 1>&2 |
| 11 | cat <<-EOF |
| 12 | Usage: MAKEALL [options] [--] [boards-to-build] |
| 13 | |
| 14 | Options: |
| 15 | -a ARCH, --arch ARCH Build all boards with arch ARCH |
| 16 | -c CPU, --cpu CPU Build all boards with cpu CPU |
| 17 | -v VENDOR, --vendor VENDOR Build all boards with vendor VENDOR |
| 18 | -s SOC, --soc SOC Build all boards with soc SOC |
| 19 | -h, --help This help output |
| 20 | |
| 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 | |
| 27 | If no boards are specified, then the default is "powerpc". |
| 28 | |
| 29 | Environment variables: |
| 30 | BUILD_NCPUS number of parallel make jobs (default: auto) |
| 31 | CROSS_COMPILE cross-compiler toolchain prefix (default: "") |
| 32 | MAKEALL_LOGDIR output all logs to here (default: ./LOG/) |
| 33 | BUILD_DIR output build directory (default: ./) |
| 34 | |
| 35 | Examples: |
| 36 | - build all Power Architecture boards: |
| 37 | MAKEALL -a powerpc |
| 38 | MAKEALL --arch powerpc |
| 39 | MAKEALL powerpc |
| 40 | - build all PowerPC boards manufactured by vendor "esd": |
| 41 | MAKEALL -a powerpc -v esd |
| 42 | - build all PowerPC boards manufactured either by "keymile" or "siemens": |
| 43 | MAKEALL -a powerpc -v keymile -v siemens |
| 44 | - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards: |
| 45 | MAKEALL -c mpc83xx -v freescale 4xx |
| 46 | EOF |
| 47 | exit ${ret} |
| 48 | } |
| 49 | |
| 50 | SHORT_OPTS="ha:c:v:s:" |
| 51 | LONG_OPTS="help,arch:,cpu:,vendor:,soc:" |
| 52 | |
| 53 | # Option processing based on util-linux-2.13/getopt-parse.bash |
| 54 | |
| 55 | # Note that we use `"$@"' to let each command-line parameter expand to a |
| 56 | # separate word. The quotes around `$@' are essential! |
| 57 | # We need TEMP as the `eval set --' would nuke the return value of |
| 58 | # getopt. |
| 59 | TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \ |
| 60 | -n 'MAKEALL' -- "$@"` |
| 61 | |
| 62 | [ $? != 0 ] && usage 1 |
| 63 | |
| 64 | # Note the quotes around `$TEMP': they are essential! |
| 65 | eval set -- "$TEMP" |
| 66 | |
| 67 | SELECTED='' |
| 68 | |
| 69 | while true ; do |
| 70 | case "$1" in |
| 71 | -a|--arch) |
| 72 | # echo "Option ARCH: argument \`$2'" |
| 73 | if [ "$opt_a" ] ; then |
| 74 | opt_a="${opt_a%)} || \$2 == \"$2\")" |
| 75 | else |
| 76 | opt_a="(\$2 == \"$2\")" |
| 77 | fi |
| 78 | SELECTED='y' |
| 79 | shift 2 ;; |
| 80 | -c|--cpu) |
| 81 | # echo "Option CPU: argument \`$2'" |
| 82 | if [ "$opt_c" ] ; then |
| 83 | opt_c="${opt_c%)} || \$3 == \"$2\")" |
| 84 | else |
| 85 | opt_c="(\$3 == \"$2\")" |
| 86 | fi |
| 87 | SELECTED='y' |
| 88 | shift 2 ;; |
| 89 | -s|--soc) |
| 90 | # echo "Option SoC: argument \`$2'" |
| 91 | if [ "$opt_s" ] ; then |
| 92 | opt_s="${opt_s%)} || \$6 == \"$2\")" |
| 93 | else |
| 94 | opt_s="(\$6 == \"$2\")" |
| 95 | fi |
| 96 | SELECTED='y' |
| 97 | shift 2 ;; |
| 98 | -v|--vendor) |
| 99 | # echo "Option VENDOR: argument \`$2'" |
| 100 | if [ "$opt_v" ] ; then |
| 101 | opt_v="${opt_v%)} || \$5 == \"$2\")" |
| 102 | else |
| 103 | opt_v="(\$5 == \"$2\")" |
| 104 | fi |
| 105 | SELECTED='y' |
| 106 | shift 2 ;; |
| 107 | -h|--help) |
| 108 | usage ;; |
| 109 | --) |
| 110 | shift ; break ;; |
| 111 | *) |
| 112 | echo "Internal error!" >&2 ; exit 1 ;; |
| 113 | esac |
| 114 | done |
| 115 | # echo "Remaining arguments:" |
| 116 | # for arg do echo '--> '"\`$arg'" ; done |
| 117 | |
| 118 | FILTER="\$1 !~ /^#/" |
| 119 | [ "$opt_a" ] && FILTER="${FILTER} && $opt_a" |
| 120 | [ "$opt_c" ] && FILTER="${FILTER} && $opt_c" |
| 121 | [ "$opt_s" ] && FILTER="${FILTER} && $opt_s" |
| 122 | [ "$opt_v" ] && FILTER="${FILTER} && $opt_v" |
| 123 | |
| 124 | if [ "$SELECTED" ] ; then |
| 125 | SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg) |
| 126 | |
| 127 | # Make sure some boards from boards.cfg are actually found |
| 128 | if [ -z "$SELECTED" ] ; then |
| 129 | echo "Error: No boards selected, invalid arguments" |
| 130 | exit 1 |
| 131 | fi |
| 132 | fi |
| 133 | |
| 134 | ######################################################################### |
| 135 | |
| 136 | # Print statistics when we exit |
| 137 | trap exit 1 2 3 15 |
| 138 | trap print_stats 0 |
| 139 | |
| 140 | # Determine number of CPU cores if no default was set |
| 141 | : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"} |
| 142 | |
| 143 | if [ "$BUILD_NCPUS" -gt 1 ] |
| 144 | then |
| 145 | JOBS="-j $((BUILD_NCPUS + 1))" |
| 146 | else |
| 147 | JOBS="" |
| 148 | fi |
| 149 | |
| 150 | |
| 151 | if [ "${CROSS_COMPILE}" ] ; then |
| 152 | MAKE="make CROSS_COMPILE=${CROSS_COMPILE}" |
| 153 | else |
| 154 | MAKE=make |
| 155 | fi |
| 156 | |
| 157 | if [ "${MAKEALL_LOGDIR}" ] ; then |
| 158 | LOG_DIR=${MAKEALL_LOGDIR} |
| 159 | else |
| 160 | LOG_DIR="LOG" |
| 161 | fi |
| 162 | |
| 163 | if [ ! "${BUILD_DIR}" ] ; then |
| 164 | BUILD_DIR="." |
| 165 | fi |
| 166 | |
| 167 | [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} || exit 1 |
| 168 | |
| 169 | LIST="" |
| 170 | |
| 171 | # Keep track of the number of builds and errors |
| 172 | ERR_CNT=0 |
| 173 | ERR_LIST="" |
| 174 | TOTAL_CNT=0 |
| 175 | RC=0 |
| 176 | |
| 177 | # Helper funcs for parsing boards.cfg |
| 178 | boards_by_field() |
| 179 | { |
| 180 | awk \ |
| 181 | -v field="$1" \ |
| 182 | -v select="$2" \ |
| 183 | '($1 !~ /^#/ && $field == select) { print $1 }' \ |
| 184 | boards.cfg |
| 185 | } |
| 186 | boards_by_arch() { boards_by_field 2 "$@" ; } |
| 187 | boards_by_cpu() { boards_by_field 3 "$@" ; } |
| 188 | boards_by_soc() { boards_by_field 6 "$@" ; } |
| 189 | |
| 190 | ######################################################################### |
| 191 | ## MPC5xx Systems |
| 192 | ######################################################################### |
| 193 | |
| 194 | LIST_5xx="$(boards_by_cpu mpc5xx)" |
| 195 | |
| 196 | ######################################################################### |
| 197 | ## MPC5xxx Systems |
| 198 | ######################################################################### |
| 199 | |
| 200 | LIST_5xxx="$(boards_by_cpu mpc5xxx)" |
| 201 | |
| 202 | ######################################################################### |
| 203 | ## MPC512x Systems |
| 204 | ######################################################################### |
| 205 | |
| 206 | LIST_512x="$(boards_by_cpu mpc512x)" |
| 207 | |
| 208 | ######################################################################### |
| 209 | ## MPC8xx Systems |
| 210 | ######################################################################### |
| 211 | |
| 212 | LIST_8xx="$(boards_by_cpu mpc8xx)" |
| 213 | |
| 214 | ######################################################################### |
| 215 | ## PPC4xx Systems |
| 216 | ######################################################################### |
| 217 | |
| 218 | LIST_4xx="$(boards_by_cpu ppc4xx)" |
| 219 | |
| 220 | ######################################################################### |
| 221 | ## MPC8220 Systems |
| 222 | ######################################################################### |
| 223 | |
| 224 | LIST_8220="$(boards_by_cpu mpc8220)" |
| 225 | |
| 226 | ######################################################################### |
| 227 | ## MPC824x Systems |
| 228 | ######################################################################### |
| 229 | |
| 230 | LIST_824x="$(boards_by_cpu mpc824x)" |
| 231 | |
| 232 | ######################################################################### |
| 233 | ## MPC8260 Systems (includes 8250, 8255 etc.) |
| 234 | ######################################################################### |
| 235 | |
| 236 | LIST_8260="$(boards_by_cpu mpc8260)" |
| 237 | |
| 238 | ######################################################################### |
| 239 | ## MPC83xx Systems (includes 8349, etc.) |
| 240 | ######################################################################### |
| 241 | |
| 242 | LIST_83xx="$(boards_by_cpu mpc83xx)" |
| 243 | |
| 244 | ######################################################################### |
| 245 | ## MPC85xx Systems (includes 8540, 8560 etc.) |
| 246 | ######################################################################### |
| 247 | |
| 248 | LIST_85xx="$(boards_by_cpu mpc85xx)" |
| 249 | |
| 250 | ######################################################################### |
| 251 | ## MPC86xx Systems |
| 252 | ######################################################################### |
| 253 | |
| 254 | LIST_86xx="$(boards_by_cpu mpc86xx)" |
| 255 | |
| 256 | ######################################################################### |
| 257 | ## 74xx/7xx Systems |
| 258 | ######################################################################### |
| 259 | |
| 260 | LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)" |
| 261 | |
| 262 | ######################################################################### |
| 263 | ## PowerPC groups |
| 264 | ######################################################################### |
| 265 | |
| 266 | LIST_TSEC=" \ |
| 267 | ${LIST_83xx} \ |
| 268 | ${LIST_85xx} \ |
| 269 | ${LIST_86xx} \ |
| 270 | " |
| 271 | |
| 272 | LIST_powerpc=" \ |
| 273 | ${LIST_5xx} \ |
| 274 | ${LIST_512x} \ |
| 275 | ${LIST_5xxx} \ |
| 276 | ${LIST_8xx} \ |
| 277 | ${LIST_8220} \ |
| 278 | ${LIST_824x} \ |
| 279 | ${LIST_8260} \ |
| 280 | ${LIST_83xx} \ |
| 281 | ${LIST_85xx} \ |
| 282 | ${LIST_86xx} \ |
| 283 | ${LIST_4xx} \ |
| 284 | ${LIST_74xx_7xx}\ |
| 285 | " |
| 286 | |
| 287 | # Alias "ppc" -> "powerpc" to not break compatibility with older scripts |
| 288 | # still using "ppc" instead of "powerpc" |
| 289 | LIST_ppc=" \ |
| 290 | ${LIST_powerpc} \ |
| 291 | " |
| 292 | |
| 293 | ######################################################################### |
| 294 | ## StrongARM Systems |
| 295 | ######################################################################### |
| 296 | |
| 297 | LIST_SA="$(boards_by_cpu sa1100)" |
| 298 | |
| 299 | ######################################################################### |
| 300 | ## ARM9 Systems |
| 301 | ######################################################################### |
| 302 | |
| 303 | LIST_ARM9="$(boards_by_cpu arm920t) \ |
| 304 | $(boards_by_cpu arm926ejs) \ |
| 305 | $(boards_by_cpu arm925t) \ |
| 306 | omap1610h2 \ |
| 307 | omap1610inn \ |
| 308 | omap730p2 \ |
| 309 | " |
| 310 | |
| 311 | ######################################################################### |
| 312 | ## ARM11 Systems |
| 313 | ######################################################################### |
| 314 | LIST_ARM11="$(boards_by_cpu arm1136) \ |
| 315 | apollon \ |
| 316 | imx31_phycore \ |
| 317 | imx31_phycore_eet \ |
| 318 | mx31pdk \ |
| 319 | mx31pdk_nand \ |
| 320 | smdk6400 \ |
| 321 | " |
| 322 | |
| 323 | ######################################################################### |
| 324 | ## ARMV7 Systems |
| 325 | ######################################################################### |
| 326 | |
| 327 | LIST_ARMV7="$(boards_by_cpu armv7)" |
| 328 | |
| 329 | ######################################################################### |
| 330 | ## AT91 Systems |
| 331 | ######################################################################### |
| 332 | |
| 333 | LIST_at91="$(boards_by_soc at91)" |
| 334 | |
| 335 | ######################################################################### |
| 336 | ## Xscale Systems |
| 337 | ######################################################################### |
| 338 | |
| 339 | LIST_pxa="$(boards_by_cpu pxa)" |
| 340 | |
| 341 | LIST_ixp="$(boards_by_cpu ixp) |
| 342 | pdnb3 \ |
| 343 | scpu \ |
| 344 | " |
| 345 | |
| 346 | ######################################################################### |
| 347 | ## ARM groups |
| 348 | ######################################################################### |
| 349 | |
| 350 | LIST_arm=" \ |
| 351 | ${LIST_SA} \ |
| 352 | ${LIST_ARM9} \ |
| 353 | ${LIST_ARM10} \ |
| 354 | ${LIST_ARM11} \ |
| 355 | ${LIST_ARMV7} \ |
| 356 | ${LIST_at91} \ |
| 357 | ${LIST_pxa} \ |
| 358 | ${LIST_ixp} \ |
| 359 | " |
| 360 | |
| 361 | ######################################################################### |
| 362 | ## MIPS Systems (default = big endian) |
| 363 | ######################################################################### |
| 364 | |
| 365 | LIST_mips4kc=" \ |
| 366 | incaip \ |
| 367 | qemu_mips \ |
| 368 | vct_platinum \ |
| 369 | vct_platinum_small \ |
| 370 | vct_platinum_onenand \ |
| 371 | vct_platinum_onenand_small \ |
| 372 | vct_platinumavc \ |
| 373 | vct_platinumavc_small \ |
| 374 | vct_platinumavc_onenand \ |
| 375 | vct_platinumavc_onenand_small \ |
| 376 | vct_premium \ |
| 377 | vct_premium_small \ |
| 378 | vct_premium_onenand \ |
| 379 | vct_premium_onenand_small \ |
| 380 | " |
| 381 | |
| 382 | LIST_mips5kc="" |
| 383 | |
| 384 | LIST_au1xx0=" \ |
| 385 | dbau1000 \ |
| 386 | dbau1100 \ |
| 387 | dbau1500 \ |
| 388 | dbau1550 \ |
| 389 | dbau1550_el \ |
| 390 | gth2 \ |
| 391 | " |
| 392 | |
| 393 | LIST_mips=" \ |
| 394 | ${LIST_mips4kc} \ |
| 395 | ${LIST_mips5kc} \ |
| 396 | ${LIST_au1xx0} \ |
| 397 | " |
| 398 | |
| 399 | ######################################################################### |
| 400 | ## MIPS Systems (little endian) |
| 401 | ######################################################################### |
| 402 | |
| 403 | LIST_mips4kc_el="" |
| 404 | |
| 405 | LIST_mips5kc_el="" |
| 406 | |
| 407 | LIST_au1xx0_el=" \ |
| 408 | dbau1550_el \ |
| 409 | pb1000 \ |
| 410 | " |
| 411 | |
| 412 | LIST_mips_el=" \ |
| 413 | ${LIST_mips4kc_el} \ |
| 414 | ${LIST_mips5kc_el} \ |
| 415 | ${LIST_au1xx0_el} \ |
| 416 | " |
| 417 | |
| 418 | ######################################################################### |
| 419 | ## x86 Systems |
| 420 | ######################################################################### |
| 421 | |
| 422 | LIST_x86="$(boards_by_arch x86)" |
| 423 | |
| 424 | ######################################################################### |
| 425 | ## Nios-II Systems |
| 426 | ######################################################################### |
| 427 | |
| 428 | LIST_nios2="$(boards_by_arch nios2)" |
| 429 | |
| 430 | ######################################################################### |
| 431 | ## MicroBlaze Systems |
| 432 | ######################################################################### |
| 433 | |
| 434 | LIST_microblaze="$(boards_by_arch microblaze)" |
| 435 | |
| 436 | ######################################################################### |
| 437 | ## ColdFire Systems |
| 438 | ######################################################################### |
| 439 | |
| 440 | LIST_coldfire="$(boards_by_arch m68k) |
| 441 | astro_mcf5373l \ |
| 442 | cobra5272 \ |
| 443 | EB+MCF-EV123 \ |
| 444 | EB+MCF-EV123_internal \ |
| 445 | M52277EVB \ |
| 446 | M5235EVB \ |
| 447 | M5329AFEE \ |
| 448 | M5373EVB \ |
| 449 | M54451EVB \ |
| 450 | M54455EVB \ |
| 451 | M5475AFE \ |
| 452 | M5485AFE \ |
| 453 | " |
| 454 | |
| 455 | ######################################################################### |
| 456 | ## AVR32 Systems |
| 457 | ######################################################################### |
| 458 | |
| 459 | LIST_avr32="$(boards_by_arch avr32)" |
| 460 | |
| 461 | ######################################################################### |
| 462 | ## Blackfin Systems |
| 463 | ######################################################################### |
| 464 | |
| 465 | LIST_blackfin="$(boards_by_arch blackfin)" |
| 466 | |
| 467 | ######################################################################### |
| 468 | ## SH Systems |
| 469 | ######################################################################### |
| 470 | |
| 471 | LIST_sh2="$(boards_by_cpu sh2)" |
| 472 | LIST_sh3="$(boards_by_cpu sh3)" |
| 473 | LIST_sh4="$(boards_by_cpu sh4)" |
| 474 | |
| 475 | LIST_sh="$(boards_by_arch sh)" |
| 476 | |
| 477 | ######################################################################### |
| 478 | ## SPARC Systems |
| 479 | ######################################################################### |
| 480 | |
| 481 | LIST_sparc="$(boards_by_arch sparc)" |
| 482 | |
| 483 | #----------------------------------------------------------------------- |
| 484 | |
| 485 | build_target() { |
| 486 | target=$1 |
| 487 | |
| 488 | ${MAKE} distclean >/dev/null |
| 489 | ${MAKE} -s ${target}_config |
| 490 | |
| 491 | ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ |
| 492 | | tee ${LOG_DIR}/$target.ERR |
| 493 | |
| 494 | # Check for 'make' errors |
| 495 | if [ ${PIPESTATUS[0]} -ne 0 ] ; then |
| 496 | RC=1 |
| 497 | fi |
| 498 | |
| 499 | if [ -s ${LOG_DIR}/$target.ERR ] ; then |
| 500 | ERR_CNT=$((ERR_CNT + 1)) |
| 501 | ERR_LIST="${ERR_LIST} $target" |
| 502 | else |
| 503 | rm ${LOG_DIR}/$target.ERR |
| 504 | fi |
| 505 | |
| 506 | TOTAL_CNT=$((TOTAL_CNT + 1)) |
| 507 | |
| 508 | ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \ |
| 509 | | tee -a ${LOG_DIR}/$target.MAKELOG |
| 510 | } |
| 511 | build_targets() { |
| 512 | for t in "$@" ; do |
| 513 | # If a LIST_xxx var exists, use it. But avoid variable |
| 514 | # expansion in the eval when a board name contains certain |
| 515 | # characters that the shell interprets. |
| 516 | case ${t} in |
| 517 | *[-+=]*) list= ;; |
| 518 | *) list=$(eval echo '${LIST_'$t'}') ;; |
| 519 | esac |
| 520 | if [ -n "${list}" ] ; then |
| 521 | build_targets ${list} |
| 522 | else |
| 523 | build_target ${t} |
| 524 | fi |
| 525 | done |
| 526 | } |
| 527 | |
| 528 | #----------------------------------------------------------------------- |
| 529 | |
| 530 | print_stats() { |
| 531 | echo "" |
| 532 | echo "--------------------- SUMMARY ----------------------------" |
| 533 | echo "Boards compiled: ${TOTAL_CNT}" |
| 534 | if [ ${ERR_CNT} -gt 0 ] ; then |
| 535 | echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )" |
| 536 | fi |
| 537 | echo "----------------------------------------------------------" |
| 538 | |
| 539 | exit $RC |
| 540 | } |
| 541 | |
| 542 | #----------------------------------------------------------------------- |
| 543 | |
| 544 | # Build target groups selected by options, plus any command line args |
| 545 | set -- ${SELECTED} "$@" |
| 546 | # run PowerPC by default |
| 547 | [ $# = 0 ] && set -- powerpc |
| 548 | build_targets "$@" |