forked from DLTcollab/dcurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (128 loc) · 3.02 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
VERSION = 0.3.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/sanitizers.mk
endif
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
# Handle git submodule
include mk/submodule.mk
# Assign the hardware to CPU if no hardware is specified
PLATFORMS := $(BUILD_AVX) $(BUILD_SSE) $(BUILD_GENERIC) $(BUILD_GPU) $(BUILD_FPGA_ACCEL)
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_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 \
pow
TESTS := $(addprefix $(OUT)/test-, $(TESTS))
LIBS = libdcurl.so
LIBS := $(addprefix $(OUT)/, $(LIBS))
JARS := dcurljni-$(VERSION).jar
JARS := $(addprefix $(OUT)/, $(JARS))
PREQ := config $(TESTS) $(LIBS)
ifeq ("$(BUILD_JNI)","1")
PREQ += $(JARS)
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_ACCEL)","1")
OBJS += \
pow_fpga_accel.o
endif
OBJS := $(addprefix $(OUT)/, $(OBJS))
$(OUT)/test-%.o: tests/test-%.c $(LIBTUV_PATH)/include
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(LIBTUV_INCLUDE) -c -MMD -MF [email protected] $<
$(OUT)/%.o: $(SRC)/%.c $(LIBTUV_PATH)/include
$(VECHO) " CC\t$@\n"
$(Q)$(CC) -o $@ $(CFLAGS) $(LIBTUV_INCLUDE) -c -MMD -MF [email protected] $<
$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_LIBRARY)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -o $@ $^ $(LDFLAGS)
$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_LIBRARY)
$(VECHO) " LD\t$@\n"
$(Q)$(CC) -shared -o $@ $^ $(LDFLAGS)
include mk/common.mk
-include $(deps)