File: Makefile

package info (click to toggle)
hcxtools 7.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,152 kB
  • sloc: ansic: 21,223; python: 144; makefile: 101; sh: 99
file content (109 lines) | stat: -rw-r--r-- 2,527 bytes parent folder | download
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
PRODUCTION		:= 1
PRODUCTION_VERSION	:= 7.1.0
PRODUCTION_YEAR		:= 2026

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
DEFS		= -DVERSION_TAG=\"$(VERSION_TAG)\" -DVERSION_YEAR=\"$(VERSION_YEAR)\"
DEFS		+= -DWANTZLIB

INSTALL		?= install
INSTFLAGS	=
PKG_CONFIG ?= pkg-config

ifeq ($(HOSTOS), Linux)
INSTFLAGS += -D
endif

OPENSSL_LIBS=$(shell $(PKG_CONFIG) --libs openssl)
OPENSSL_CFLAGS=$(shell $(PKG_CONFIG) --cflags openssl)
CURL_LIBS=$(shell $(PKG_CONFIG) --libs libcurl)
CURL_CFLAGS=$(shell $(PKG_CONFIG) --cflags libcurl)
Z_LIBS=$(shell $(PKG_CONFIG) --libs zlib)
Z_CFLAGS=$(shell $(PKG_CONFIG) --cflags zlib)

TOOLS=
TOOLS+=hcxpcapngtool
hcxpcapngtool_libs=$(OPENSSL_LIBS) $(Z_LIBS)
hcxpcapngtool_cflags=$(OPENSSL_CFLAGS) $(Z_CFLAGS)
TOOLS+=hcxhashtool
hcxhashtool_libs=$(OPENSSL_LIBS) $(CURL_LIBS)
hcxhashtool_cflags=$(OPENSSL_CFLAGS) $(CURL_CFLAGS)
TOOLS+=hcxpsktool
hcxpsktool_libs=$(OPENSSL_LIBS)
hcxpsktool_cflags=$(OPENSSL_CFLAGS)
TOOLS+=hcxpmktool
hcxpmktool_libs=$(OPENSSL_LIBS)
hcxpmktool_cflags=$(OPENSSL_CFLAGS)
TOOLS+=hcxpottool
hcxpottool_libs=$(OPENSSL_LIBS)
hcxpottool_cflags=$(OPENSSL_CFLAGS)
TOOLS+=hcxeiutool
TOOLS+=hcxwltool
TOOLS+=hcxhash2cap
TOOLS+=wlancap2wpasec
wlancap2wpasec_libs=$(OPENSSL_LIBS) $(CURL_LIBS)
wlancap2wpasec_cflags=$(OPENSSL_CFLAGS) $(CURL_CFLAGS)
TOOLS+=whoismac
whoismac_libs=$(OPENSSL_LIBS) $(CURL_LIBS)
whoismac_cflags=$(OPENSSL_CFLAGS) $(CURL_CFLAGS)

.PHONY: all build install clean uninstall

all: build

build: $(TOOLS)

.deps:
	mkdir -p .deps

# $1: tool name
define tool-build
$(1)_src ?= $(1).c
$(1)_libs ?=
$(1)_cflags ?=

$(1): $$($(1)_src) | .deps
	$$(CC) $$(CFLAGS) $$($(1)_cflags) $$(CPPFLAGS) -MMD -MF .deps/$$@.d -o $$@ $$($(1)_src) $$($(1)_libs) $$(LDFLAGS) $$(DEFS)

.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