-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
294 lines (229 loc) · 8.81 KB
/
Makefile
File metadata and controls
294 lines (229 loc) · 8.81 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# Makefile for simple-dhcpd
# Portable across GNU make, BSD make, and BusyBox make: no ifeq/define/$(shell).
# Platform logic lives in scripts/platform-env.sh + scripts/mk-impl.sh (POSIX sh).
#
# Copyright 2024 SimpleDaemons <info@simpledaemons.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
PROJECT_NAME = simple-dhcpd
# Keep in sync with CMakeLists.txt project(... VERSION ...)
VERSION = 0.6.0
BUILD_DIR = build
DIST_DIR = dist
PACKAGE_DIR = packaging
SRC_DIR = src
INCLUDE_DIR = include
CONFIG_DIR_SRC = config
SCRIPTS_DIR = scripts
DEPLOYMENT_DIR = deployment
# Optional overrides (passed into scripts/mk.sh)
PARALLEL_JOBS ?=
INSTALL_PREFIX ?=
MAKE ?= make
# Relative path: do not use $(CURDIR) — empty on some BSD/BusyBox makes → "/scripts/mk.sh".
MK_SH = ./scripts/mk.sh
# ROOT from the shell cwd when the recipe runs (correct with make -C dir).
# Environment passed to every mk.sh invocation (quote paths for spaces)
E = ROOT="$$(pwd)" MAKE="$(MAKE)" OS="$(OS)" SHELL="$(SHELL)" \
PROJECT_NAME="$(PROJECT_NAME)" VERSION="$(VERSION)" \
BUILD_DIR="$(BUILD_DIR)" DIST_DIR="$(DIST_DIR)" PACKAGE_DIR="$(PACKAGE_DIR)" \
SRC_DIR="$(SRC_DIR)" INCLUDE_DIR="$(INCLUDE_DIR)" CONFIG_DIR_SRC="$(CONFIG_DIR_SRC)" \
SCRIPTS_DIR="$(SCRIPTS_DIR)" DEPLOYMENT_DIR="$(DEPLOYMENT_DIR)" \
PARALLEL_JOBS="$(PARALLEL_JOBS)" INSTALL_PREFIX="$(INSTALL_PREFIX)"
.DEFAULT_GOAL := all
all: build
$(BUILD_DIR)-dir:
@env $(E) sh $(MK_SH) mkdir-build-dir
build: $(BUILD_DIR)-dir
@env $(E) sh $(MK_SH) build
clean:
@env $(E) sh $(MK_SH) clean
install: build
@env $(E) sh $(MK_SH) install
uninstall:
@env $(E) sh $(MK_SH) uninstall
test: build
@env $(E) sh $(MK_SH) test
package: build
@env $(E) sh $(MK_SH) package
dev-build: $(BUILD_DIR)-dir
@env $(E) sh $(MK_SH) dev-build
dev-test: dev-build
@env $(E) sh $(MK_SH) dev-test
static-build: $(BUILD_DIR)-dir
@env $(E) sh $(MK_SH) static-build
static-test: static-build
@env $(E) sh $(MK_SH) static-test
static-package: static-build
@env $(E) sh $(MK_SH) static-package
static-zip: static-build
@env $(E) sh $(MK_SH) static-zip
static-all: static-package static-zip
@echo "All static binary packages created successfully"
@echo "Static binary packages:"
@ls -la "$(DIST_DIR)"/$(PROJECT_NAME)-$(VERSION)-static-* 2>/dev/null || echo "No static binary packages found"
format:
@env $(E) sh $(MK_SH) format
check-style:
@env $(E) sh $(MK_SH) check-style
lint: check-style
@env $(E) sh $(MK_SH) lint
security-scan:
@env $(E) sh $(MK_SH) security-scan
deps:
@env $(E) sh $(MK_SH) deps
dev-deps:
@env $(E) sh $(MK_SH) dev-deps
docker-build:
docker build -t $(PROJECT_NAME):$(VERSION) .
docker-run:
docker run -d --name $(PROJECT_NAME)-$(VERSION) -p 67:67 $(PROJECT_NAME):$(VERSION)
docker-stop:
docker stop $(PROJECT_NAME)-$(VERSION)
docker rm $(PROJECT_NAME)-$(VERSION)
service-install: install
@env $(E) sh $(MK_SH) service-install
service-status:
@env $(E) sh $(MK_SH) service-status
help:
@echo "A lightweight and secure DHCP server daemon - Main Help"
@echo "=================================="
@echo ""
@echo "Essential targets:"
@echo " all - Build the project (default)"
@echo " build - Build using CMake"
@echo " clean - Clean build files"
@echo " install - Install the project"
@echo " uninstall - Uninstall the project"
@echo " test - Run tests"
@echo " package - Build platform-specific packages"
@echo " package-source - Create source code packages (TAR.GZ + ZIP)"
@echo " package-all - Create all packages (binary + source)"
@echo " package-info - Show package information"
@echo ""
@echo "Development targets:"
@echo " dev-build - Build in debug mode"
@echo " dev-test - Run tests in debug mode"
@echo " format - Format source code"
@echo " lint - Run static analysis"
@echo " security-scan - Run security scanning tools"
@echo ""
@echo "Static binary targets:"
@echo " static-build - Build static binary (self-contained)"
@echo " static-test - Run tests on static binary"
@echo " static-package - Create platform-specific static binary package"
@echo " static-zip - Create static binary ZIP package"
@echo " static-all - Create all static binary formats"
@echo ""
@echo "Dependency management:"
@echo " deps - Install dependencies"
@echo " dev-deps - Install development tools"
@echo ""
@echo "Service management:"
@echo " service-install - Install system service"
@echo " service-status - Check service status"
@echo " service-start - Start service"
@echo " service-stop - Stop service"
@echo ""
@echo "Help categories:"
@echo " help-all - Show all available targets"
@echo " help-build - Build and development targets"
@echo " help-package - Package creation targets"
@echo " help-deps - Dependency management targets"
@echo " help-service - Service management targets"
@echo " help-docker - Docker targets"
@echo " help-config - Configuration management targets"
@echo " help-platform - Platform-specific targets"
@echo ""
@echo "Examples:"
@echo " make build - Build the project"
@echo " make test - Build and run tests"
@echo " make package - Create platform-specific packages"
@echo " make dev-deps - Install development tools"
@echo " make help-all - Show all available targets"
help-all:
@env $(E) sh $(MK_SH) help-all
help-build:
@echo "Build: all, build, clean, install, uninstall, test, dev-build, dev-test,"
@echo "static-build, static-test, static-package, static-zip, static-all, format, check-style, lint, security-scan"
help-package:
@echo "Package: package, package-source, package-all, package-info, package-deb, package-rpm,"
@echo "package-msi, package-exe, package-dmg, package-pkg, package-tgz"
help-deps:
@echo "Dependencies: deps, dev-deps"
help-service:
@echo "Service: service-install, service-uninstall, service-status, service-start, service-stop,"
@echo "service-restart, service-enable, service-disable (plus legacy start/stop/restart/status)"
help-docker:
@echo "Docker: docker-build, docker-run, docker-stop"
help-config:
@echo "Config: config-install, config-backup, log-rotate, backup, restore, distclean"
help-platform:
@echo "Platform detection runs inside scripts (Windows, macOS, Linux, FreeBSD). Override: PARALLEL_JOBS=8 make build"
package-source: build
@env $(E) sh $(MK_SH) package-source
package-all: package package-source
@echo "All packages created successfully"
@echo "Binary packages:"
@ls -la "$(DIST_DIR)"/$(PROJECT_NAME)-$(VERSION)-*.* 2>/dev/null || echo "No binary packages found"
@echo "Source packages:"
@ls -la "$(DIST_DIR)"/$(PROJECT_NAME)-$(VERSION)-src.* 2>/dev/null || echo "No source packages found"
package-deb: build
@env $(E) sh $(MK_SH) package-deb
package-rpm: build
@env $(E) sh $(MK_SH) package-rpm
package-msi: build
@env $(E) sh $(MK_SH) package-msi
package-exe: build
@env $(E) sh $(MK_SH) package-exe
package-dmg: build
@env $(E) sh $(MK_SH) package-dmg
package-pkg: build
@env $(E) sh $(MK_SH) package-pkg
package-tgz: build
@env $(E) sh $(MK_SH) package-tgz
package-info:
@env $(E) sh $(MK_SH) package-info
debug: dev-build
release: build
sanitize: dev-build
rebuild: clean build
test-verbose: test
start: service-start
stop: service-stop
restart: service-restart
status: service-status
service-start:
@env $(E) sh $(MK_SH) service-start
service-stop:
@env $(E) sh $(MK_SH) service-stop
service-restart:
@env $(E) sh $(MK_SH) service-restart
service-enable:
@env $(E) sh $(MK_SH) service-enable
service-disable:
@env $(E) sh $(MK_SH) service-disable
service-uninstall:
@env $(E) sh $(MK_SH) service-uninstall
config-install: install
@env $(E) sh $(MK_SH) config-install
config-backup:
@env $(E) sh $(MK_SH) config-backup
log-rotate: install
@env $(E) sh $(MK_SH) log-rotate
backup: config-backup
@env $(E) sh $(MK_SH) backup
restore: backup
@env $(E) sh $(MK_SH) restore
distclean: clean
@env $(E) sh $(MK_SH) distclean
.PHONY: all build clean install uninstall test package package-source package-all \
package-deb package-rpm package-msi package-exe package-dmg package-pkg package-tgz package-info \
static-build static-test static-package static-zip static-all \
dev-build dev-test format check-style lint security-scan deps dev-deps \
docker-build docker-run docker-stop service-install service-uninstall service-status \
service-start service-stop service-restart service-enable service-disable \
config-install config-backup log-rotate backup restore distclean \
debug release sanitize rebuild test-verbose start stop restart status \
help help-all help-build help-package help-deps help-service help-docker help-config help-platform