|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -x |
| 4 | +set -e |
| 5 | + |
| 6 | +# build perf for the PrawnOS linux kernel |
| 7 | + |
| 8 | + |
| 9 | +# This file is part of PrawnOS (https://www.prawnos.com) |
| 10 | +# Copyright (c) 2020 Hal Emmerich <[email protected]> |
| 11 | + |
| 12 | +# PrawnOS is free software: you can redistribute it and/or modify |
| 13 | +# it under the terms of the GNU General Public License version 2 |
| 14 | +# as published by the Free Software Foundation. |
| 15 | + |
| 16 | +# PrawnOS is distributed in the hope that it will be useful, |
| 17 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | +# GNU General Public License for more details. |
| 20 | + |
| 21 | +# You should have received a copy of the GNU General Public License |
| 22 | +# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>. |
| 23 | + |
| 24 | +if [ -z "$1" ] |
| 25 | +then |
| 26 | + echo "No kernel version supplied" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | +if [ -z "$2" ] |
| 30 | +then |
| 31 | + echo "No resources directory" |
| 32 | + exit 1 |
| 33 | +fi |
| 34 | +if [ -z "$3" ] |
| 35 | +then |
| 36 | + echo "No build directory supplied" |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | +if [ -z "$4" ] |
| 40 | +then |
| 41 | + echo "No PrawnOS initramfs supplied" |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | +if [ -z "$" ] |
| 45 | +then |
| 46 | + echo "No PrawnOS target arch supplied" |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | + |
| 50 | + |
| 51 | +KVER=$1 |
| 52 | +RESOURCES=$2 |
| 53 | +BUILD_DIR=$3 |
| 54 | +INITRAMFS=$4 |
| 55 | +TARGET=$5 |
| 56 | + |
| 57 | +#assumes the kernel is already built, so we don't have to worry about janitorial work |
| 58 | + |
| 59 | + |
| 60 | +cd $BUILD_DIR |
| 61 | + |
| 62 | +sudo apt install libzstd-dev libelf-dev systemtap-sdt-dev libssl-dev libslang2-dev libperl-dev python-dev liblzma-dev libcap-dev libnuma-dev libbabeltrace-dev libbabeltrace-ctf-dev flex bison libiberty-dev binutils-dev libunwind-dev libdw-dev |
| 63 | + |
| 64 | +ARCH_ARMHF=armhf |
| 65 | +ARCH_ARM64=arm64 |
| 66 | + |
| 67 | +#this arch nonsense is obnoxious. |
| 68 | +# armhf is just "arm" to the kernel |
| 69 | +# arm64 is just arm64 |
| 70 | +if [ "$TARGET" == "$ARCH_ARMHF" ]; then |
| 71 | + CROSS_COMPILER=arm-none-eabi- |
| 72 | + # kernel doesn't differentiate between arm and armhf |
| 73 | + KERNEL_ARCH=arm |
| 74 | +elif [ "$TARGET" == "$ARCH_ARM64" ]; then |
| 75 | + CROSS_COMPILER=aarch64-linux-gnu- |
| 76 | + KERNEL_ARCH=$ARCH_ARM64 |
| 77 | +else |
| 78 | + echo "no valid target arch specified" |
| 79 | + exit 1 |
| 80 | +fi |
| 81 | + |
| 82 | +cd tools/perf/ |
| 83 | +make -j $(($(nproc) +1)) CROSS_COMPILE=$CROSS_COMPILER ARCH=$KERNEL_ARCH |
| 84 | + |
| 85 | +#TODO: for packaging, we can use make -C tools/ perf_install prefix=/usr/ |
0 commit comments