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