-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
251 lines (224 loc) · 10 KB
/
Makefile
File metadata and controls
251 lines (224 loc) · 10 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# Makefile for ionis-apps
#
# High-performance Go applications for IONIS WSPR/Solar data processing
#
# Usage:
# make # Show help
# make all # Build all binaries
# make install # Install to system (requires sudo)
# make test # Run tests
# make clean # Remove build artifacts
SHELL := /bin/bash
.PHONY: help all build install uninstall test clean lint fmt vet wspr solar contest pskr
# =============================================================================
# Package Metadata
# =============================================================================
NAME := ionis-apps
VERSION := $(shell cat VERSION 2>/dev/null || echo "0.0.0")
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# =============================================================================
# Go Configuration (CPU-only, static binaries)
# =============================================================================
GO := go
GOFLAGS := -trimpath
CGO_ENABLED := 0
LDFLAGS := -s -w \
-X main.Version=$(VERSION) \
-X main.GitCommit=$(GIT_COMMIT) \
-X main.BuildDate=$(BUILD_DATE)
# =============================================================================
# Installation Paths (FHS-compliant)
# =============================================================================
PREFIX := /usr
BINDIR := $(PREFIX)/bin
DATADIR := $(PREFIX)/share/$(NAME)
SYSCONFDIR := /etc/$(NAME)
# =============================================================================
# Build Directories
# =============================================================================
BINDIR_BUILD := bin
DISTDIR := dist
# =============================================================================
# Commands to Build
# =============================================================================
# Note: Legacy tools (wspr-ingest, wspr-ingest-cpu, wspr-ingest-fast) removed
# due to clickhouse-go/v2 API incompatibility. Replaced by faster tools.
WSPR_CMDS := wspr-shredder wspr-turbo wspr-parquet-native wspr-download
SOLAR_CMDS := solar-ingest solar-download solar-backfill dscovr-ingest
CONTEST_CMDS := contest-download rbn-download rbn-ingest contest-ingest
PSKR_CMDS := pskr-collector pskr-ingest
UTIL_CMDS := db-validate
ALL_CMDS := $(WSPR_CMDS) $(SOLAR_CMDS) $(CONTEST_CMDS) $(PSKR_CMDS) $(UTIL_CMDS)
# Shell scripts to install
SOLAR_SCRIPTS := solar-refresh.sh solar-live-update.sh solar-history-load.sh
# =============================================================================
# Default Target
# =============================================================================
.DEFAULT_GOAL := help
help:
@printf "\n"
@printf "┌─────────────────────────────────────────────────────────────────┐\n"
@printf "│ ionis-apps v$(VERSION) │\n"
@printf "│ High-Performance WSPR/Solar Data Ingestion Tools │\n"
@printf "└─────────────────────────────────────────────────────────────────┘\n"
@printf "\n"
@printf "WSPR Ingestion Tools:\n"
@printf " wspr-shredder Uncompressed CSV ingester (14.4 Mrps)\n"
@printf " wspr-turbo Streaming .gz ingester (8.8 Mrps)\n"
@printf " wspr-parquet-native Parquet file ingester (8.4 Mrps)\n"
@printf " wspr-download WSPR archive downloader\n"
@printf "\n"
@printf "Solar Tools:\n"
@printf " solar-download Multi-source solar data downloader\n"
@printf " solar-ingest Solar/geomagnetic data ingester\n"
@printf " solar-refresh Download + ingest pipeline script\n"
@printf " dscovr-ingest DSCOVR L1 solar wind ingester (Bz/speed/density)\n"
@printf "\n"
@printf "Contest Tools:\n"
@printf " contest-download CQ contest Cabrillo log downloader\n"
@printf " rbn-download Reverse Beacon Network archive downloader\n"
@printf " rbn-ingest RBN ZIP→CSV→ClickHouse ingester\n"
@printf " contest-ingest Cabrillo log→ClickHouse ingester\n"
@printf "\n"
@printf "PSK Reporter Tools:\n"
@printf " pskr-collector MQTT real-time spot collector\n"
@printf " pskr-ingest JSONL→ClickHouse incremental ingester\n"
@printf "\n"
@printf "Utility Tools:\n"
@printf " db-validate Validate ClickHouse table row counts\n"
@printf "\n"
@printf "Usage: make [target]\n"
@printf "\n"
@printf "Targets:\n"
@printf " help Show this help message\n"
@printf " all Build all binaries\n"
@printf " wspr Build WSPR binaries only\n"
@printf " solar Build Solar binaries only\n"
@printf " contest Build Contest binaries only\n"
@printf " pskr Build PSK Reporter binaries only\n"
@printf " install Install to system (PREFIX=$(PREFIX))\n"
@printf " uninstall Remove installed files\n"
@printf " test Run Go tests\n"
@printf " lint Run golangci-lint\n"
@printf " fmt Format Go code\n"
@printf " vet Run go vet\n"
@printf " clean Remove build artifacts\n"
@printf " deps Download dependencies\n"
@printf "\n"
@printf "Variables:\n"
@printf " PREFIX Installation prefix (default: /usr)\n"
@printf " DESTDIR Staging directory for packaging\n"
@printf "\n"
@printf "Examples:\n"
@printf " make all # Build everything\n"
@printf " sudo make install # Install to /usr/bin\n"
@printf " DESTDIR=/tmp/stage make install # Stage for RPM packaging\n"
@printf "\n"
# =============================================================================
# Build Targets
# =============================================================================
all: $(addprefix $(BINDIR_BUILD)/,$(ALL_CMDS))
@printf "\nBuild complete:\n"
@for cmd in $(ALL_CMDS); do printf " $(BINDIR_BUILD)/$$cmd\n"; done
wspr: $(addprefix $(BINDIR_BUILD)/,$(WSPR_CMDS))
@printf "\nWSPR tools built:\n"
@for cmd in $(WSPR_CMDS); do printf " $(BINDIR_BUILD)/$$cmd\n"; done
solar: $(addprefix $(BINDIR_BUILD)/,$(SOLAR_CMDS))
@printf "\nSolar tools built:\n"
@for cmd in $(SOLAR_CMDS); do printf " $(BINDIR_BUILD)/$$cmd\n"; done
contest: $(addprefix $(BINDIR_BUILD)/,$(CONTEST_CMDS))
@printf "\nContest tools built:\n"
@for cmd in $(CONTEST_CMDS); do printf " $(BINDIR_BUILD)/$$cmd\n"; done
pskr: $(addprefix $(BINDIR_BUILD)/,$(PSKR_CMDS))
@printf "\nPSK Reporter tools built:\n"
@for cmd in $(PSKR_CMDS); do printf " $(BINDIR_BUILD)/$$cmd\n"; done
# Generic build rule for all commands
$(BINDIR_BUILD)/%: cmd/%/main.go | $(BINDIR_BUILD)
@printf "Building $*...\n"
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ ./cmd/$*
# Create build directory
$(BINDIR_BUILD):
@mkdir -p $(BINDIR_BUILD)
# =============================================================================
# Dependencies
# =============================================================================
deps:
@printf "Downloading dependencies...\n"
$(GO) mod download
$(GO) mod tidy
$(GO) mod verify
@printf "Dependencies ready.\n"
# =============================================================================
# Code Quality
# =============================================================================
fmt:
@printf "Formatting Go code...\n"
$(GO) fmt ./...
vet:
@printf "Running go vet...\n"
$(GO) vet ./...
lint:
@printf "Running golangci-lint...\n"
@if command -v golangci-lint &>/dev/null; then \
golangci-lint run ./...; \
else \
printf "golangci-lint not installed, skipping.\n"; \
fi
# =============================================================================
# Testing
# =============================================================================
test:
@printf "Running tests...\n"
$(GO) test -v -race -coverprofile=coverage.out ./...
@printf "\nTest coverage:\n"
$(GO) tool cover -func=coverage.out | tail -1
test-short:
@printf "Running short tests...\n"
$(GO) test -short -v ./...
# =============================================================================
# Installation
# =============================================================================
install: all
@printf "Installing $(NAME) v$(VERSION) to $(DESTDIR)$(PREFIX)...\n"
@printf "\n"
install -d $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(DATADIR)
install -d $(DESTDIR)$(SYSCONFDIR)
@for cmd in $(ALL_CMDS); do \
printf " Installing $$cmd...\n"; \
install -m 755 $(BINDIR_BUILD)/$$cmd $(DESTDIR)$(BINDIR)/; \
done
@for script in $(SOLAR_SCRIPTS); do \
printf " Installing $${script%.sh}...\n"; \
install -m 755 scripts/$$script $(DESTDIR)$(BINDIR)/$${script%.sh}; \
done
@printf "\nInstalled $(words $(ALL_CMDS)) binaries + $(words $(SOLAR_SCRIPTS)) scripts to $(DESTDIR)$(BINDIR)/\n"
uninstall:
@printf "Uninstalling $(NAME) from $(DESTDIR)$(PREFIX)...\n"
@for cmd in $(ALL_CMDS); do \
rm -f $(DESTDIR)$(BINDIR)/$$cmd; \
done
@for script in $(SOLAR_SCRIPTS); do \
rm -f $(DESTDIR)$(BINDIR)/$${script%.sh}; \
done
rm -rf $(DESTDIR)$(DATADIR)
rm -rf $(DESTDIR)$(SYSCONFDIR)
@printf "Uninstall complete.\n"
# =============================================================================
# Packaging
# =============================================================================
dist: clean all
@printf "Creating distribution archive...\n"
mkdir -p $(DISTDIR)
tar -czvf $(DISTDIR)/$(NAME)-$(VERSION)-linux-amd64.tar.gz \
-C $(BINDIR_BUILD) $(ALL_CMDS)
@printf "Created: $(DISTDIR)/$(NAME)-$(VERSION)-linux-amd64.tar.gz\n"
# =============================================================================
# Cleanup
# =============================================================================
clean:
@printf "Cleaning build artifacts...\n"
rm -rf $(BINDIR_BUILD) $(DISTDIR) build
rm -f coverage.out
@printf "Clean complete.\n"