-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (31 loc) · 1.48 KB
/
Makefile
File metadata and controls
41 lines (31 loc) · 1.48 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
CC := gcc
PKG := pkg-config
TARGET := anyintruder
SRCS := any_intruder.c src/monitor.c src/logger.c src/ui.c src/file_utilities.c src/webhook/telegram.c src/platform_webhook.c src/http_client.c src/webhook/dingding.c src/webhook/discord.c src/webhook/wechat.c
OBJS := $(SRCS:.c=.o)
BREW_PCAP := $(shell command -v brew >/dev/null 2>&1 && brew --prefix libpcap 2>/dev/null || echo)
ifeq ($(BREW_PCAP),)
PKG_CONFIG_PATH :=
else
PKG_CONFIG_PATH := $(BREW_PCAP)/lib/pkgconfig:$(PKG_CONFIG_PATH)
export PKG_CONFIG_PATH
endif
PCAP_CFLAGS := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(PKG) --cflags libpcap 2>/dev/null || echo)
PCAP_LIBS := $(shell PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" $(PKG) --libs libpcap 2>/dev/null || echo)
NCURSES_CFLAGS := $(shell $(PKG) --cflags ncurses 2>/dev/null || echo)
NCURSES_LIBS := $(shell $(PKG) --libs ncurses 2>/dev/null || echo)
CFLAGS := -Wall -O2 -Iinclude $(shell pkg-config --cflags openssl) $(shell pkg-config --cflags libcurl) $(shell pkg-config --cflags json-c) -pthread $(PCAP_CFLAGS) $(NCURSES_CFLAGS)
LIBS := $(shell pkg-config --libs openssl) $(shell pkg-config --libs libcurl) $(shell pkg-config --libs json-c) $(PCAP_LIBS) $(NCURSES_LIBS)
ifeq ($(strip $(LIBS)),)
LIBS := -L/usr/local/opt/openssl/lib -lpcap -lncurses -lssl -lcrypto
endif
.PHONY: all run clean
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
run: all
./$(TARGET)
clean:
rm -f $(OBJS) $(TARGET) && rm -f $(TARGET).log