Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (53 loc) · 1.93 KB
/
Copy pathMakefile
File metadata and controls
63 lines (53 loc) · 1.93 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
APP_NAME = step-ca
SUDO := $(shell if [ $$(id -u) -ne 0 ]; then echo "$(SUDO)"; else echo ""; fi)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME ?= $(shell date -u '+%Y-%m-%d %H:%M UTC')
# Targets
.PHONY: all clean check-deps dev build
default: build
test:
go test -race ./externalcas
clean:
@echo "Cleaning build cache..."
go clean -cache
rm -f step-ca
rm -rf db
check-deps:
@echo "Checking for libpcsclite-dev dependency..."
@OS_NAME=$$(uname -s); \
if [ "$$OS_NAME" = "Darwin" ]; then \
echo "🍎 MacOS - Skipping dependency check"; \
elif [ -f /etc/os-release ]; then \
. /etc/os-release; \
if echo "$$ID" | grep -Eqi 'ubuntu|debian'; then \
if ! dpkg -s libpcsclite-dev >/dev/null 2>&1 || ! command -v pkg-config >/dev/null 2>&1; then \
echo "📦 Installing libpcsclite-dev and pkg-config on Debian/Ubuntu..."; \
$(SUDO) apt-get update && $(SUDO) apt-get install -y libpcsclite-dev pkg-config; \
fi; \
elif echo "$$ID" | grep -Eqi 'rhel|rocky|centos'; then \
if ! rpm -q pcsc-lite-devel >/dev/null 2>&1 || ! command -v pkg-config >/dev/null 2>&1; then \
echo "📦 Installing pcsc-lite-devel and pkgconfig on Rocky/RHEL..."; \
$(SUDO) dnf install -y pcsc-lite-devel pkgconfig; \
fi; \
else \
echo "⚠️ Unknown Linux distribution: $$ID. You may need to install some dependencies manually."; \
fi; \
else \
echo "Cannot detect OS. /etc/os-release not found."; \
exit 1; \
fi
dev: clean check-deps
@echo "Setting up dependencies for development..."
mkdir db
go mod tidy
@echo "✔ OK"
build: clean check-deps
@echo "Building acme-proxy with step-ca..."
mkdir db
go build -ldflags="-s -w -X main.Version=$(VERSION) -X 'main.BuildTime=$(BUILD_TIME)'" -v -o $(APP_NAME) .
@echo "✔ OK"
debug: clean check-deps
mkdir db
go build \
-ldflags="-X main.Version=$(VERSION) -X 'main.BuildTime=$(BUILD_TIME)'" \
-gcflags="all=-N -l" -o $(APP_NAME) .