-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (67 loc) · 2.43 KB
/
Makefile
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
.PHONY: all build clean install-deps test crun srun dist help
# Project Variables
SERVER_BIN_NAME = server
CLIENT_BIN_NAME = client
SRC_DIR = cmd
BUILD_DIR = build
# Detect OS and architecture
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
# Binary suffixes for different platforms
ifeq ($(OS),Windows_NT)
OS_SUFFIX = .exe
else
OS_SUFFIX =
endif
SERVER_BIN = $(BUILD_DIR)/$(SERVER_BIN_NAME)$(OS_SUFFIX)
CLIENT_BIN = $(BUILD_DIR)/$(CLIENT_BIN_NAME)$(OS_SUFFIX)
# Default: Build the project
all: install-deps build
# Build for the current OS and architecture
build:
@echo "Building for detected system: $(OS)/$(ARCH)..."
@go build -o $(SERVER_BIN) $(SRC_DIR)/server/main.go
@go build -o $(CLIENT_BIN) $(SRC_DIR)/client/main.go
# Test the project (Optional: Add your Go/C tests here)
test:
@echo "Running tests..."
@go test ./...
# Clean up built binaries
clean:
@echo "Cleaning up..."
@rm -f $(BUILD_DIR)/*
# Install dependencies for Go, C/C++, and Python
install-deps:
@echo "Installing dependencies..."
@go mod tidy
# Add additional dependencies if needed
# Rebuild the project from scratch
rebuild: clean all
# Compile and run the client binary for the detected OS/architecture
crun:
@echo "Building and running client binary for detected system: $(OS)/$(ARCH)..."
@go build -o $(CLIENT_BIN) $(SRC_DIR)/client/main.go
@echo "Running client binary..."
@./$(CLIENT_BIN)
# Compile and run the server binary for the detected OS/architecture
srun:
@echo "Building and running server binary for detected system: $(OS)/$(ARCH)..."
@go build -o $(SERVER_BIN) $(SRC_DIR)/server/main.go
@echo "Running server binary..."
@./$(SERVER_BIN)
# Create a zip archive of binaries for distribution
dist: all
@echo "Creating distribution archive..."
@zip -r $(BUILD_DIR)/backdoor_dist.zip $(BUILD_DIR)/*
# Help menu to list all available commands
help:
@echo "Available commands:"
@echo " make all - Install deps and build binaries for detected platform"
@echo " make build - Build the project for the detected platform"
@echo " make clean - Clean up build artifacts"
@echo " make rebuild - Clean and build again"
@echo " make test - Run tests"
@echo " make crun - Build and run the client binary"
@echo " make srun - Build and run the server binary"
@echo " make dist - Package binaries into a zip archive"
@echo " make install-deps - Install Go and other dependencies"