]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - MAKEALL
ppc, arm: rework and enhance keymile-common.h
[karo-tx-uboot.git] / MAKEALL
1 #!/bin/bash
2
3 # Tool mainly for U-Boot Quality Assurance: build one or more board
4 # configurations with minimal verbosity, showing only warnings and
5 # errors.
6 #
7 # There are several ways to select which boards to build.
8 #
9 # Traditionally, architecture names (like "powerpc"), CPU family names
10 # (like "mpc83xx") or board names can be specified on the command
11 # line; without any arguments, MAKEALL defaults to building all Power
12 # Architecture systems (i. e. same as for "MAKEALL powerpc").
13 #
14 # With the introduction of the board.cfg file, it has become possible
15 # to provide additional selections.  We use standard command line
16 # options for this:
17 #
18 # -a or --arch  :       Select architecture
19 # -c or --cpu   :       Select CPU family
20 # -s or --soc   :       Select SoC type
21 # -v or --vendor:       Select board vendor
22 #
23 # Selections by these options are logically ANDed; if the same option
24 # is used repeatedly, such selections are ORed.  So "-v FOO -v BAR"
25 # will select all configurations where the vendor is either FOO or
26 # BAR.  Any additional arguments specified on the command line are
27 # always build additionally.
28 #
29 # Examples:
30 #
31 # - build all Power Architecture boards:
32 #
33 #       MAKEALL -a powerpc
34 #   or
35 #       MAKEALL --arch powerpc
36 #   or
37 #       MAKEALL powerpc
38 #
39 # - build all PowerPC boards manufactured by vendor "esd":
40 #
41 #       MAKEALL -a powerpc -v esd
42 #
43 # - build all PowerPC boards manufactured either by "keymile" or
44 #   "siemens":
45 #
46 #       MAKEALL -a powerpc -v keymile -v siemens
47 #
48 # - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards:
49 #
50 #       MAKEALL -c mpc83xx -v freescale 4xx
51 #
52 #########################################################################
53
54 SHORT_OPTS="a:c:v:s:"
55 LONG_OPTS="arch:,cpu:,vendor:,soc:"
56
57 # Option processing based on util-linux-2.13/getopt-parse.bash
58
59 # Note that we use `"$@"' to let each command-line parameter expand to a
60 # separate word. The quotes around `$@' are essential!
61 # We need TEMP as the `eval set --' would nuke the return value of
62 # getopt.
63 TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \
64      -n 'MAKEALL' -- "$@"`
65
66 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
67
68 # Note the quotes around `$TEMP': they are essential!
69 eval set -- "$TEMP"
70
71 SELECTED=''
72
73 while true ; do
74         case "$1" in
75         -a|--arch)
76                 # echo "Option ARCH: argument \`$2'"
77                 if [ "$opt_a" ] ; then
78                         opt_a="${opt_a%)} || \$2 == \"$2\")"
79                 else
80                         opt_a="(\$2 == \"$2\")"
81                 fi
82                 SELECTED='y'
83                 shift 2 ;;
84         -c|--cpu)
85                 # echo "Option CPU: argument \`$2'"
86                 if [ "$opt_c" ] ; then
87                         opt_c="${opt_c%)} || \$3 == \"$2\")"
88                 else
89                         opt_c="(\$3 == \"$2\")"
90                 fi
91                 SELECTED='y'
92                 shift 2 ;;
93         -s|--soc)
94                 # echo "Option SoC: argument \`$2'"
95                 if [ "$opt_s" ] ; then
96                         opt_s="${opt_s%)} || \$6 == \"$2\")"
97                 else
98                         opt_s="(\$6 == \"$2\")"
99                 fi
100                 SELECTED='y'
101                 shift 2 ;;
102         -v|--vendor)
103                 # echo "Option VENDOR: argument \`$2'"
104                 if [ "$opt_v" ] ; then
105                         opt_v="${opt_v%)} || \$5 == \"$2\")"
106                 else
107                         opt_v="(\$5 == \"$2\")"
108                 fi
109                 SELECTED='y'
110                 shift 2 ;;
111         --)
112                 shift ; break ;;
113         *)
114                 echo "Internal error!" >&2 ; exit 1 ;;
115         esac
116 done
117 # echo "Remaining arguments:"
118 # for arg do echo '--> '"\`$arg'" ; done
119
120 FILTER="\$1 !~ /^#/"
121 [ "$opt_a" ] && FILTER="${FILTER} && $opt_a"
122 [ "$opt_c" ] && FILTER="${FILTER} && $opt_c"
123 [ "$opt_s" ] && FILTER="${FILTER} && $opt_s"
124 [ "$opt_v" ] && FILTER="${FILTER} && $opt_v"
125
126 if [ "$SELECTED" ] ; then
127         SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg)
128
129         # Make sure some boards from boards.cfg are actually found
130         if [ -z "$SELECTED" ] ; then
131                 echo "Error: No boards selected, invalid arguments"
132                 exit 1
133         fi
134 fi
135
136 #########################################################################
137
138 # Print statistics when we exit
139 trap exit 1 2 3 15
140 trap print_stats 0
141
142 # Determine number of CPU cores if no default was set
143 : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
144
145 if [ "$BUILD_NCPUS" -gt 1 ]
146 then
147         JOBS="-j $((BUILD_NCPUS + 1))"
148 else
149         JOBS=""
150 fi
151
152
153 if [ "${CROSS_COMPILE}" ] ; then
154         MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
155 else
156         MAKE=make
157 fi
158
159 if [ "${MAKEALL_LOGDIR}" ] ; then
160         LOG_DIR=${MAKEALL_LOGDIR}
161 else
162         LOG_DIR="LOG"
163 fi
164
165 if [ ! "${BUILD_DIR}" ] ; then
166         BUILD_DIR="."
167 fi
168
169 [ -d ${LOG_DIR} ] || mkdir ${LOG_DIR} || exit 1
170
171 LIST=""
172
173 # Keep track of the number of builds and errors
174 ERR_CNT=0
175 ERR_LIST=""
176 TOTAL_CNT=0
177 RC=0
178
179 # Helper funcs for parsing boards.cfg
180 boards_by_field()
181 {
182         awk \
183                 -v field="$1" \
184                 -v select="$2" \
185                 '($1 !~ /^#/ && $field == select) { print $1 }' \
186                 boards.cfg
187 }
188 boards_by_arch() { boards_by_field 2 "$@" ; }
189 boards_by_cpu()  { boards_by_field 3 "$@" ; }
190 boards_by_soc()  { boards_by_field 6 "$@" ; }
191
192 #########################################################################
193 ## MPC5xx Systems
194 #########################################################################
195
196 LIST_5xx="$(boards_by_cpu mpc5xx)"
197
198 #########################################################################
199 ## MPC5xxx Systems
200 #########################################################################
201
202 LIST_5xxx="$(boards_by_cpu mpc5xxx)"
203
204 #########################################################################
205 ## MPC512x Systems
206 #########################################################################
207
208 LIST_512x="$(boards_by_cpu mpc512x)"
209
210 #########################################################################
211 ## MPC8xx Systems
212 #########################################################################
213
214 LIST_8xx="$(boards_by_cpu mpc8xx)"
215
216 #########################################################################
217 ## PPC4xx Systems
218 #########################################################################
219
220 LIST_4xx="$(boards_by_cpu ppc4xx)"
221
222 #########################################################################
223 ## MPC8220 Systems
224 #########################################################################
225
226 LIST_8220="$(boards_by_cpu mpc8220)"
227
228 #########################################################################
229 ## MPC824x Systems
230 #########################################################################
231
232 LIST_824x="$(boards_by_cpu mpc824x)"
233
234 #########################################################################
235 ## MPC8260 Systems (includes 8250, 8255 etc.)
236 #########################################################################
237
238 LIST_8260="$(boards_by_cpu mpc8260)"
239
240 #########################################################################
241 ## MPC83xx Systems (includes 8349, etc.)
242 #########################################################################
243
244 LIST_83xx="$(boards_by_cpu mpc83xx)"
245
246 #########################################################################
247 ## MPC85xx Systems (includes 8540, 8560 etc.)
248 #########################################################################
249
250 LIST_85xx="$(boards_by_cpu mpc85xx)"
251
252 #########################################################################
253 ## MPC86xx Systems
254 #########################################################################
255
256 LIST_86xx="$(boards_by_cpu mpc86xx)"
257
258 #########################################################################
259 ## 74xx/7xx Systems
260 #########################################################################
261
262 LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
263
264 #########################################################################
265 ## PowerPC groups
266 #########################################################################
267
268 LIST_TSEC="             \
269         ${LIST_83xx}    \
270         ${LIST_85xx}    \
271         ${LIST_86xx}    \
272 "
273
274 LIST_powerpc="          \
275         ${LIST_5xx}     \
276         ${LIST_512x}    \
277         ${LIST_5xxx}    \
278         ${LIST_8xx}     \
279         ${LIST_8220}    \
280         ${LIST_824x}    \
281         ${LIST_8260}    \
282         ${LIST_83xx}    \
283         ${LIST_85xx}    \
284         ${LIST_86xx}    \
285         ${LIST_4xx}     \
286         ${LIST_74xx_7xx}\
287 "
288
289 # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
290 # still using "ppc" instead of "powerpc"
291 LIST_ppc="              \
292         ${LIST_powerpc} \
293 "
294
295 #########################################################################
296 ## StrongARM Systems
297 #########################################################################
298
299 LIST_SA="$(boards_by_cpu sa1100)"
300
301 #########################################################################
302 ## ARM7 Systems
303 #########################################################################
304
305 LIST_ARM7="             \
306         ap7             \
307         ap720t          \
308         armadillo       \
309         B2              \
310         ep7312          \
311         evb4510         \
312         impa7           \
313         integratorap    \
314         lpc2292sodimm   \
315         modnet50        \
316         SMN42           \
317 "
318
319 #########################################################################
320 ## ARM9 Systems
321 #########################################################################
322
323 LIST_ARM9="                     \
324         a320evb                 \
325         ap920t                  \
326         ap922_XA10              \
327         ap926ejs                \
328         ap946es                 \
329         ap966                   \
330         aspenite                \
331         cp920t                  \
332         cp922_XA10              \
333         cp926ejs                \
334         cp946es                 \
335         cp966                   \
336         da830evm                \
337         da850evm                \
338         edb9301                 \
339         edb9302                 \
340         edb9302a                \
341         edb9307                 \
342         edb9307a                \
343         edb9312                 \
344         edb9315                 \
345         edb9315a                \
346         edminiv2                \
347         guruplug                \
348         imx27lite               \
349         jadecpu                 \
350         lpd7a400                \
351         magnesium               \
352         mv88f6281gtw_ge         \
353         mx1ads                  \
354         mx1fs2                  \
355         netstar                 \
356         nhk8815                 \
357         nhk8815_onenand         \
358         omap1510inn             \
359         omap1610h2              \
360         omap1610inn             \
361         omap5912osk             \
362         omap730p2               \
363         openrd_base             \
364         rd6281a                 \
365         sbc2410x                \
366         scb9328                 \
367         sheevaplug              \
368         smdk2400                \
369         smdk2410                \
370         spear300                \
371         spear310                \
372         spear320                \
373         spear600                \
374         suen3                   \
375         trab                    \
376         VCMA9                   \
377         versatile               \
378         versatileab             \
379         versatilepb             \
380         voiceblue               \
381         davinci_dvevm           \
382         davinci_schmoogie       \
383         davinci_sffsdr          \
384         davinci_sonata          \
385         davinci_dm355evm        \
386         davinci_dm355leopard    \
387         davinci_dm365evm        \
388         davinci_dm6467evm       \
389 "
390
391 #########################################################################
392 ## ARM10 Systems
393 #########################################################################
394 LIST_ARM10="            \
395         integratorcp    \
396         cp1026          \
397 "
398
399 #########################################################################
400 ## ARM11 Systems
401 #########################################################################
402 LIST_ARM11="                    \
403         cp1136                  \
404         omap2420h4              \
405         apollon                 \
406         imx31_litekit           \
407         imx31_phycore           \
408         imx31_phycore_eet       \
409         mx31ads                 \
410         mx31pdk                 \
411         mx31pdk_nand            \
412         qong                    \
413         smdk6400                \
414         tnetv107x_evm           \
415 "
416
417 #########################################################################
418 ## ARMV7 Systems
419 #########################################################################
420 LIST_ARMV7="            \
421         am3517_crane            \
422         am3517_evm              \
423         ca9x4_ct_vxp            \
424         devkit8000              \
425         dig297                  \
426         igep0020                \
427         igep0030                \
428         mx51evk                 \
429         omap3_beagle            \
430         omap3_overo             \
431         omap3_evm               \
432         omap3_pandora           \
433         omap3_sdp3430           \
434         omap3_zoom1             \
435         omap3_zoom2             \
436         omap4_panda             \
437         omap4_sdp4430           \
438         s5p_goni                \
439         smdkc100                \
440 "
441
442 #########################################################################
443 ## AT91 Systems
444 #########################################################################
445
446 LIST_at91="$(boards_by_soc at91)\
447         $(boards_by_soc at91rm9200)\
448         at91sam9260ek           \
449         at91sam9261ek           \
450         at91sam9263ek           \
451         at91sam9g10ek           \
452         at91sam9g20ek           \
453         at91sam9m10g45ek        \
454         at91sam9rlek            \
455         CPUAT91                 \
456         CPU9260                 \
457         CPU9G20                 \
458         pm9g45                  \
459         SBC35_A9G20             \
460         TNY_A9260               \
461         TNY_A9G20               \
462 "
463
464 #########################################################################
465 ## Xscale Systems
466 #########################################################################
467
468 LIST_pxa="$(boards_by_cpu pxa)"
469
470 LIST_ixp="$(boards_by_cpu ixp)
471         pdnb3           \
472         scpu            \
473 "
474
475 #########################################################################
476 ## ARM groups
477 #########################################################################
478
479 LIST_arm="                      \
480         ${LIST_SA}              \
481         ${LIST_ARM7}            \
482         ${LIST_ARM9}            \
483         ${LIST_ARM10}           \
484         ${LIST_ARM11}           \
485         ${LIST_ARMV7}   \
486         ${LIST_at91}            \
487         ${LIST_pxa}             \
488         ${LIST_ixp}             \
489 "
490
491 #########################################################################
492 ## MIPS Systems         (default = big endian)
493 #########################################################################
494
495 LIST_mips4kc="          \
496         incaip          \
497         qemu_mips       \
498         vct_platinum    \
499         vct_platinum_small      \
500         vct_platinum_onenand    \
501         vct_platinum_onenand_small      \
502         vct_platinumavc \
503         vct_platinumavc_small   \
504         vct_platinumavc_onenand \
505         vct_platinumavc_onenand_small   \
506         vct_premium     \
507         vct_premium_small       \
508         vct_premium_onenand     \
509         vct_premium_onenand_small       \
510 "
511
512 LIST_mips5kc=""
513
514 LIST_au1xx0="           \
515         dbau1000        \
516         dbau1100        \
517         dbau1500        \
518         dbau1550        \
519         dbau1550_el     \
520         gth2            \
521 "
522
523 LIST_mips="             \
524         ${LIST_mips4kc} \
525         ${LIST_mips5kc} \
526         ${LIST_au1xx0}  \
527 "
528
529 #########################################################################
530 ## MIPS Systems         (little endian)
531 #########################################################################
532
533 LIST_mips4kc_el=""
534
535 LIST_mips5kc_el=""
536
537 LIST_au1xx0_el="        \
538         dbau1550_el     \
539         pb1000          \
540 "
541
542 LIST_mips_el="                  \
543         ${LIST_mips4kc_el}      \
544         ${LIST_mips5kc_el}      \
545         ${LIST_au1xx0_el}       \
546 "
547
548 #########################################################################
549 ## x86 Systems
550 #########################################################################
551
552 LIST_x86="$(boards_by_arch x86)"
553
554 #########################################################################
555 ## Nios-II Systems
556 #########################################################################
557
558 LIST_nios2="$(boards_by_arch nios2)
559         nios2-generic   \
560 "
561
562 #########################################################################
563 ## MicroBlaze Systems
564 #########################################################################
565
566 LIST_microblaze="$(boards_by_arch microblaze)"
567
568 #########################################################################
569 ## ColdFire Systems
570 #########################################################################
571
572 LIST_coldfire="$(boards_by_arch m68k)
573         astro_mcf5373l          \
574         cobra5272               \
575         EB+MCF-EV123            \
576         EB+MCF-EV123_internal   \
577         M52277EVB               \
578         M5235EVB                \
579         M5329AFEE               \
580         M5373EVB                \
581         M54451EVB               \
582         M54455EVB               \
583         M5475AFE                \
584         M5485AFE                \
585 "
586
587 #########################################################################
588 ## AVR32 Systems
589 #########################################################################
590
591 LIST_avr32="$(boards_by_arch avr32)"
592
593 #########################################################################
594 ## Blackfin Systems
595 #########################################################################
596
597 LIST_blackfin="$(boards_by_arch blackfin)"
598
599 #########################################################################
600 ## SH Systems
601 #########################################################################
602
603 LIST_sh2="$(boards_by_cpu sh2)"
604 LIST_sh3="$(boards_by_cpu sh3)"
605 LIST_sh4="$(boards_by_cpu sh4)"
606
607 LIST_sh="$(boards_by_arch sh)"
608
609 #########################################################################
610 ## SPARC Systems
611 #########################################################################
612
613 LIST_sparc="$(boards_by_arch sparc)"
614
615 #-----------------------------------------------------------------------
616
617 build_target() {
618         target=$1
619
620         ${MAKE} distclean >/dev/null
621         ${MAKE} -s ${target}_config
622
623         ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
624                                 | tee ${LOG_DIR}/$target.ERR
625
626         # Check for 'make' errors
627         if [ ${PIPESTATUS[0]} -ne 0 ] ; then
628                 RC=1
629         fi
630
631         if [ -s ${LOG_DIR}/$target.ERR ] ; then
632                 ERR_CNT=$((ERR_CNT + 1))
633                 ERR_LIST="${ERR_LIST} $target"
634         else
635                 rm ${LOG_DIR}/$target.ERR
636         fi
637
638         TOTAL_CNT=$((TOTAL_CNT + 1))
639
640         ${CROSS_COMPILE}size ${BUILD_DIR}/u-boot \
641                                 | tee -a ${LOG_DIR}/$target.MAKELOG
642 }
643 build_targets() {
644         for t in "$@" ; do
645                 # If a LIST_xxx var exists, use it.  But avoid variable
646                 # expansion in the eval when a board name contains certain
647                 # characters that the shell interprets.
648                 case ${t} in
649                         *[-+=]*) list= ;;
650                         *)       list=$(eval echo '${LIST_'$t'}') ;;
651                 esac
652                 if [ -n "${list}" ] ; then
653                         build_targets ${list}
654                 else
655                         build_target ${t}
656                 fi
657         done
658 }
659
660 #-----------------------------------------------------------------------
661
662 print_stats() {
663         echo ""
664         echo "--------------------- SUMMARY ----------------------------"
665         echo "Boards compiled: ${TOTAL_CNT}"
666         if [ ${ERR_CNT} -gt 0 ] ; then
667                 echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )"
668         fi
669         echo "----------------------------------------------------------"
670
671         exit $RC
672 }
673
674 #-----------------------------------------------------------------------
675
676 # Build target groups selected by options, plus any command line args
677 set -- ${SELECTED} "$@"
678 # run PowerPC by default
679 [ $# = 0 ] && set -- powerpc
680 build_targets "$@"