62 lines
2.2 KiB
Bash
Executable File
62 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# build.sh — wrapper for Mestre Buildroot builds.
|
|
#
|
|
# Usage:
|
|
# ./scripts/build.sh # full build
|
|
# ./scripts/build.sh menuconfig # Buildroot menuconfig
|
|
# ./scripts/build.sh linux-menuconfig # Linux kernel menuconfig
|
|
# ./scripts/build.sh uboot-menuconfig # U-Boot menuconfig
|
|
# ./scripts/build.sh <pkg>-rebuild # Force-rebuild a single package
|
|
# ./scripts/build.sh clean # Clean build output
|
|
# ./scripts/build.sh -- -j4 # Pass arbitrary args through to make
|
|
#
|
|
# On first invocation, the build directory is created and configured from
|
|
# the mestre_x6200_defconfig. Subsequent invocations reuse the existing
|
|
# build directory.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
BUILD_DIR="$REPO_ROOT/build"
|
|
BR2_EXTERNAL="$REPO_ROOT/br2_external"
|
|
DEFCONFIG="mestre_x6200_defconfig"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Sanity check: submodule must be present
|
|
# ---------------------------------------------------------------------------
|
|
if [ ! -f "$REPO_ROOT/buildroot/Makefile" ]; then
|
|
echo "!!! Buildroot submodule not initialized."
|
|
echo " Run: ./scripts/setup.sh"
|
|
exit 1
|
|
fi
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# First-time configuration
|
|
# ---------------------------------------------------------------------------
|
|
if [ ! -f "$BUILD_DIR/.config" ]; then
|
|
if [ ! -f "$BR2_EXTERNAL/configs/$DEFCONFIG" ]; then
|
|
echo "!!! Defconfig not found: $BR2_EXTERNAL/configs/$DEFCONFIG"
|
|
echo " The defconfig hasn't been added yet. See the project's"
|
|
echo " milestone status in README.md."
|
|
exit 1
|
|
fi
|
|
|
|
echo ">>> First-time configuration: $DEFCONFIG"
|
|
mkdir -p "$BUILD_DIR"
|
|
make -C "$REPO_ROOT/buildroot" \
|
|
BR2_EXTERNAL="$BR2_EXTERNAL" \
|
|
O="$BUILD_DIR" \
|
|
"$DEFCONFIG"
|
|
echo
|
|
fi
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Run make in the build directory
|
|
# ---------------------------------------------------------------------------
|
|
# Default to plain `make` if no extra args were passed.
|
|
if [ $# -eq 0 ]; then
|
|
make -C "$BUILD_DIR"
|
|
else
|
|
make -C "$BUILD_DIR" "$@"
|
|
fi
|