blob: 0ab53bff7a43f1d4d35489a5d774481925fde4a4 [file] [log] [blame]
Stewart Smith098d03e2016-03-01 13:59:42 +11001#!/bin/bash
2
3set -ex
4set -eo pipefail
5
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +10006BUILD_INFO=0
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +05307CONFIGTAG="_defconfig"
8
9DEFCONFIGS=();
10
Stewart Smithc4b9bf62018-08-24 13:30:15 +100011SDK_DIR=""
12
13while getopts "o:p:rs:" opt; do
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100014 case $opt in
15 o)
16 echo "Output directory: $OPTARG"
17 OUTDIR="$OPTARG"
18 ;;
Stewart Smithc4b9bf62018-08-24 13:30:15 +100019 s)
20 echo "SDK is in: $OPTARG"
21 SDK_DIR=$OPTARG
22 ;;
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100023 p)
24 echo "Platforms to build: $OPTARG"
25 PLATFORM_LIST="$OPTARG"
26 ;;
27 r)
Stewart Smithc4b9bf62018-08-24 13:30:15 +100028 echo "Build legal-info etc for release"
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100029 BUILD_INFO=1
30 ;;
31 \?)
32 echo "Invalid option: -$OPTARG"
33 exit 1
34 ;;
35 :)
36 echo "Option -$OPTARG requires an argument."
37 exit 1
38 ;;
39 esac
40done
41
42if [ -z "${PLATFORM_LIST}" ]; then
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053043 echo "Using all the defconfigs for all the platforms"
44 DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)`
45else
46 IFS=', '
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100047 for p in ${PLATFORM_LIST};
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053048 do
49 DEFCONFIGS+=($p$CONFIGTAG)
50 done
51fi
Stewart Smith098d03e2016-03-01 13:59:42 +110052
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100053if [ -z "${OUTDIR}" or ! -d "${OUTDIR}" ]; then
Stewart Smith098d03e2016-03-01 13:59:42 +110054 echo "No output directory specified"
55 exit 1;
56fi
57
58if [ -z "$CCACHE_DIR" ]; then
59 CCACHE_DIR=`pwd`/.op-build_ccache
60fi
61
62shopt -s expand_aliases
63source op-build-env
64
Samuel Mendoza-Jonas94ec86a2018-08-06 15:18:26 +100065if [ -n "$DL_DIR" ]; then
66 unset BR2_DL_DIR
67 export BR2_DL_DIR=${DL_DIR}
68fi
69
Stewart Smithc4b9bf62018-08-24 13:30:15 +100070if [ -f $(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1) ]; then
71 export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so
72fi
73
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053074for i in ${DEFCONFIGS[@]}; do
Stewart Smithc4b9bf62018-08-24 13:30:15 +100075 export O=${OUTDIR}-$i
76 rm -rf $O
77 op-build O=$O $i
78 ./buildroot/utils/config --file $O/.config --set-val BR2_CCACHE y
79 ./buildroot/utils/config --file $O/.config --set-str BR2_CCACHE_DIR $CCACHE_DIR
80 if [ -d "$SDK_DIR" ]; then
81 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL y
82 ./buildroot/utils/config --file $O/.config --set-str BR2_TOOLCHAIN_EXTERNAL_PATH $SDK_DIR
83 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC y
84 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CXX y
85 # FIXME: How do we work this out programatically?
86 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_GCC_6 y
87 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_18 y
88 fi
89 op-build O=$O olddefconfig
90 op-build O=$O
Stewart Smith098d03e2016-03-01 13:59:42 +110091 r=$?
Stewart Smithc4b9bf62018-08-24 13:30:15 +100092 if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then
93 op-build O=$O legal-info
94 op-build O=$O graph-build
95 op-build O=$O graph-size
96 op-build O=$O graph-depends
97 fi
98 lsb_release -a > $O/lsb_release
Stewart Smith098d03e2016-03-01 13:59:42 +110099 if [ $r -ne 0 ]; then
100 exit $r
101 fi
102done
103