Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -ex |
| 4 | set -eo pipefail |
| 5 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 6 | BUILD_INFO=0 |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 7 | CONFIGTAG="_defconfig" |
| 8 | |
| 9 | DEFCONFIGS=(); |
| 10 | |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 11 | SDK_DIR="" |
| 12 | |
| 13 | while getopts "o:p:rs:" opt; do |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 14 | case $opt in |
| 15 | o) |
| 16 | echo "Output directory: $OPTARG" |
| 17 | OUTDIR="$OPTARG" |
| 18 | ;; |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 19 | s) |
| 20 | echo "SDK is in: $OPTARG" |
| 21 | SDK_DIR=$OPTARG |
| 22 | ;; |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 23 | p) |
| 24 | echo "Platforms to build: $OPTARG" |
| 25 | PLATFORM_LIST="$OPTARG" |
| 26 | ;; |
| 27 | r) |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 28 | echo "Build legal-info etc for release" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 29 | 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 |
| 40 | done |
| 41 | |
Joel Stanley | a81c124 | 2018-11-01 13:19:58 +1030 | [diff] [blame] | 42 | function get_kernel_release |
| 43 | { |
| 44 | IFS=. read major minor macro <<<"$1" |
| 45 | echo -n "${major}_${minor}" |
| 46 | } |
| 47 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 48 | if [ -z "${PLATFORM_LIST}" ]; then |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 49 | echo "Using all the defconfigs for all the platforms" |
| 50 | DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)` |
| 51 | else |
| 52 | IFS=', ' |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 53 | for p in ${PLATFORM_LIST}; |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 54 | do |
| 55 | DEFCONFIGS+=($p$CONFIGTAG) |
| 56 | done |
| 57 | fi |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 58 | |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 59 | if [ -z "$CCACHE_DIR" ]; then |
| 60 | CCACHE_DIR=`pwd`/.op-build_ccache |
| 61 | fi |
| 62 | |
| 63 | shopt -s expand_aliases |
| 64 | source op-build-env |
| 65 | |
Samuel Mendoza-Jonas | 94ec86a | 2018-08-06 15:18:26 +1000 | [diff] [blame] | 66 | if [ -n "$DL_DIR" ]; then |
| 67 | unset BR2_DL_DIR |
| 68 | export BR2_DL_DIR=${DL_DIR} |
| 69 | fi |
| 70 | |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 71 | if [ -f $(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1) ]; then |
| 72 | export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so |
| 73 | fi |
| 74 | |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 75 | for i in ${DEFCONFIGS[@]}; do |
Klaus Heinrich Kiwi | a1f404a | 2020-04-16 14:24:30 -0300 | [diff] [blame^] | 76 | export O=${OUTDIR}/$i |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 77 | 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 Stanley | a81c124 | 2018-11-01 13:19:58 +1030 | [diff] [blame] | 88 | |
| 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 Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 93 | fi |
| 94 | op-build O=$O olddefconfig |
| 95 | op-build O=$O |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 96 | r=$? |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 97 | 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 Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 104 | if [ $r -ne 0 ]; then |
| 105 | exit $r |
| 106 | fi |
| 107 | done |
| 108 | |