#!/bin/bash # Local build script for Cthulhu development # Builds and installs Cthulhu to ~/.local without touching system installation set -e # Exit on any error # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${GREEN}=== Cthulhu Local Build Script ===${NC}" # Check if we're in the right directory if [[ ! -f "configure.ac" ]]; then echo -e "${RED}Error: Not in Cthulhu source directory (configure.ac not found)${NC}" exit 1 fi # Check dependencies echo -e "${YELLOW}Checking dependencies...${NC}" if ! command -v autoreconf &> /dev/null; then echo -e "${RED}Error: autoreconf not found. Install autotools.${NC}" exit 1 fi if ! python3 -c "import dasbus" 2>/dev/null; then echo -e "${YELLOW}Warning: dasbus not available. D-Bus service will be disabled.${NC}" fi # Clean previous build artifacts (optional) if [[ "$1" == "--clean" ]]; then echo -e "${YELLOW}Cleaning previous build...${NC}" make distclean 2>/dev/null || true rm -rf autom4te.cache configure config.status Makefile fi # Set local installation prefix LOCAL_PREFIX="$HOME/.local" echo -e "${YELLOW}Installing to: ${LOCAL_PREFIX}${NC}" # Regenerate autotools files echo -e "${YELLOW}Regenerating autotools files...${NC}" autoreconf -fiv # Configure for local installation echo -e "${YELLOW}Configuring...${NC}" ./configure --prefix="$LOCAL_PREFIX" \ --sysconfdir="$LOCAL_PREFIX/etc" \ --localstatedir="$LOCAL_PREFIX/var" \ --disable-help # Build echo -e "${YELLOW}Building...${NC}" make -j$(nproc) # Install locally echo -e "${YELLOW}Installing to local prefix...${NC}" make install || { echo -e "${YELLOW}Warning: make install had errors, but checking if binary was created...${NC}" if [[ -f "$LOCAL_PREFIX/bin/cthulhu" ]]; then echo -e "${GREEN}Binary successfully installed despite makefile warnings.${NC}" else echo -e "${RED}Installation failed.${NC}" exit 1 fi } echo -e "${GREEN}=== Build Complete ===${NC}" echo -e "${GREEN}Cthulhu installed to: ${LOCAL_PREFIX}${NC}" echo -e "${GREEN}Binary location: ${LOCAL_PREFIX}/bin/cthulhu${NC}" echo "" echo -e "${YELLOW}To run local Cthulhu:${NC}" echo -e " ${LOCAL_PREFIX}/bin/cthulhu" echo "" echo -e "${YELLOW}To add to PATH (add to ~/.bashrc):${NC}" echo -e " export PATH=\"${LOCAL_PREFIX}/bin:\$PATH\"" echo "" echo -e "${YELLOW}To uninstall local build:${NC}" echo -e " ./clean-local.sh"