blob: 096ffbe9840d85731bfcdeeb3042bbf377d8b596 [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
Joel Stanleya81c1242018-11-01 13:19:58 +103042function get_kernel_release
43{
44 IFS=. read major minor macro <<<"$1"
45 echo -n "${major}_${minor}"
46}
47
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100048if [ -z "${PLATFORM_LIST}" ]; then
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053049 echo "Using all the defconfigs for all the platforms"
50 DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)`
51else
52 IFS=', '
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100053 for p in ${PLATFORM_LIST};
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053054 do
55 DEFCONFIGS+=($p$CONFIGTAG)
56 done
57fi
Stewart Smith098d03e2016-03-01 13:59:42 +110058
Stewart Smith098d03e2016-03-01 13:59:42 +110059if [ -z "$CCACHE_DIR" ]; then
60 CCACHE_DIR=`pwd`/.op-build_ccache
61fi
62
63shopt -s expand_aliases
64source op-build-env
65
Samuel Mendoza-Jonas94ec86a2018-08-06 15:18:26 +100066if [ -n "$DL_DIR" ]; then
67 unset BR2_DL_DIR
68 export BR2_DL_DIR=${DL_DIR}
69fi
70
Stewart Smithc4b9bf62018-08-24 13:30:15 +100071if [ -f $(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1) ]; then
72 export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so
73fi
74
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053075for i in ${DEFCONFIGS[@]}; do
Klaus Heinrich Kiwia1f404a2020-04-16 14:24:30 -030076 export O=${OUTDIR}/$i
Stewart Smithc4b9bf62018-08-24 13:30:15 +100077 rm -rf $O
78 op-build O=$O $i
79 ./buildroot/utils/config --file $O/.config --set-val BR2_CCACHE y
80 ./buildroot/utils/config --file $O/.config --set-str BR2_CCACHE_DIR $CCACHE_DIR
81 if [ -d "$SDK_DIR" ]; then
82 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL y
83 ./buildroot/utils/config --file $O/.config --set-str BR2_TOOLCHAIN_EXTERNAL_PATH $SDK_DIR
84 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC y
85 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CXX y
86 # FIXME: How do we work this out programatically?
87 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_GCC_6 y
Joel Stanleya81c1242018-11-01 13:19:58 +103088
89 KERNEL_VER=$(./buildroot/utils/config --file $O/.config --state BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE)
90 echo "KERNEL_VER " $KERNEL_VER
91 HEADERS=BR2_TOOLCHAIN_EXTERNAL_HEADERS_$(get_kernel_release $KERNEL_VER)
92 ./buildroot/utils/config --file $O/.config --set-val $HEADERS y
Stewart Smithc4b9bf62018-08-24 13:30:15 +100093 fi
94 op-build O=$O olddefconfig
95 op-build O=$O
Stewart Smith098d03e2016-03-01 13:59:42 +110096 r=$?
Stewart Smithc4b9bf62018-08-24 13:30:15 +100097 if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then
98 op-build O=$O legal-info
99 op-build O=$O graph-build
100 op-build O=$O graph-size
101 op-build O=$O graph-depends
102 fi
103 lsb_release -a > $O/lsb_release
Stewart Smith098d03e2016-03-01 13:59:42 +1100104 if [ $r -ne 0 ]; then
105 exit $r
106 fi
107done
108