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