blob: e1455b2b304f3e96e155010e5dc5d58e79872cf9 [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
Samuel Mendoza-Jonas8d102aa2018-08-10 13:47:48 +100059if [ -z "${OUTDIR}" or ! -d "${OUTDIR}" ]; then
Stewart Smith098d03e2016-03-01 13:59:42 +110060 echo "No output directory specified"
61 exit 1;
62fi
63
64if [ -z "$CCACHE_DIR" ]; then
65 CCACHE_DIR=`pwd`/.op-build_ccache
66fi
67
68shopt -s expand_aliases
69source op-build-env
70
Samuel Mendoza-Jonas94ec86a2018-08-06 15:18:26 +100071if [ -n "$DL_DIR" ]; then
72 unset BR2_DL_DIR
73 export BR2_DL_DIR=${DL_DIR}
74fi
75
Stewart Smithc4b9bf62018-08-24 13:30:15 +100076if [ -f $(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1) ]; then
77 export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so
78fi
79
Pridhiviraj Paidipeddi24d94a22016-08-15 16:51:31 +053080for i in ${DEFCONFIGS[@]}; do
Stewart Smithc4b9bf62018-08-24 13:30:15 +100081 export O=${OUTDIR}-$i
82 rm -rf $O
83 op-build O=$O $i
84 ./buildroot/utils/config --file $O/.config --set-val BR2_CCACHE y
85 ./buildroot/utils/config --file $O/.config --set-str BR2_CCACHE_DIR $CCACHE_DIR
86 if [ -d "$SDK_DIR" ]; then
87 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL y
88 ./buildroot/utils/config --file $O/.config --set-str BR2_TOOLCHAIN_EXTERNAL_PATH $SDK_DIR
89 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC y
90 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_CXX y
91 # FIXME: How do we work this out programatically?
92 ./buildroot/utils/config --file $O/.config --set-val BR2_TOOLCHAIN_EXTERNAL_GCC_6 y
Joel Stanleya81c1242018-11-01 13:19:58 +103093
94 KERNEL_VER=$(./buildroot/utils/config --file $O/.config --state BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE)
95 echo "KERNEL_VER " $KERNEL_VER
96 HEADERS=BR2_TOOLCHAIN_EXTERNAL_HEADERS_$(get_kernel_release $KERNEL_VER)
97 ./buildroot/utils/config --file $O/.config --set-val $HEADERS y
Stewart Smithc4b9bf62018-08-24 13:30:15 +100098 fi
99 op-build O=$O olddefconfig
100 op-build O=$O
Stewart Smith098d03e2016-03-01 13:59:42 +1100101 r=$?
Stewart Smithc4b9bf62018-08-24 13:30:15 +1000102 if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then
103 op-build O=$O legal-info
104 op-build O=$O graph-build
105 op-build O=$O graph-size
106 op-build O=$O graph-depends
107 fi
108 lsb_release -a > $O/lsb_release
Stewart Smith098d03e2016-03-01 13:59:42 +1100109 if [ $r -ne 0 ]; then
110 exit $r
111 fi
112done
113