-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (126 loc) · 4.16 KB
/
Makefile
File metadata and controls
144 lines (126 loc) · 4.16 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
project = NativeExtractor
project_libname = nativeextractor
flags = -std=c11 -D_GNU_SOURCE -pthread
links = glib-2.0
test_dir = build/tests
miners_install_dir = /usr/lib/nativeextractor_miners
main_path = src/main.c
# Use config=release for release builds
ifeq ($(config), release)
dir = build/release
flags := $(flags) -O4 -march=native
else
dir = build/debug
flags := $(flags) -O0 -g3 -DDEBUG
endif
ifeq ($(install), true)
flags := $(flags) -DNE_PRODUCTION
endif
.PHONY: clean
clean:
-rm *.o
-rm -f $(dir)/lib$(project).so $(dir)/$(project)_example
-rm -rf $(dir)/lib/
.PHONY: build
build:
-mkdir -p $(dir)
$(CC) $(flags) -fPIC -Iinclude -rdynamic \
`pkg-config --cflags $(links)` \
-c `find src/*.c -not -name "main.c"`
$(CC) -shared -o $(dir)/lib$(project_libname).so *.o
if [ -f "$(main_path)" ]; then \
gcc "$(main_path)" `pkg-config nativeextractor --libs --cflags` -o $(dir)/NativeExtractor; \
fi
.PHONY: examples
examples:
-mkdir -p $(dir)
make example name=glob
make example name=ngrep
make example name=naive_email_miner
# naive email miner as .so module
$(CC) $(flags) -DSO_MODULE `pkg-config --cflags $(links)` \
`pkg-config --libs $(links)` \
-Iinclude/ -shared -o $(dir)/naive_email_miner.so \
-fPIC src/example/naive_email_miner.c
.PHONY: miner
miner:
-mkdir -p $(dir)/lib/
$(CC) $(flags) `pkg-config --cflags $(links)` \
`pkg-config --libs $(links)` \
-Iinclude/ -shared -o $(dir)/lib/$(name).so \
-fPIC src/miners/$(name).c
.PHONY: example
example:
$(CC) $(flags) -Iinclude -rdynamic \
`pkg-config --cflags $(links)` \
src/example/$(name).c \
-L$(dir) -l$(project_libname) \
`pkg-config --libs $(links)` -ldl \
-o $(dir)/$(name)
.PHONY: all-miners
all-miners:
for f in src/miners/*.c; do \
make miner name=`basename $$f .c` config=$(config); \
done
.PHONY: install
install:
make config=release install=true build
make config=release install=true all-miners
rm -rf /usr/include/$(project_libname)/
mkdir -p /usr/include/$(project_libname)/
cp -rf ./include/$(project_libname)/ /usr/include/
mkdir -p /usr/lib/
rm -f /usr/lib/$(project_libname).so
cp build/release/lib$(project_libname).so /usr/lib/lib$(project_libname).so
mkdir -p $(miners_install_dir)
cp build/release/lib/* $(miners_install_dir)
ldconfig
mkdir -p /usr/lib/pkgconfig/
cp nativeextractor.pc /usr/lib/pkgconfig/
rm *.o
.PHONY: test
test:
-mkdir -p $(test_dir)
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/extractor.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_extractor \
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/patricia.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_patricia \
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/glob.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_glob \
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/finite_automaton.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_finite_automaton \
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/regex_miner.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_regex_miner \
$(CC) $(flags) -Iinclude -rdynamic \
`find ./src/ -maxdepth 1 -type f ! -name "main.c" -name "*.c"` tests/enclosed.c \
`pkg-config --cflags $(links)` \
`pkg-config --cflags --libs cmocka` \
`pkg-config --libs $(links)` -ldl \
-o $(test_dir)/$(project)_enclosed \
.PHONY: default
default: all-miners build
.PHONY: doc
doc:
-cd ./doc && git clone https://github.com/MaJerle/doxygen-dark-theme.git
doxygen ./doc/Doxyfile
.DEFAULT_GOAL := default