1+ # Quiver Chat - Cross-platform Makefile
2+ # This Makefile builds executables for Windows, Linux, and macOS
3+
4+ # Variables
5+ APP_NAME := quiver-chat
6+ VERSION := 27.7.1
7+ DIST_DIR := dist
8+ FRONTEND_DIR := frontend
9+
10+ # Go build flags
11+ LDFLAGS := -ldflags="-s -w"
12+
13+ # Platforms and architectures
14+ PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64
15+
16+ # Default target
17+ .PHONY : all
18+ all : clean frontend build
19+
20+ # Clean previous builds
21+ .PHONY : clean
22+ clean :
23+ @echo " 🧹 Cleaning previous builds..."
24+ @rm -rf $(DIST_DIR ) /
25+ @mkdir -p $(DIST_DIR ) /
26+
27+ # Build the Next.js frontend
28+ .PHONY : frontend
29+ frontend :
30+ @echo " 🎨 Building Next.js frontend..."
31+ @cd $(FRONTEND_DIR ) && npm install && npm run build
32+ @echo " ✅ Frontend build completed!"
33+
34+ # Build for all platforms
35+ .PHONY : build
36+ build : $(PLATFORMS )
37+
38+ # Build for specific platforms
39+ .PHONY : linux/amd64
40+ linux/amd64 :
41+ @echo " 📦 Building for Linux (amd64)..."
42+ @GOOS=linux GOARCH=amd64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -linux-amd64 .
43+
44+ .PHONY : linux/arm64
45+ linux/arm64 :
46+ @echo " 📦 Building for Linux (arm64)..."
47+ @GOOS=linux GOARCH=arm64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -linux-arm64 .
48+
49+ .PHONY : darwin/amd64
50+ darwin/amd64 :
51+ @echo " 📦 Building for macOS (amd64)..."
52+ @GOOS=darwin GOARCH=amd64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -macos-amd64 .
53+
54+ .PHONY : darwin/arm64
55+ darwin/arm64 :
56+ @echo " 📦 Building for macOS (arm64 - Apple Silicon)..."
57+ @GOOS=darwin GOARCH=arm64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -macos-arm64 .
58+
59+ .PHONY : windows/amd64
60+ windows/amd64 :
61+ @echo " 📦 Building for Windows (amd64)..."
62+ @GOOS=windows GOARCH=amd64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -windows-amd64.exe .
63+
64+ .PHONY : windows/arm64
65+ windows/arm64 :
66+ @echo " 📦 Building for Windows (arm64)..."
67+ @GOOS=windows GOARCH=arm64 go build $(LDFLAGS ) -o $(DIST_DIR ) /$(APP_NAME ) -windows-arm64.exe .
68+
69+ # Show build results
70+ .PHONY : list
71+ list :
72+ @echo " "
73+ @echo " ✅ Build completed! Binaries available in $( DIST_DIR) / directory:"
74+ @echo " "
75+ @ls -la $(DIST_DIR ) /
76+ @echo " "
77+ @echo " 📋 Usage instructions:"
78+ @echo " 1. Copy the appropriate binary for your platform"
79+ @echo " 2. Run the binary: ./$( APP_NAME) -[platform]"
80+ @echo " 3. Open your browser and navigate to http://localhost:8080"
81+ @echo " 4. Choose a nickname and start chatting!"
82+ @echo " "
83+ @echo " 🌐 No external dependencies required - just run and go!"
84+
85+ # Development targets
86+ .PHONY : dev
87+ dev :
88+ @echo " 🚀 Starting development server..."
89+ @go run .
90+
91+ .PHONY : test
92+ test :
93+ @echo " 🧪 Running tests..."
94+ @go test -v -race ./...
95+
96+ .PHONY : coverage
97+ coverage :
98+ @echo " 📊 Running tests with coverage..."
99+ @go test -v -race -coverprofile=coverage.out ./...
100+
101+ # Release targets
102+ .PHONY : release-archives
103+ release-archives : build
104+ @echo " 📦 Creating release archives..."
105+ @cd $(DIST_DIR ) && \
106+ tar -czf $(APP_NAME ) -linux-amd64.tar.gz $(APP_NAME ) -linux-amd64 && \
107+ tar -czf $(APP_NAME ) -linux-arm64.tar.gz $(APP_NAME ) -linux-arm64 && \
108+ tar -czf $(APP_NAME ) -macos-amd64.tar.gz $(APP_NAME ) -macos-amd64 && \
109+ tar -czf $(APP_NAME ) -macos-arm64.tar.gz $(APP_NAME ) -macos-arm64 && \
110+ zip $(APP_NAME ) -windows-amd64.zip $(APP_NAME ) -windows-amd64.exe && \
111+ zip $(APP_NAME ) -windows-arm64.zip $(APP_NAME ) -windows-arm64.exe
112+
113+ # Help target
114+ .PHONY : help
115+ help :
116+ @echo " 🚀 Quiver Chat Build System"
117+ @echo " "
118+ @echo " Available targets:"
119+ @echo " all - Build everything (clean + frontend + all platforms)"
120+ @echo " clean - Clean previous builds"
121+ @echo " frontend - Build Next.js frontend only"
122+ @echo " build - Build for all platforms"
123+ @echo " linux/amd64 - Build for Linux x64"
124+ @echo " linux/arm64 - Build for Linux ARM64"
125+ @echo " darwin/amd64 - Build for macOS Intel"
126+ @echo " darwin/arm64 - Build for macOS Apple Silicon"
127+ @echo " windows/amd64 - Build for Windows x64"
128+ @echo " windows/arm64 - Build for Windows ARM64"
129+ @echo " list - Show build results"
130+ @echo " dev - Start development server"
131+ @echo " test - Run tests"
132+ @echo " coverage - Run tests with coverage"
133+ @echo " release-archives - Create release archives"
134+ @echo " help - Show this help message"
0 commit comments