-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (74 loc) · 4.06 KB
/
Copy pathMakefile
File metadata and controls
89 lines (74 loc) · 4.06 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
77
78
79
80
81
82
83
84
85
86
87
88
89
# ──────────────────────────────────────────────────────────────────────────────
# Makefile — build all Go sub‑modules when their code changes
# ──────────────────────────────────────────────────────────────────────────────
# where we’ll drop the binaries
BINDIR := $(HOME)/go/bin
# cross‑compile settings (exported for every go build)
GOOS := linux
GOARCH := amd64
CGO_ENABLED := 0
export GOOS GOARCH CGO_ENABLED
# collect .go files in each package
APIS_SRCS := $(wildcard apis/*.go)
DB_SRCS := $(wildcard db/*.go)
UPDATER_SRCS := $(shell find updater -name '*.go')
OBJUPDATER_SRCS := $(wildcard objupdater/*.go)
PROVISIONER_SRCS := $(wildcard provisioner/*.go)
# ─── Phony targets ────────────────────────────────────────────────────────────
.PHONY: all clean apis dbtool updater objupdater provisioner config
all: $(BINDIR) \
$(BINDIR)/apis \
$(BINDIR)/dbtool \
$(BINDIR)/updater \
$(BINDIR)/objupdater \
$(BINDIR)/provisioner
# ensure bin/ exists
$(BINDIR):
mkdir -p $@
# ─── Build rules ──────────────────────────────────────────────────────────────
# apis
$(BINDIR)/apis: $(APIS_SRCS) | $(BINDIR)
@echo "Building apis → $@"
cd apis && go build -o $(BINDIR)/apis
# dbtool
$(BINDIR)/dbtool: $(DB_SRCS) | $(BINDIR)
@echo "Building dbtool → $@"
cd db && go build -o $(BINDIR)/dbtool
# updater
$(BINDIR)/updater: $(UPDATER_SRCS) | $(BINDIR)
@echo "Building updater → $@"
cd updater && go build -o $(BINDIR)/updater
#
# objupdater
$(BINDIR)/objupdater: $(OBJUPDATER_SRCS) | $(BINDIR)
@echo "Building objupdater → $@"
cd objupdater && go build -o $(BINDIR)/objupdater
# provision‑sensor
$(BINDIR)/provisioner: $(PROVISIONER_SRCS) | $(BINDIR)
@echo "Building provisioner → $@"
cd provisioner && go build -o $(BINDIR)/provisioner
# ─── Install ─────────────────────────────────────────────────────────────────
install:
sudo cp $(BINDIR)/apis /usr/local/bin
sudo cp $(BINDIR)/dbtool /usr/local/bin
sudo cp $(BINDIR)/updater /usr/local/bin
sudo cp $(BINDIR)/objupdater /usr/local/bin
sudo cp $(BINDIR)/provisioner /usr/local/bin
# ─── Config ─────────────────────────────────────────────────────────────────
config:
sudo mkdir -p /opt/config/nginx /opt/config/scripts /opt/config/supervisor /opt/config/provisioner /opt/config/logrotate.d
sudo cp config/db.json config/db_dev.json config/auth.json /opt/config/
sudo cp config/minio.json /opt/config/
sudo cp config/filebeat.yml /opt/config/
sudo cp db/schema_pg_v3.sql /opt/config/
sudo cp nginx/nginx.conf /opt/config/nginx/
sudo cp config/provisioner/* /opt/config/provisioner/
sudo cp config/scripts/* /opt/config/scripts/
sudo cp config/supervisor/* /opt/config/supervisor/
sudo cp config/logrotate.d/securite /opt/config/logrotate.d/
# ─── Install Utils ─────────────────────────────────────────────────────────────────
install-utils:
sudo cp utils/* /usr/local/bin
# ─── Cleanup ─────────────────────────────────────────────────────────────────
clean:
rm -rf $(BINDIR)