forked from DLTcollab/dcurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (125 loc) · 2.4 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
OUT ?= ./build
SRC := src
CFLAGS = -Wall -fPIC
LDFLAGS = \
-lpthread
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),Darwin)
# GNU ld specific options
LDFLAGS += \
-Wl,--gc-sections \
-Wl,--as-needed \
-Wl,--version-script=./mk/libdcurl.version
endif
-include $(OUT)/local.mk
ifeq ("$(BUILD_DEBUG)","1")
CFLAGS += -Og -g
else
# Enable all the optimizations in release build
CFLAGS += -Ofast
endif
SSE_S := $(shell grep -o sse /proc/cpuinfo | head -n 1)
# FIXME: avoid hardcoded architecture flags. We might support advanced SIMD
# instructions for Intel and Arm later.
ifeq ("$(BUILD_AVX)","1")
CFLAGS += -mavx -mavx2 -DENABLE_AVX
else
ifeq ($(SSE_S),sse)
CFLAGS += -msse2 -DENABLE_SSE
endif
endif
ifeq ("$(BUILD_GPU)","1")
include mk/opencl.mk
endif
ifeq ("$(BUILD_FPGA)","1")
include mk/fpga.mk
endif
ifeq ("$(BUILD_JNI)","1")
include mk/java.mk
endif
TESTS = \
trinary \
curl
ifeq ("$(BUILD_AVX)","1")
TESTS += \
pow_avx \
multi_pow_cpu
else
ifeq ($(SSE_S),sse)
TESTS += \
pow_sse \
multi_pow_cpu
else
TESTS += \
pow_c \
multi_pow_cpu
endif
endif
ifeq ("$(BUILD_GPU)","1")
TESTS += \
pow_cl \
multi_pow_gpu
endif
ifeq ("$(BUILD_FPGA)","1")
TESTS += \
pow_fpga
endif
ifeq ("$(BUILD_COMPAT)", "1")
TESTS += ccurl-multi_pow
endif
TESTS := $(addprefix $(OUT)/test-, $(TESTS))
LIBS = libdcurl.so
LIBS := $(addprefix $(OUT)/, $(LIBS))
all: config $(TESTS) $(LIBS)
.DEFAULT_GOAL := all
OBJS = \
curl.o \
constants.o \
trinary.o \
dcurl.o
ifeq ("$(BUILD_AVX)","1")
OBJS += pow_avx.o
else
ifeq ($(SSE_S),sse)
OBJS += pow_sse.o
else
OBJS += pow_c.o
endif
endif
ifeq ("$(BUILD_GPU)","1")
OBJS += \
pow_cl.o \
clcontext.o
endif
ifeq ("$(BUILD_FPGA)","1")
OBJS += \
pow_fpga.o
endif
ifeq ("$(BUILD_JNI)","1")
OBJS += \
jni/iri-pearldiver-exlib.o
endif
ifeq ("$(BUILD_COMPAT)", "1")
OBJS += \
compat-ccurl.o
endif
OBJS := $(addprefix $(OUT)/, $(OBJS))
$(OUT)/test-%.o: tests/test-%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) -c -MMD -MF [email protected] $<
$(OUT)/%.o: $(SRC)/%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/test-%: $(OUT)/test-%.o $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)
$(OUT)/libdcurl.so: $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)
$(OUT)/test-%: tests/test-%.py $(OUT)/libdcurl.so
$(Q)echo "#!$(PYTHON)" > $@
$(call py_prepare_cmd)
$(Q)chmod +x $@
include mk/common.mk
include mk/python.mk
-include $(deps)