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