forked from DLTcollab/dcurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
196 lines (155 loc) · 3.64 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
VERSION = 0.6.0
OUT ?= ./build
SRC := src
CFLAGS = -Wall -fPIC -std=gnu99
LDFLAGS = \
-lm \
-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
ifneq ("$(BUILD_DEBUG)","0")
CFLAGS += -Og -g3 -DENABLE_DEBUG
ifneq ("$(BUILD_DEBUG)","1")
include mk/dynamic-analysis.mk
endif
else
# Enable all the valid optimizations for standard programs in release build
CFLAGS += -O3
endif
# Static code analysis
include mk/static-analysis.mk
# Check specific CPU features available on build host
include mk/cpu-features.mk
# Handle git submodule
include mk/submodule.mk
# Board specific compiler flags
include mk/board.mk
# Generate document
include mk/docgen.mk
# Assign the hardware to CPU if no hardware is specified
PLATFORMS := $(BUILD_AVX) $(BUILD_SSE) $(BUILD_GENERIC) $(BUILD_GPU) $(BUILD_FPGA)
ENABLE_PLATFORMS := $(findstring 1,$(PLATFORMS))
ifneq ("$(ENABLE_PLATFORMS)","1")
ifeq ("$(call cpu_feature,AVX)","1")
BUILD_AVX = 1
else ifeq ("$(call cpu_feature,SSE)","1")
BUILD_SSE = 1
else
BUILD_GENERIC = 1
endif
endif
ifeq ("$(BUILD_AVX)","1")
CFLAGS += -mavx -DENABLE_AVX
ifeq ("$(call cpu_feature,AVX2)","1")
CFLAGS += -mavx2
endif
else ifeq ("$(BUILD_SSE)","1")
CFLAGS += -msse2 -DENABLE_SSE
else ifeq ("$(BUILD_GENERIC)","1")
CFLAGS += -DENABLE_GENERIC
endif
ifeq ("$(call cpu_feature,SSE4_2)","1")
CFLAGS += -msse4.2
endif
ifeq ("$(BUILD_GPU)","1")
include mk/opencl.mk
endif
ifeq ("$(BUILD_FPGA)","1")
CFLAGS += -DENABLE_FPGA
endif
ifeq ("$(BUILD_REMOTE)","1")
CFLAGS += -DENABLE_REMOTE
endif
ifeq ("$(BUILD_JNI)","1")
include mk/java.mk
endif
ifeq ("$(BUILD_STAT)","1")
CFLAGS += -DENABLE_STAT
endif
TESTS = \
trinary \
curl \
dcurl \
pow \
multi-pow
TESTS := $(addprefix $(OUT)/test-, $(TESTS))
LIBS = libdcurl.so
LIBS := $(addprefix $(OUT)/, $(LIBS))
JARS := dcurljni-$(VERSION).jar
JARS := $(addprefix $(OUT)/, $(JARS))
PREQ := $(SUBS) config $(TESTS) $(LIBS)
ifeq ("$(BUILD_JNI)","1")
PREQ += $(JARS)
endif
ifeq ("$(BUILD_REMOTE)", "1")
PREQ += $(OUT)/remote-worker
endif
all: $(PREQ)
.DEFAULT_GOAL := all
OBJS = \
curl.o \
constants.o \
trinary.o \
dcurl.o \
implcontext.o \
common.o
ifeq ("$(BUILD_AVX)","1")
OBJS += pow_avx.o
else ifeq ("$(BUILD_SSE)","1")
OBJS += pow_sse.o
else ifeq ("$(BUILD_GENERIC)","1")
OBJS += pow_c.o
endif
ifeq ("$(BUILD_GPU)","1")
OBJS += \
pow_cl.o \
clcontext.o
endif
ifeq ("$(BUILD_JNI)","1")
OBJS += \
jni/iri_pearldiver_exlib.o
endif
ifeq ("$(BUILD_COMPAT)", "1")
OBJS += \
compat_ccurl.o
endif
ifeq ("$(BUILD_FPGA)","1")
OBJS += \
pow_fpga.o
endif
ifeq ("$(BUILD_REMOTE)", "1")
OBJS += \
remote_common.o \
remote_interface.o
WORKER_EXCLUDE_OBJS := remote_interface.o
ifeq ("$(BUILD_JNI)", "1")
WORKER_EXCLUDE_OBJS += jni/iri_pearldiver_exlib.o
endif
WORKER_OBJS := $(addprefix $(OUT)/worker-,$(filter-out $(WORKER_EXCLUDE_OBJS), $(OBJS)))
WORKER_CFLAGS := $(filter-out -DENABLE_REMOTE, $(CFLAGS))
endif
OBJS := $(addprefix $(OUT)/, $(OBJS))
$(OUT)/test-%.o: tests/test-%.c
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(SUB_INCLUDE) -c -MMD -MF [email protected] $<
$(OUT)/%.o: $(SRC)/%.c $(SUB_OBJS)
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(SUB_INCLUDE) -c -MMD -MF [email protected] $<
$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(SUB_OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)
$(OUT)/libdcurl.so: $(OBJS) $(SUB_OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)
ifeq ("$(BUILD_REMOTE)", "1")
include mk/remote.mk
endif
include mk/common.mk
-include $(deps)