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 | |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 13 | opt=$(getopt -o 'o:s:p:r' -- "$@") |
| 14 | if [ $? != 0 ] ; then |
| 15 | echo "Invalid arguments" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | eval set -- "$opt" |
| 20 | unset opt |
| 21 | |
| 22 | while true; do |
| 23 | case "$1" in |
| 24 | '-o') |
| 25 | shift |
| 26 | echo "Output directory: $1" |
| 27 | OUTDIR="$1" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 28 | ;; |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 29 | '-s') |
| 30 | shift |
| 31 | echo "SDK is in: $1" |
| 32 | SDK_DIR=$1 |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 33 | ;; |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 34 | '-p') |
| 35 | shift |
| 36 | echo "Platforms to build: $1" |
| 37 | PLATFORM_LIST="$1" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 38 | ;; |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 39 | '-r') |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 40 | echo "Build legal-info etc for release" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 41 | BUILD_INFO=1 |
| 42 | ;; |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 43 | '--') |
| 44 | shift |
| 45 | break |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 46 | ;; |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 47 | *) |
| 48 | echo "Internal error!" |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 49 | exit 1 |
| 50 | ;; |
| 51 | esac |
Klaus Heinrich Kiwi | 220aeba | 2020-04-20 17:28:18 -0300 | [diff] [blame] | 52 | shift |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 53 | done |
| 54 | |
Joel Stanley | a81c124 | 2018-11-01 13:19:58 +1030 | [diff] [blame] | 55 | function get_kernel_release |
| 56 | { |
| 57 | IFS=. read major minor macro <<<"$1" |
| 58 | echo -n "${major}_${minor}" |
| 59 | } |
| 60 | |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 61 | if [ -z "${PLATFORM_LIST}" ]; then |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 62 | echo "Using all the defconfigs for all the platforms" |
| 63 | DEFCONFIGS=`(cd openpower/configs; ls -1 *_defconfig)` |
| 64 | else |
| 65 | IFS=', ' |
Samuel Mendoza-Jonas | 8d102aa | 2018-08-10 13:47:48 +1000 | [diff] [blame] | 66 | for p in ${PLATFORM_LIST}; |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 67 | do |
| 68 | DEFCONFIGS+=($p$CONFIGTAG) |
| 69 | done |
| 70 | fi |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 71 | |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 72 | if [ -z "$CCACHE_DIR" ]; then |
| 73 | CCACHE_DIR=`pwd`/.op-build_ccache |
| 74 | fi |
| 75 | |
| 76 | shopt -s expand_aliases |
| 77 | source op-build-env |
| 78 | |
Samuel Mendoza-Jonas | 94ec86a | 2018-08-06 15:18:26 +1000 | [diff] [blame] | 79 | if [ -n "$DL_DIR" ]; then |
| 80 | unset BR2_DL_DIR |
| 81 | export BR2_DL_DIR=${DL_DIR} |
| 82 | fi |
| 83 | |
Klaus Heinrich Kiwi | 04ce68e | 2020-04-16 15:17:50 -0300 | [diff] [blame] | 84 | if [ -f "$(ldconfig -p | grep libeatmydata.so | tr ' ' '\n' | grep /|head -n1)" ]; then |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 85 | export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}libeatmydata.so |
Klaus Heinrich Kiwi | b0cfd8e | 2020-04-20 23:18:30 -0300 | [diff] [blame^] | 86 | elif [ -f "/usr/lib64/nosync/nosync.so" ]; then |
| 87 | export LD_PRELOAD=${LD_PRELOAD:+"$LD_PRELOAD "}/usr/lib64/nosync/nosync.so |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 88 | fi |
| 89 | |
Pridhiviraj Paidipeddi | 24d94a2 | 2016-08-15 16:51:31 +0530 | [diff] [blame] | 90 | for i in ${DEFCONFIGS[@]}; do |
Klaus Heinrich Kiwi | a1f404a | 2020-04-16 14:24:30 -0300 | [diff] [blame] | 91 | export O=${OUTDIR}/$i |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 92 | rm -rf $O |
| 93 | op-build O=$O $i |
Klaus Heinrich Kiwi | 2cc78eb | 2020-04-17 10:55:50 -0300 | [diff] [blame] | 94 | ./buildroot/utils/config --file $O/.config --enable CCACHE \ |
| 95 | --set-str CCACHE_DIR $CCACHE_DIR |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 96 | if [ -d "$SDK_DIR" ]; then |
Klaus Heinrich Kiwi | 2cc78eb | 2020-04-17 10:55:50 -0300 | [diff] [blame] | 97 | ./buildroot/utils/config --file $O/.config --enable TOOLCHAIN_EXTERNAL \ |
| 98 | --set-str TOOLCHAIN_EXTERNAL_PATH $SDK_DIR \ |
| 99 | --enable TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC \ |
| 100 | --enable TOOLCHAIN_EXTERNAL_CXX |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 101 | # FIXME: How do we work this out programatically? |
Klaus Heinrich Kiwi | 2cc78eb | 2020-04-17 10:55:50 -0300 | [diff] [blame] | 102 | ./buildroot/utils/config --file $O/.config --enable BR2_TOOLCHAIN_EXTERNAL_GCC_6 |
Joel Stanley | a81c124 | 2018-11-01 13:19:58 +1030 | [diff] [blame] | 103 | |
| 104 | KERNEL_VER=$(./buildroot/utils/config --file $O/.config --state BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE) |
| 105 | echo "KERNEL_VER " $KERNEL_VER |
| 106 | HEADERS=BR2_TOOLCHAIN_EXTERNAL_HEADERS_$(get_kernel_release $KERNEL_VER) |
| 107 | ./buildroot/utils/config --file $O/.config --set-val $HEADERS y |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 108 | fi |
| 109 | op-build O=$O olddefconfig |
| 110 | op-build O=$O |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 111 | r=$? |
Stewart Smith | c4b9bf6 | 2018-08-24 13:30:15 +1000 | [diff] [blame] | 112 | if [ ${BUILD_INFO} = 1 ] && [ $r = 0 ]; then |
| 113 | op-build O=$O legal-info |
| 114 | op-build O=$O graph-build |
| 115 | op-build O=$O graph-size |
| 116 | op-build O=$O graph-depends |
| 117 | fi |
| 118 | lsb_release -a > $O/lsb_release |
Stewart Smith | 098d03e | 2016-03-01 13:59:42 +1100 | [diff] [blame] | 119 | if [ $r -ne 0 ]; then |
| 120 | exit $r |
| 121 | fi |
| 122 | done |
| 123 | |