diff --git a/README.md b/README.md index 3c37b6b78..b6fdb663b 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,7 @@ sure to properly check out the source code which requires properly initializing git submodule update --init --recursive ``` -## Building with CMake -A build system for compiling and testing ubpf is generated for Windows, Linux and macOS platforms using [`cmake`](https://cmake.org/): - -``` -cmake -S . -B build -DUBPF_ENABLE_TESTS=true -cmake --build build --config Debug -``` +## Preparing system for build In order to prepare your system to successfully generate the build system using CMake, follow the platform-specific instructions below. @@ -83,7 +77,19 @@ cmake -S . -B build -DUBPF_ENABLE_TESTS=true -DUBPF_ALTERNATE_LLVM_PATH=/opt/hom ``` ### Linux -TBD + +```bash +./scripts/build-libbpf.sh +``` + +## Building with CMake + +A build system for compiling and testing ubpf is generated for Windows, Linux and macOS platforms using [`cmake`](https://cmake.org/): + +``` +cmake -S . -B build -DUBPF_ENABLE_TESTS=true +cmake --build build --config Debug +``` ## Running the tests diff --git a/scripts/build-libbpf.sh b/scripts/build-libbpf.sh new file mode 100755 index 000000000..21971bb1d --- /dev/null +++ b/scripts/build-libbpf.sh @@ -0,0 +1,24 @@ +#!/usr/bin/bash +# Copyright (c) Microsoft Corporation +# SPDX-License-Identifier: MIT + +git clone /~https://github.com/libbpf/libbpf.git +if [ $? -ne 0 ]; then + echo "Could not clone the libbpf repository." + exit 1 +fi + +# Jump in to the src directory to do the actual build. +cd libbpf/src + +make +if [ $? -ne 0 ]; then + echo "Could not build libbpf source." + exit 1 +fi + +# Now that the build was successful, install the library (shared +# object and header files) in a spot where FindLibBpf.cmake can +# find it when it is being built. +sudo PREFIX=/usr LIBDIR=/usr/lib/x86_64-linux-gnu/ make install +exit 0