aboutsummaryrefslogtreecommitdiff
path: root/example/Makefile.in
blob: 79847087ad7759efd72e87d3425724c612f61a8a (plain)
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
CC=@CC@
CXX=@CXX@
BUILD_MINGW=@BUILD_MINGW@
DPDK_TARGET=@DPDK_TARGET@

BUILD_SRC=../src
ROOT_SRC=@srcdir@/../src
ROOT_EXAMPLES=@srcdir@

CFLAGS=-g -fPIC -DPIC -I$(ROOT_SRC)/include -I$(BUILD_SRC)/include @PCAP_INC@ @CFLAGS@
LIBNDPI=$(BUILD_SRC)/.libs/libndpi.a
LDFLAGS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ -lpthread @LDFLAGS@
HEADERS=$(ROOT_EXAMPLES)/intrusion_detection.h \
		$(ROOT_EXAMPLES)/reader_util.h \
		$(BUILD_SRC)/include/ndpi_api.h \
		$(ROOT_SRC)/include/ndpi_typedefs.h \
		$(ROOT_SRC)/include/ndpi_protocol_ids.h
OBJS=ndpiReader.o reader_util.o intrusion_detection.o
PREFIX?=@prefix@

ifneq ($(BUILD_MINGW),)
all:
	@echo 'Examples disabled due to mingw build.'

else

all: ndpiReader $(DPDK_TARGET)

libndpiReader.a: $(LIBNDPI) reader_util.o intrusion_detection.o
	ar rsv libndpiReader.a reader_util.o intrusion_detection.o

ndpiReader: libndpiReader.a ndpiReader.o
	$(CC) $(CFLAGS) ndpiReader.o -o $@ libndpiReader.a $(LDFLAGS)

ndpiSimpleIntegration: ndpiSimpleIntegration.o
	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

%.o: $(ROOT_EXAMPLES)/%.c $(HEADERS) Makefile
	$(CC) $(CFLAGS) -c $< -o $(notdir $@)

install: ndpiReader
	mkdir -p $(DESTDIR)$(PREFIX)/bin/
	mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi
	cp ndpiReader $(DESTDIR)$(PREFIX)/bin/
	cp $(ROOT_EXAMPLES)/protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt
	cp $(ROOT_EXAMPLES)/categories.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt
	cp $(ROOT_EXAMPLES)/mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomHosts.txt
	[ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
	[ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true

dpdk:
ifneq ($(DPDK_TARGET),)
	make -f Makefile.dpdk
else
	@echo 'Skipping. DPDK needs to be enabled during configure.'
endif

check:
	 cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force \
		-I$(ROOT_SRC)/include \
		-I$(BUILD_SRC)/include \
		-I. \
		$(ROOT_EXAMPLES)/*.c

clean:
	/bin/rm -f *.o ndpiReader ndpiReader.dpdk ndpiSimpleIntegration libndpiReader.a
	/bin/rm -f .*.dpdk.cmd .*.o.cmd *.dpdk.map .*.o.d
	/bin/rm -f _install _postbuild _postinstall _preinstall
	/bin/rm -rf build

distdir:
	cp \
		$(ROOT_EXAMPLES)/categories.txt \
		$(ROOT_EXAMPLES)/mining_hosts.txt \
		$(ROOT_EXAMPLES)/protos.txt \
		$(ROOT_EXAMPLES)/risky_domains.txt \
		$(ROOT_EXAMPLES)/ja3_fingerprints.csv \
		$(ROOT_EXAMPLES)/sha1_fingerprints.csv \
		$(ROOT_EXAMPLES)/README.DPDK \
		$(ROOT_EXAMPLES)/intrusion_detection.h \
		$(ROOT_EXAMPLES)/ndpiSimpleIntegration.c \
		$(ROOT_EXAMPLES)/reader_util.c \
		$(ROOT_EXAMPLES)/ndpiReader.c \
		$(ROOT_EXAMPLES)/ndpi2timeline.py \
		$(ROOT_EXAMPLES)/intrusion_detection.c \
		$(ROOT_EXAMPLES)/reader_util.h \
		'$(distdir)/'

distclean: clean
	/bin/rm -f Makefile.dpdk
	/bin/rm -f Makefile

endif