forked from DLTcollab/dcurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (113 loc) · 2.31 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
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
ifeq ("$(BUILD_DEBUG)","1")
CFLAGS += -Og -g3
else
# Enable all the valid optimizations for standard programs in release build
CFLAGS += -O3
endif
# Check specific CPU features available on build host
include mk/cpu-features.mk
ifeq ("$(BUILD_AVX)","1")
CFLAGS += -mavx -DENABLE_AVX
ifeq ("$(call cpu_feature,AVX2)","1")
CFLAGS += -mavx2
endif
else
BUILD_SSE := $(call cpu_feature,SSE)
ifeq ("$(BUILD_SSE)","1")
CFLAGS += -msse2 -DENABLE_SSE
endif
endif
ifeq ("$(BUILD_GPU)","1")
include mk/opencl.mk
endif
ifeq ("$(BUILD_FPGA_ACCEL)","1")
CFLAGS += -DENABLE_FPGA_ACCEL
endif
ifeq ("$(BUILD_JNI)","1")
include mk/java.mk
endif
ifeq ("$(BUILD_STAT)","1")
CFLAGS += -DENABLE_STAT
endif
TESTS = \
trinary \
curl \
dcurl \
multi-pow \
pow
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 \
implcontext.o \
common.o
ifeq ("$(BUILD_AVX)","1")
OBJS += pow_avx.o
else
ifeq ("$(BUILD_SSE)","1")
OBJS += pow_sse.o
else
OBJS += pow_c.o
endif
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_ACCEL)","1")
OBJS += \
pow_fpga_accel.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)