-
Notifications
You must be signed in to change notification settings - Fork 398
/
Makefile
85 lines (62 loc) · 1.65 KB
/
Makefile
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
PRODUCTION := 0
PRODUCTION_VERSION := 6.3.5
PRODUCTION_YEAR := 2024
ifeq ($(PRODUCTION),1)
VERSION_TAG := $(PRODUCTION_VERSION)
else
VERSION_TAG := $(shell git describe --tags || echo $(PRODUCTION_VERSION))
endif
VERSION_YEAR := $(shell echo $(PRODUCTION_YEAR))
PREFIX ?= /usr
BINDIR = $(DESTDIR)$(PREFIX)/bin
HOSTOS := $(shell uname -s)
CC ?= gcc
CFLAGS ?= -O3 -Wall -Wextra -Wpedantic
CFLAGS += -std=gnu99
# uncomment to enable DEBUG symbols
#CFLAGS += -ggdb -fsanitize=address
DEFS = -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_YEAR=\"$(VERSION_YEAR)\"
# comment to disable STATUS display (headless operation)
DEFS += -DHCXSTATUSOUT
# comment to disable GPS support
DEFS += -DHCXNMEAOUT
# uncomment to enable BPF compiler
DEFS += -DHCXWANTLIBPCAP
LDFLAGS += -lpcap
# uncomment to enable DEBUG log
#DEFS += -DHCXDEBUG
INSTALL ?= install
INSTFLAGS =
ifeq ($(HOSTOS), Linux)
INSTFLAGS += -D
endif
TOOLS=hcxdumptool
.PHONY: all build install clean uninstall
all: build
build: $(TOOLS)
# $1: tool name
define tool-build
$(1)_src ?= $(1).c
$(1)_libs ?=
$(1)_cflags ?=
$(1): $$($(1)_src)
$$(CC) $$(CFLAGS) $$($(1)_cflags) $$(CPPFLAGS) -o $$@ $$($(1)_src) $$(DEFS) $$(LDFLAGS)
.deps/$(1).d: $(1)
.PHONY: $(1).install
$(1).install: $(1)
$$(INSTALL) $$(INSTFLAGS) -m 0755 $(1) $$(BINDIR)/$(1)
.PHONY: $(1).clean
$(1).clean:
rm -f .deps/$(1).d
rm -f $(1)
.PHONY: $(1).uninstall
$(1).uninstall:
rm -rf $$(BINDIR)/$(1)
endef
$(foreach tool,$(TOOLS),$(eval $(call tool-build,$(tool))))
install: $(patsubst %,%.install,$(TOOLS))
clean: $(patsubst %,%.clean,$(TOOLS))
rm -rf .deps
rm -f *.o *~
uninstall: $(patsubst %,%.uninstall,$(TOOLS))
-include .deps/*.d