#!/usr/bin/env bash # # Build Wiimms ISO Tools (wit) # # Builds the complete suite of tools for Wii/GameCube disc management # Tools: wit, wwt, wdf, wfuse # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SRC_DIR="${SCRIPT_DIR}/src" BUILD_DIR="${SCRIPT_DIR}/build" TOOLS_BIN_DIR="${SCRIPT_DIR}/../bin" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "Building Wiimms ISO Tools (wit)" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" # Check if source exists if [ ! -d "${SRC_DIR}" ]; then echo "❌ Source directory not found: ${SRC_DIR}" echo " Run ./clone.sh first!" exit 1 fi # Check for required tools echo "🔍 Checking build dependencies..." MISSING_DEPS=() if ! command -v gcc &> /dev/null; then MISSING_DEPS+=("gcc") fi if ! command -v make &> /dev/null; then MISSING_DEPS+=("make") fi if ! command -v pkg-config &> /dev/null; then MISSING_DEPS+=("pkg-config") fi # Check for fuse development files (optional) if ! pkg-config --exists fuse 2>/dev/null; then echo " ⚠️ libfuse-dev not found (wfuse will not be built)" echo " Optional: sudo apt-get install libfuse-dev" fi if [ ${#MISSING_DEPS[@]} -gt 0 ]; then echo "❌ Missing required dependencies: ${MISSING_DEPS[*]}" echo "" echo "Install with:" echo " sudo apt-get install build-essential pkg-config libfuse-dev" exit 1 fi echo " ✅ gcc found: $(gcc --version | head -1)" echo " ✅ make found: $(make --version | head -1)" echo "" # Create build directory mkdir -p "${BUILD_DIR}" # Record build start time BUILD_START=$(date +%s) echo "🔨 Compiling Wiimms ISO Tools..." echo " Source: ${SRC_DIR}" echo " Output: ${BUILD_DIR}" echo "" cd "${SRC_DIR}/project" # Clean any previous builds echo " Cleaning previous builds..." make clean &>/dev/null || true # Build with optimizations echo " Building all tools..." echo "" make -j$(nproc) 2>&1 | tee "${SCRIPT_DIR}/build.log" # Record build end time BUILD_END=$(date +%s) BUILD_DURATION=$((BUILD_END - BUILD_START)) echo "" echo "✅ Build complete in ${BUILD_DURATION} seconds!" echo "" # Copy binaries to build directory echo "📦 Copying binaries..." BUILT_BINARIES=() for tool in wit wwt wdf wfuse; do if [ -f "bin/${tool}" ]; then cp "bin/${tool}" "${BUILD_DIR}/" chmod +x "${BUILD_DIR}/${tool}" BUILT_BINARIES+=("${tool}") echo " ✅ ${tool}" elif [ -f "${tool}" ]; then cp "${tool}" "${BUILD_DIR}/" chmod +x "${BUILD_DIR}/${tool}" BUILT_BINARIES+=("${tool}") echo " ✅ ${tool}" fi done if [ ${#BUILT_BINARIES[@]} -eq 0 ]; then echo "❌ No binaries found after build!" exit 1 fi echo "" # Show binary info echo "📦 Binary Information:" for tool in "${BUILT_BINARIES[@]}"; do if [ -f "${BUILD_DIR}/${tool}" ]; then SIZE=$(du -h "${BUILD_DIR}/${tool}" | cut -f1) echo " ${tool}: ${SIZE}" fi done echo "" # Test binaries echo "🧪 Testing binaries..." for tool in "${BUILT_BINARIES[@]}"; do if "${BUILD_DIR}/${tool}" --version &>/dev/null; then VERSION=$("${BUILD_DIR}/${tool}" --version 2>&1 | head -1) echo " ✅ ${tool}: ${VERSION}" elif "${BUILD_DIR}/${tool}" --help &>/dev/null; then echo " ✅ ${tool}: responds to --help" else echo " ⚠️ ${tool}: built but may not respond to version check" fi done echo "" # Create symlinks in tools/bin/ mkdir -p "${TOOLS_BIN_DIR}" echo "🔗 Creating symlinks..." for tool in "${BUILT_BINARIES[@]}"; do ln -sf "${BUILD_DIR}/${tool}" "${TOOLS_BIN_DIR}/${tool}" echo " ${TOOLS_BIN_DIR}/${tool} → ${BUILD_DIR}/${tool}" done echo "" # Save build info BUILD_INFO_FILE="${SCRIPT_DIR}/BUILD_INFO.txt" { echo "Wiimms ISO Tools build information" echo "===================================" echo "" echo "Build date: $(date -u +%Y-%m-%d\ %H:%M:%S\ UTC)" echo "Build duration: ${BUILD_DURATION} seconds" echo "Build system: $(uname -s) $(uname -m)" echo "Compiler: $(gcc --version | head -1)" echo "Parallel jobs: $(nproc)" echo "" echo "Built tools:" for tool in "${BUILT_BINARIES[@]}"; do if [ -f "${BUILD_DIR}/${tool}" ]; then SIZE=$(du -h "${BUILD_DIR}/${tool}" | cut -f1) MD5=$(md5sum "${BUILD_DIR}/${tool}" | cut -d' ' -f1) echo " ${tool}:" echo " Size: ${SIZE}" echo " MD5: ${MD5}" if "${BUILD_DIR}/${tool}" --version &>/dev/null; then VERSION=$("${BUILD_DIR}/${tool}" --version 2>&1 | head -1) echo " Version: ${VERSION}" fi fi done echo "" echo "Symlinks:" for tool in "${BUILT_BINARIES[@]}"; do echo " ${TOOLS_BIN_DIR}/${tool} → ${BUILD_DIR}/${tool}" done } > "${BUILD_INFO_FILE}" echo "📄 Build info saved to: ${BUILD_INFO_FILE}" echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✅ Wiimms ISO Tools are ready to use!" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "Tools built:" for tool in "${BUILT_BINARIES[@]}"; do echo " • ${tool}" done echo "" echo "Usage examples:" echo " ${TOOLS_BIN_DIR}/wit COPY game.iso game.wbfs" echo " ${TOOLS_BIN_DIR}/wit EXTRACT game.iso game/" echo " ${TOOLS_BIN_DIR}/wwt DUMP game.wbfs" echo ""