1BENCH_MODS = bench.so $(BENCH_ALGOS:%=bench-%.so)
2BENCH_ALGOS = wheel heap llrb
3BENCH_OPS = add del expire
4
5$(top_builddir)/bench/bench.so: $(top_srcdir)/bench/bench.c
6$(top_builddir)/bench/bench-wheel.so: $(top_srcdir)/bench/bench-wheel.c
7$(top_builddir)/bench/bench-heap.so: $(top_srcdir)/bench/bench-heap.c
8$(top_builddir)/bench/bench-llrb.so: $(top_srcdir)/bench/bench-llrb.c
9
10$(BENCH_MODS:%=$(top_builddir)/bench/%): $(top_srcdir)/timeout.h $(top_srcdir)/timeout.c $(top_srcdir)/bench/bench.h
11	mkdir -p $(@D)
12	@$(SHRC); echo_cmd $(CC) -o $@ $(top_srcdir)/bench/$(@F:%.so=%.c) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(ALL_SOFLAGS) $(ALL_LDFLAGS) $(ALL_LIBS)
13
14$(BENCH_OPS:%=$(top_builddir)/bench/wheel-%.dat): $(top_builddir)/bench/bench-wheel.so $(top_builddir)/bench/bench.so $(top_srcdir)/bench/bench-aux.lua
15$(BENCH_OPS:%=$(top_builddir)/bench/heap-%.dat): $(top_builddir)/bench/bench-heap.so $(top_builddir)/bench/bench.so $(top_srcdir)/bench/bench-aux.lua
16$(BENCH_OPS:%=$(top_builddir)/bench/llrb-%.dat): $(top_builddir)/bench/bench-llrb.so $(top_builddir)/bench/bench.so $(top_srcdir)/bench/bench-aux.lua
17
18$(BENCH_ALGOS:%=$(top_builddir)/bench/%-add.dat): $(top_srcdir)/bench/bench-add.lua
19	@$(SHRC); echo_cmd cd $(@D) && echo_cmd $(LUA) $${top_srcdir}/bench/bench-add.lua $${top_builddir}/bench/bench-$(@F:%-add.dat=%).so > $(@F).tmp
20	mv $@.tmp $@
21
22$(BENCH_ALGOS:%=$(top_builddir)/bench/%-del.dat): $(top_srcdir)/bench/bench-del.lua
23	@$(SHRC); echo_cmd cd $(@D) && echo_cmd $(LUA) $${top_srcdir}/bench/bench-del.lua $${top_builddir}/bench/bench-$(@F:%-del.dat=%).so > $(@F).tmp
24	mv $@.tmp $@
25
26$(BENCH_ALGOS:%=$(top_builddir)/bench/%-expire.dat): $(top_srcdir)/bench/bench-expire.lua
27	@$(SHRC); echo_cmd cd $(@D) && echo_cmd $(LUA) $${top_srcdir}/bench/bench-expire.lua $${top_builddir}/bench/bench-$(@F:%-expire.dat=%).so > $(@F).tmp
28	mv $@.tmp $@
29
30$(top_builddir)/bench/bench.eps: \
31	$(BENCH_OPS:%=$(top_builddir)/bench/wheel-%.dat) \
32	$(BENCH_OPS:%=$(top_builddir)/bench/heap-%.dat)
33#	$(BENCH_OPS:%=$(top_builddir)/bench/llrb-%.dat)
34
35$(top_builddir)/bench/bench.eps: $(top_srcdir)/bench/bench.plt
36	@$(SHRC); echo_cmd cd $(@D) && echo_cmd gnuplot $${top_srcdir}/bench/bench.plt > $(@F).tmp
37	mv $@.tmp $@
38
39$(top_builddir)/bench/bench.pdf: $(top_builddir)/bench/bench.eps
40	@$(SHRC); echo_cmd ps2pdf $${top_builddir}/bench/bench.eps $@
41
42bench-mods: $(BENCH_MODS:%=$(top_builddir)/bench/%)
43
44bench-all: $(top_builddir)/bench/bench.pdf
45
46bench-clean:
47	$(RM) -r $(top_builddir)/bench/*.so $(top_builddir)/bench/*.dSYM
48	$(RM) $(top_builddir)/bench/*.dat $(top_builddir)/bench/*.tmp
49	$(RM) $(top_builddir)/bench/bench.{eps,pdf}
50