summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 0fde165f855d215bea92dce554ecd7ffdec61a8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Veilith Portable - Makefile
# Builds portable executables for Windows, Linux, and Android

# Configuration
VERSION := 0.9
BUILD_DATE := $(shell date +%Y%m%d)
OUTPUT_DIR := veilith-portable-v$(VERSION)
LDFLAGS := -s -w -X main.Version=$(VERSION) -X main.BuildDate=$(BUILD_DATE)

# Colors for output
GREEN := \033[0;32m
YELLOW := \033[1;33m
BLUE := \033[0;34m
RED := \033[0;31m
NC := \033[0m

.PHONY: all clean windows linux android portable help test install-deps

# Default target
all: portable

# Help
help:
	@echo "Veilith Portable Build System v$(VERSION)"
	@echo ""
	@echo "Usage:"
	@echo "  make portable     - Build all portable executables"
	@echo "  make windows      - Build Windows executable only"
	@echo "  make linux        - Build Linux executable only"
	@echo "  make android      - Build Android APK only"
	@echo "  make clean        - Clean build artifacts"
	@echo "  make test         - Run tests"
	@echo "  make install-deps - Install build dependencies"
	@echo ""

# Install dependencies
install-deps:
	@echo "$(BLUE)[Setup]$(NC) Installing dependencies..."
	go get fyne.io/fyne/v2
	go get golang.org/x/crypto/scrypt
	go get golang.org/x/crypto/nacl/secretbox
	go get golang.org/x/net/proxy
	go get github.com/flynn/noise
	@echo "$(GREEN)✓$(NC) Dependencies installed"

# Build Windows portable
windows: install-deps
	@echo "$(BLUE)[Windows]$(NC) Building Windows portable executable..."
	@mkdir -p $(OUTPUT_DIR)/Windows
	CGO_ENABLED=1 \
	GOOS=windows \
	GOARCH=amd64 \
	CC=x86_64-w64-mingw32-gcc \
	go build \
	    -ldflags="$(LDFLAGS) -H windowsgui" \
	    -tags static \
	    -o $(OUTPUT_DIR)/Windows/veilith.exe \
	    ./veilith-main.go
	@if [ $$? -eq 0 ]; then \
		echo "$(GREEN)✓$(NC) Windows build complete"; \
	else \
		echo "$(RED)✗$(NC) Windows build failed"; \
	fi

# Build Linux portable
linux: install-deps
	@echo "$(BLUE)[Linux]$(NC) Building Linux portable executable..."
	@mkdir -p $(OUTPUT_DIR)/Linux
	CGO_ENABLED=1 \
	GOOS=linux \
	GOARCH=amd64 \
	go build \
	    -ldflags="$(LDFLAGS) -extldflags '-static'" \
	    -tags 'osusergo netgo static_build' \
	    -o $(OUTPUT_DIR)/Linux/veilith-linux \
	    ./veilith-main.go
	@chmod +x $(OUTPUT_DIR)/Linux/veilith-linux
	@if [ $$? -eq 0 ]; then \
		echo "$(GREEN)✓$(NC) Linux build complete"; \
	else \
		echo "$(RED)✗$(NC) Linux build failed"; \
	fi

# Build Android APK (placeholder - requires Android SDK)
android:
	@echo "$(YELLOW)[Android]$(NC) Android build not yet implemented"
	@echo "  Use build.sh for Android builds"

# Build all portable executables
portable:
	@echo "$(BLUE)╔════════════════════════════════════════╗$(NC)"
	@echo "$(BLUE)║  VEILITH PORTABLE BUILD v$(VERSION)         ║$(NC)"
	@echo "$(BLUE)╚════════════════════════════════════════╝$(NC)"
	@echo ""
	@$(MAKE) -s linux
	@echo ""
	@echo "$(GREEN)✓ Build complete!$(NC)"
	@echo "Output: $(OUTPUT_DIR)/"

# Run tests
test:
	@echo "$(BLUE)[Test]$(NC) Running tests..."
	go test -v ./identity/...
	go test -v ./addressbook/...
	go test -v ./session/...
	go test -v ./transport/...
	@echo "$(GREEN)✓$(NC) Tests complete"

# Clean build artifacts
clean:
	@echo "$(YELLOW)[Clean]$(NC) Removing build artifacts..."
	rm -rf $(OUTPUT_DIR)
	rm -rf veilith-portable-v*.zip
	rm -rf veilith-portable-v*.tar.gz
	@echo "$(GREEN)✓$(NC) Clean complete"

# Package distribution
package: portable
	@echo "$(YELLOW)[Package]$(NC) Creating distribution archives..."
	@if command -v zip > /dev/null; then \
		zip -r $(OUTPUT_DIR).zip $(OUTPUT_DIR); \
		echo "$(GREEN)✓$(NC) Created $(OUTPUT_DIR).zip"; \
	fi
	@if command -v tar > /dev/null; then \
		tar -czf $(OUTPUT_DIR).tar.gz $(OUTPUT_DIR); \
		echo "$(GREEN)✓$(NC) Created $(OUTPUT_DIR).tar.gz"; \
	fi