forked from google/highwayhash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (80 loc) · 2.67 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
# We assume X64 unless HH_POWER or HH_AARCH64 are defined.
ifeq ($(OSTYPE),FreeBSD)
override CXXFLAGS +=-fPIC
override LDFLAGS += -lpthread
endif
override CPPFLAGS += -I.
override CXXFLAGS +=-std=c++11 -Wall -O3
SIP_OBJS := $(addprefix obj/, \
sip_hash.o \
sip_tree_hash.o \
scalar_sip_tree_hash.o \
)
DISPATCHER_OBJS := $(addprefix obj/, \
arch_specific.o \
instruction_sets.o \
nanobenchmark.o \
os_specific.o \
)
HIGHWAYHASH_OBJS := $(DISPATCHER_OBJS) obj/hh_portable.o
HIGHWAYHASH_TEST_OBJS := $(DISPATCHER_OBJS) obj/highwayhash_test_portable.o
VECTOR_TEST_OBJS := $(DISPATCHER_OBJS) obj/vector_test_portable.o
ifdef HH_AARCH64
HH_X64 =
else
ifdef HH_POWER
HH_X64 =
else
HH_X64 = 1
HIGHWAYHASH_OBJS += obj/hh_avx2.o obj/hh_sse41.o
HIGHWAYHASH_TEST_OBJS += obj/highwayhash_test_avx2.o obj/highwayhash_test_sse41.o
VECTOR_TEST_OBJS += obj/vector_test_avx2.o obj/vector_test_sse41.o
endif
endif
all: $(addprefix bin/, \
profiler_example nanobenchmark_example vector_test sip_hash_test \
highwayhash_test benchmark) lib/libhighwayhash.a
obj/%.o: highwayhash/%.cc
@mkdir -p -- $(dir $@)
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
bin/%: obj/%.o
@mkdir -p -- $(dir $@)
$(CXX) $(LDFLAGS) $^ -o $@
.DELETE_ON_ERROR:
deps.mk: $(wildcard highwayhash/*.cc) $(wildcard highwayhash/*.h) Makefile
set -eu; for file in highwayhash/*.cc; do \
target=obj/$${file##*/}; target=$${target%.*}.o; \
[ "$$target" = "obj/highwayhash_target.o" ] || \
[ "$$target" = "obj/data_parallel_benchmark.o" ] || \
[ "$$target" = "obj/data_parallel_test.o" ] || \
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -DHH_DISABLE_TARGET_SPECIFIC -MM -MT \
"$$target" "$$file"; \
done | sed -e ':b' -e 's-../[^./]*/--' -e 'tb' >$@
-include deps.mk
bin/profiler_example: $(DISPATCHER_OBJS)
bin/nanobenchmark_example: $(DISPATCHER_OBJS) obj/nanobenchmark.o
ifdef HH_X64
obj/sip_tree_hash.o: CXXFLAGS+=-mavx2
# (Compiled from same source file with different compiler flags)
obj/highwayhash_test_avx2.o: CXXFLAGS+=-mavx2
obj/highwayhash_test_sse41.o: CXXFLAGS+=-msse4.1
obj/hh_avx2.o: CXXFLAGS+=-mavx2
obj/hh_sse41.o: CXXFLAGS+=-msse4.1
obj/vector_test_avx2.o: CXXFLAGS+=-mavx2
obj/vector_test_sse41.o: CXXFLAGS+=-msse4.1
obj/benchmark.o: CXXFLAGS+=-mavx2
endif
lib/libhighwayhash.a: $(SIP_OBJS) $(HIGHWAYHASH_OBJS) obj/c_bindings.o
@mkdir -p -- $(dir $@)
$(AR) rcs $@ $^
# ./test_exports.sh $@
bin/highwayhash_test: $(HIGHWAYHASH_TEST_OBJS)
bin/vector_test: $(VECTOR_TEST_OBJS)
bin/benchmark: obj/benchmark.o $(HIGHWAYHASH_TEST_OBJS)
bin/benchmark: $(SIP_OBJS) $(HIGHWAYHASH_OBJS)
clean:
[ ! -d obj ] || $(RM) -r -- obj/
distclean: clean
[ ! -d bin ] || $(RM) -r -- bin/
[ ! -d lib ] || $(RM) -r -- lib/
.PHONY: clean distclean all