#!/bin/bash
echo "Building V2GDecoder with GCC (Linux alternative to VC++ MSBuild)..."

# GCC로 VC 소스 컴파일
gcc -I"src" \
    -I"src/codec" \
    -I"src/iso1" \
    -I"src/iso2" \
    -I"src/din" \
    -I"src/xmldsig" \
    -I"src/appHandshake" \
    -I"src/transport" \
    -I"src/compat" \
    -Wall -O2 \
    V2GDecoder.c \
    src/codec/*.c \
    src/iso1/*.c \
    src/iso2/*.c \
    src/din/*.c \
    src/xmldsig/*.c \
    src/appHandshake/*.c \
    src/transport/*.c \
    -o V2GDecoder

if [ $? -eq 0 ]; then
    echo "✅ Build successful! V2GDecoder created."
    echo
    echo "Usage:"
    echo "  ./V2GDecoder ../Sample/test5.exi"
    echo
    echo "Note: This is GCC build alternative to Windows MSBuild."
    echo "      For Windows VC++ build, use build.bat instead."
else
    echo "❌ Build failed with error code $?"
    echo 
    echo "Make sure GCC is installed:"
    echo "  Ubuntu/Debian: sudo apt install build-essential"
    echo "  CentOS/RHEL: sudo dnf install gcc"
    echo "  macOS: xcode-select --install"
    exit 1
fi