-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (55 loc) · 2.02 KB
/
Copy pathMakefile
File metadata and controls
76 lines (55 loc) · 2.02 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# ─────────────────────────────
# Reproducible build Makefile
# ─────────────────────────────
GO ?= go
BIN_DIR ?= ./bin
OUT_CLIENT ?= $(BIN_DIR)/cmaas-client
OUT_OPENAI_PROXY ?= $(BIN_DIR)/openai-proxy
OUT_ANTHROPIC_PROXY ?= $(BIN_DIR)/anthropic-proxy
OUT_CMAAS_AUDIT ?= $(BIN_DIR)/cmaas-audit
# Environment detection
ifeq ($(shell uname -s),Darwin)
# macOS environment
GOOS ?= darwin
ifeq ($(shell uname -m),arm64)
# ARM64 architecture
GOARCH ?= arm64
else
# Intel architecture
GOARCH ?= amd64
endif
else
# Linux environment
GOOS ?= linux
GOARCH ?= amd64
endif
CGO_ENABLED := 0
# Use git commit time if available, otherwise use Unix epoch (1970-01-01)
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct 2>/dev/null || echo 0)
export GOOS GOARCH CGO_ENABLED SOURCE_DATE_EPOCH
GOFLAGS := -trimpath -buildvcs=false
LDFLAGS := -s -w -buildid= -X 'main.buildTime=$(SOURCE_DATE_EPOCH)'
.PHONY: all build proxies client openai-proxy anthropic-proxy cmaas-audit clean test
all: build
build: client openai-proxy anthropic-proxy cmaas-audit
proxies: openai-proxy anthropic-proxy
client: $(OUT_CLIENT)
openai-proxy: $(OUT_OPENAI_PROXY)
anthropic-proxy: $(OUT_ANTHROPIC_PROXY)
cmaas-audit: $(OUT_CMAAS_AUDIT)
$(OUT_CLIENT): go.mod $(shell find . -name '*.go')
@mkdir -p $(@D)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ ./cmd/cmaas-client
$(OUT_OPENAI_PROXY): go.mod $(shell find . -name '*.go')
@mkdir -p $(@D)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ ./cmd/openai-proxy
$(OUT_ANTHROPIC_PROXY): go.mod $(shell find . -name '*.go')
@mkdir -p $(@D)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ ./cmd/anthropic-proxy
$(OUT_CMAAS_AUDIT): go.mod $(shell find . -name '*.go')
@mkdir -p $(@D)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ ./cmd/cmaas-audit
test:
$(GO) test ./...
clean:
@rm -rf $(OUT_CLIENT) $(OUT_OPENAI_PROXY) $(OUT_ANTHROPIC_PROXY) $(OUT_CMAAS_AUDIT)