|
| 1 | +# Convenience methods for creating a uboot build |
| 2 | +# |
| 3 | +# Here we define helper methods for building the uboot bootloader |
| 4 | +inherit: [make, pkg-config, python3] |
| 5 | + |
| 6 | +depends: |
| 7 | + - tools: |
| 8 | + target-toolchain: host-compat-toolchain |
| 9 | + depends: |
| 10 | + - python::pylibfdt # python support |
| 11 | + - libs::openssl-dev # FIT |
| 12 | + - libs::gnutls-dev # mkeficapsule/tools |
| 13 | + - name: utils::efitools # uefi |
| 14 | + use: [tools] |
| 15 | + - name: utils::xxd # UBOOT_ENV |
| 16 | + use: [tools] |
| 17 | + - name: devel::dtc # dts |
| 18 | + use: [tools] |
| 19 | + |
| 20 | +buildTools: [target-toolchain, host-toolchain, m4, bison, flex, dtc, python3, efitools] |
| 21 | +buildToolsWeak: [xxd] |
| 22 | +buildVars: [CROSS_COMPILE] |
| 23 | +buildSetup: | |
| 24 | + HOSTCC=gcc |
| 25 | + DTC=$(which dtc) |
| 26 | + # All the dependencies are for the host tools. We have to manually collect |
| 27 | + # the paths and provide them to the make command. |
| 28 | + for i in "${@:2}" ; do |
| 29 | + if [[ -d "$i/usr/include" ]] ; then |
| 30 | + HOSTCFLAGS+=" -I$i/usr/include" |
| 31 | + fi |
| 32 | + for j in lib usr/lib ; do |
| 33 | + if [[ -d "$i/$j" ]] ; then |
| 34 | + HOSTLDFLAGS+=" -L$i/$j" |
| 35 | + if compgen -G "$i/$j/*.so" >/dev/null ; then |
| 36 | + HOSTLDFLAGS+=" -Wl,-rpath-link=$i/$j" |
| 37 | + fi |
| 38 | + fi |
| 39 | + done |
| 40 | + done |
| 41 | +
|
| 42 | + # Build the initial uboot config. This will be used by all other steps. |
| 43 | + # |
| 44 | + # $1: uboot source directory |
| 45 | + # $2: defconfig (optional) |
| 46 | + # - if this is an actual file, use it as the config |
| 47 | + # - if this is not a file, check if a defconfig for the target arch by |
| 48 | + # that name exists and if yes, use that one |
| 49 | + ubootConfig() |
| 50 | + { |
| 51 | + DEF_CFG=${2:-defconfig} |
| 52 | + if [[ -f "$1/configs/${DEF_CFG}" ]] ; then |
| 53 | + DEF_CFG=$1/configs/${DEF_CFG} |
| 54 | + fi |
| 55 | + # check if the defconfig file exists |
| 56 | + if [[ ! -f "$DEF_CFG" ]]; then |
| 57 | + >&2 echo "Don't know how to use $DEF_CFG as uboot config!" |
| 58 | + false |
| 59 | + fi |
| 60 | + # check if the source file is newer than .config |
| 61 | + if [[ -f .config && .config -nt $DEF_CFG ]]; then |
| 62 | + break; |
| 63 | + fi |
| 64 | + # redo the .config file |
| 65 | + cp -u "$DEF_CFG" .config |
| 66 | + makeSequential -C $1 O=$PWD \ |
| 67 | + CROSS_COMPILE="$CROSS_COMPILE" \ |
| 68 | + DTC="$DTC" \ |
| 69 | + HOSTCC="$HOSTCC" \ |
| 70 | + HOSTCFLAGS="$HOSTCFLAGS" \ |
| 71 | + HOSTLDFLAGS="$HOSTLDFLAGS" \ |
| 72 | + olddefconfig |
| 73 | + } |
| 74 | +
|
| 75 | + # Build the actual target uboot image(s) and all configured modules |
| 76 | + # |
| 77 | + # $@: list of targets to package |
| 78 | + ubootBuild() |
| 79 | + { |
| 80 | + makeParallel \ |
| 81 | + CROSS_COMPILE="$CROSS_COMPILE" \ |
| 82 | + DTC="$DTC" \ |
| 83 | + HOSTCC="$HOSTCC" \ |
| 84 | + HOSTCFLAGS="$HOSTCFLAGS" \ |
| 85 | + HOSTLDFLAGS="$HOSTLDFLAGS" \ |
| 86 | + $@ |
| 87 | + } |
| 88 | +
|
| 89 | +packageSetup: | |
| 90 | + # Install the uboot files |
| 91 | + # |
| 92 | + # $@: list of targets to package |
| 93 | + ubootPackage() |
| 94 | + { |
| 95 | + for i in "${@:2}" ; do |
| 96 | + cp "$1/$i" "$PWD" |
| 97 | + done |
| 98 | + } |
0 commit comments