#!/bin/sh

# Define the output directory
OUTPUT_DIR="/var/www/html/binaries"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# Compile for Linux (various architectures)
env GOOS=linux GOARCH=amd64 go build -o "$OUTPUT_DIR/amd64" "bot-amd64.go"
env GOOS=linux GOARCH=386 go build -o "$OUTPUT_DIR/i386" "bot-i386.go"
env GOOS=linux GOARCH=arm GOARM=5 go build -o "$OUTPUT_DIR/armv5" "bot-armv5.go"
env GOOS=linux GOARCH=arm GOARM=6 go build -o "$OUTPUT_DIR/armv6" "bot-armv6.go"
env GOOS=linux GOARCH=arm GOARM=7 go build -o "$OUTPUT_DIR/armv7" "bot-armv7.go"
env GOOS=linux GOARCH=arm64 go build -o "$OUTPUT_DIR/arm64" "bot-arm64.go"
env GOOS=linux GOARCH=mips go build -o "$OUTPUT_DIR/mips" "bot-mips.go"
env GOOS=linux GOARCH=mipsle go build -o "$OUTPUT_DIR/mipsle" "bot-mipsle.go"
env GOOS=linux GOARCH=mips64 go build -o "$OUTPUT_DIR/mips64" "bot-mips64.go"
env GOOS=linux GOARCH=mips64le go build -o "$OUTPUT_DIR/mips64le" "bot-mips64le.go"
env GOOS=linux GOARCH=ppc64 go build -o "$OUTPUT_DIR/ppc64" "bot-ppc64.go"
env GOOS=linux GOARCH=ppc64le go build -o "$OUTPUT_DIR/ppc64le" "bot-ppc64le.go"
env GOOS=linux GOARCH=riscv64 go build -o "$OUTPUT_DIR/riscv64" "bot-riscv64.go"
env GOOS=linux GOARCH=s390x go build -o "$OUTPUT_DIR/s390x" "bot-s390x.go"         # IBM Z
env GOOS=linux GOARCH=arm GOARM=7 go build -o "$OUTPUT_DIR/armv7hf" "bot-armv7hf.go" # ARMv7 hard float
env GOOS=linux GOARCH=arm64 go build -o "$OUTPUT_DIR/armv8" "bot-armv8.go"         # ARMv8 (64-bit)
env GOOS=linux GOARCH=loong64 go build -o "$OUTPUT_DIR/loong64" "bot-loong64.go"     # Loongson 64-bit

# Compile for Android (ARM architectures)
env GOOS=android GOARCH=arm GOARM=7 go build -o "$OUTPUT_DIR/armv7" "bot-armv7.go"
env GOOS=android GOARCH=arm64 go build -o "$OUTPUT_DIR/arm64" "arm64.go"

echo "Compilation finished. Binaries are stored in $OUTPUT_DIR."
