-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
235 lines (204 loc) · 9.72 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
## Whistlepig Makefile
## Copyright (c) 2011 William Morgan <[email protected]>
## Whistlepig is released under the three-clause BSD license. See the COPYING
## file for terms.
LEX=flex
YACC=bison
CC=gcc
RUBY=/usr/bin/ruby
ECHO=/bin/echo
## stolen from redis
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
OPTIMIZATION?=-O3
CFLAGS?= -std=c99 $(OPTIMIZATION) -Wall -Wextra -Wwrite-strings -Werror -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -D_ANSI_SOURCE -D_XOPEN_SOURCE=600
ifeq ($(uname_S),Darwin)
CFLAGS:=$(CFLAGS) -Wshorten-64-to-32
endif
CCLINK?= -pthread
CCOPT= $(CFLAGS) $(CCLINK) $(ARCH) $(PROF)
DEBUG?= -rdynamic -ggdb
TESTFILES = test-segment.c test-stringmap.c test-stringpool.c test-termhash.c test-search.c test-labels.c test-tokenizer.c test-queries.c test-snippets.c
CSRCFILES = segment.c termhash.c stringmap.c error.c query.c search.c stringpool.c mmap-obj.c query-parser.c index.c entry.c lock.c snippeter.c
HEADERFILES = $(CSRCFILES:.c=.h) defaults.h whistlepig.h khash.h rarray.h
LEXFILES = tokenizer.lex query-parser.lex
YFILES = query-parser.y
GENFILES = $(LEXFILES:.lex=.lex.c) $(LEXFILES:.lex=.lex.h) $(YFILES:.y=.tab.c) $(YFILES:.y=.tab.h)
OBJ = $(CSRCFILES:.c=.o) $(LEXFILES:.lex=.lex.o) $(YFILES:.y=.tab.o)
QUERYBIN=query
DUMPBIN=dump
ADDBIN=add
MBOXADDBIN=addmbox
TESTBIN = $(TESTFILES:.c=)
ALLBIN=$(QUERYBIN) $(DUMPBIN) $(ADDBIN) $(MBOXADDBIN) batch-run-queries benchmark-queries
all: $(ALLBIN)
## remove implicit rules because they fuck with my shit
.SUFFIXES:
loc: $(CSRCFILES) $(LEXFILES) $(YFILES) $(HEADERFILES)
sloccount $+
## deps (use `make dep` to generate this (in vi: :r !make dep)
batch-run-queries.o: batch-run-queries.c whistlepig.h defaults.h index.h \
segment.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h entry.h khash.h rarray.h query-parser.h lock.h snippeter.h \
timer.h
benchmark-queries.o: benchmark-queries.c whistlepig.h defaults.h index.h \
segment.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h entry.h khash.h rarray.h query-parser.h lock.h snippeter.h \
timer.h
dump.o: dump.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h
entry.o: entry.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h tokenizer.lex.h
error.o: error.c error.h
file-indexer.o: file-indexer.c timer.h whistlepig.h defaults.h index.h \
segment.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
index.o: index.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h
interactive.o: interactive.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h timer.h
lock.o: lock.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h
make-queries.o: make-queries.c tokenizer.lex.h segment.h defaults.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h
mbox-indexer.o: mbox-indexer.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h timer.h
mmap-obj.o: mmap-obj.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
query-parser.o: query-parser.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h \
query-parser.tab.h
query-parser.lex.o: query-parser.lex.c whistlepig.h defaults.h index.h \
segment.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h entry.h khash.h rarray.h query-parser.h lock.h snippeter.h \
query-parser.tab.h
query-parser.tab.o: query-parser.tab.c query.h segment.h defaults.h \
stringmap.h stringpool.h error.h termhash.h search.h mmap-obj.h \
query-parser.h query-parser.tab.h
query.o: query.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h
search.o: search.c whistlepig.h defaults.h index.h segment.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h entry.h \
khash.h rarray.h query-parser.h lock.h snippeter.h
segment.o: segment.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
snippeter.o: snippeter.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h \
tokenizer.lex.h
stringmap.o: stringmap.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
stringpool.o: stringpool.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
termhash.o: termhash.c whistlepig.h defaults.h index.h segment.h \
stringmap.h stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
test-labels.o: test-labels.c test.h query.h segment.h defaults.h \
stringmap.h stringpool.h error.h termhash.h search.h mmap-obj.h \
query-parser.h index.h entry.h khash.h rarray.h
test-labels_main.o: test-labels_main.c error.h test.h
test-queries.o: test-queries.c test.h query.h segment.h defaults.h \
stringmap.h stringpool.h error.h termhash.h search.h mmap-obj.h \
query-parser.h
test-queries_main.o: test-queries_main.c error.h test.h
test-search.o: test-search.c test.h query.h segment.h defaults.h \
stringmap.h stringpool.h error.h termhash.h search.h mmap-obj.h \
query-parser.h index.h entry.h khash.h rarray.h
test-search_main.o: test-search_main.c error.h test.h
test-segment.o: test-segment.c test.h segment.h defaults.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h \
tokenizer.lex.h index.h entry.h khash.h rarray.h
test-segment_main.o: test-segment_main.c error.h test.h
test-snippets.o: test-snippets.c test.h whistlepig.h defaults.h index.h \
segment.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h entry.h khash.h rarray.h query-parser.h lock.h snippeter.h
test-stringmap.o: test-stringmap.c stringmap.h stringpool.h error.h \
test.h
test-stringpool.o: test-stringpool.c stringpool.h error.h test.h
test-stringpool_main.o: test-stringpool_main.c error.h test.h
test-termhash.o: test-termhash.c termhash.h error.h test.h
test-termhash_main.o: test-termhash_main.c error.h test.h
test-tokenizer.o: test-tokenizer.c test.h tokenizer.lex.h segment.h \
defaults.h stringmap.h stringpool.h error.h termhash.h query.h search.h \
mmap-obj.h
test-tokenizer_main.o: test-tokenizer_main.c error.h test.h
tokenizer.lex.o: tokenizer.lex.c segment.h defaults.h stringmap.h \
stringpool.h error.h termhash.h query.h search.h mmap-obj.h
benchmark-queries: benchmark-queries.o $(OBJ)
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
batch-run-queries: batch-run-queries.o $(OBJ)
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
$(QUERYBIN): $(OBJ) interactive.o
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
$(ADDBIN): $(OBJ) file-indexer.o
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
$(MBOXADDBIN): $(OBJ) mbox-indexer.o
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
$(DUMPBIN): $(OBJ) dump.o
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
test-%_main.c: test-%.c
@$(ECHO) MAGIC $<
@$(RUBY) build/gen-test-main.rb $+ > $@
test-%: test-%.o test-%_main.o $(OBJ)
@$(ECHO) LINK $@
@$(CC) -o $@ $(CCOPT) $(DEBUG) $+
## these next two rules are to ignore warnings in generated c code
tokenizer.lex.o: tokenizer.lex.c
@$(ECHO) CC \(ignore warnings\) $<
@$(CC) -c $(CFLAGS) $(DEBUG) $(DEBUGOUTPUT) $(COMPILE_TIME) -w $<
query-parser.lex.o: query-parser.lex.c
@$(ECHO) CC \(ignore warnings\) $<
@$(CC) -c $(CFLAGS) $(DEBUG) $(DEBUGOUTPUT) $(COMPILE_TIME) -w $<
## object compilation
%.o: %.c
@$(ECHO) CC $<
@$(CC) -c $(CFLAGS) $(DEBUG) $(DEBUGOUTPUT) $(COMPILE_TIME) $<
%.lex.c %.lex.h: %.lex
@$(ECHO) LEX $+
$(LEX) $<
%.tab.c %.tab.h: %.y
@$(ECHO) YACC $+
$(YACC) $<
clean:
rm -rf $(TESTBIN) *.o *.gcda *.gcno *.gcov $(GENFILES) $(ALLBIN)
dep: $(GENFILES)
$(CC) -MM *.c
test: $(TESTBIN)
./test-segment
./test-stringmap
./test-stringpool
./test-termhash
./test-search
./test-labels
./test-queries
./test-snippets
integration-tests/enron1m.index0.pr: integration-tests/enron1m.mbox $(MBOXADDBIN) $(OBJ)
rm -f integration-tests/enron1m.index*
./$(MBOXADDBIN) integration-tests/enron1m.index integration-tests/enron1m.mbox
test-integration: batch-run-queries integration-tests/enron1m.index0.pr
ruby integration-tests/eval.rb integration-tests/testset1.txt
debug:
make DEBUGOUTPUT=-DDEBUGOUTPUT
EXPORTFILES=$(CSRCFILES) $(HEADERFILES) $(GENFILES)
rubygem: $(EXPORTFILES)
cp README COPYING ruby
cp $+ ruby/ext/whistlepig
cd ruby && rake gem
@echo gem is in ruby/pkg/