-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 1.62 KB
/
Makefile
File metadata and controls
55 lines (45 loc) · 1.62 KB
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
.PHONY: build clean install test help
BINARY_NAME=tailproxy
LIB_NAME=libtailproxy.so
INSTALL_PATH=/usr/local/bin
INSTALL_LIB_PATH=/usr/local/lib
help:
@echo "Available targets:"
@echo " build - Build tailproxy binary and preload library"
@echo " clean - Remove built binaries and cache"
@echo " install - Install tailproxy to $(INSTALL_PATH)"
@echo " uninstall - Remove tailproxy from $(INSTALL_PATH)"
@echo " test - Run tests"
@echo " help - Show this help message"
build: $(LIB_NAME) $(BINARY_NAME)
$(LIB_NAME): preload.c
@echo "Building $(LIB_NAME)..."
@gcc -shared -fPIC -O2 -Wall -o $(LIB_NAME) preload.c -ldl
@echo "Build complete: $(LIB_NAME)"
$(BINARY_NAME): $(LIB_NAME) *.go
@echo "Building $(BINARY_NAME)..."
@mkdir -p .build/cache
@TMPDIR=$(PWD)/.build GOCACHE=$(PWD)/.build/cache go build -o $(BINARY_NAME) main.go config.go proxy.go exporter.go
@echo "Build complete: $(BINARY_NAME)"
clean:
@echo "Cleaning up..."
@rm -f $(BINARY_NAME) $(LIB_NAME)
@rm -rf .build
@go clean -cache -testcache
@echo "Clean complete"
install: build
@echo "Installing $(BINARY_NAME) and $(LIB_NAME) to $(INSTALL_PATH)..."
@sudo cp $(BINARY_NAME) $(INSTALL_PATH)/
@sudo cp $(LIB_NAME) $(INSTALL_PATH)/
@sudo chmod +x $(INSTALL_PATH)/$(BINARY_NAME)
@sudo chmod 644 $(INSTALL_PATH)/$(LIB_NAME)
@echo "Installation complete"
uninstall:
@echo "Removing $(BINARY_NAME) and $(LIB_NAME) from $(INSTALL_PATH)..."
@sudo rm -f $(INSTALL_PATH)/$(BINARY_NAME)
@sudo rm -f $(INSTALL_PATH)/$(LIB_NAME)
@echo "Uninstallation complete"
test:
@echo "Running tests..."
@go test -v ./...
.DEFAULT_GOAL := build