summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0ef54dd0382fe40e8066fb988789177f62f87a0e (plain)
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
# Compiler and flags
CC = gcc
CFLAGS = -static -O2
GO_BUILD_FLAGS = -v
CGO_ENABLED = 1

# Paths
LAUNCHER_SRC = internal/namespace/launcher_src/launcher.c
LAUNCHER_BIN = internal/namespace/launcher.bin
BINARY = wg-wrap

.PHONY: all clean test

# Default target: build the final binary
all: $(BINARY)

# Build the Go binary
$(BINARY): $(LAUNCHER_BIN)
	CGO_ENABLED=$(CGO_ENABLED) go build $(GO_BUILD_FLAGS) -o $(BINARY) cmd/wg-wrap/main.go

# Build the embedded C launcher binary
$(LAUNCHER_BIN): $(LAUNCHER_SRC)
	$(CC) $(CFLAGS) $(LAUNCHER_SRC) -o $(LAUNCHER_BIN)

# Run tests
test: all
	go test -v ./...

# Clean up all artifacts
clean:
	rm -f $(BINARY) $(LAUNCHER_BIN)
	find . -name "*.test" -delete