Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 272 lines (216 sloc) 5.47 kB
ec0a9b4 @tonyrog initial add
authored
1 OSNAME := $(shell uname -s)
2 MACHINE := $(shell uname -m)
3 CC = gcc
a25b4d5 @dgud Compiles on windows
dgud authored
4 OUT_C = -o
5 OUT_L = -o
6 OBJ = o
ec0a9b4 @tonyrog initial add
authored
7
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
8 ## make MCL=1 to build with microsoft compiler using msbuild (MSVC-10)
9
2c645d2 @dgud Fixed building on linux.
dgud authored
10 ERLDIR := $(shell erl -noshell -eval "io:format([126,115,126,110],[code:root_dir()])" -s erlang halt)
ec0a9b4 @tonyrog initial add
authored
11 ERL_C_INCLUDE_DIR := $(ERLDIR)/usr/include
12 OCL_DIR := $(shell cd ..; pwd)
13
2fa5683 @dgud Makefile win32 fixes
dgud authored
14 ## Windows start
15 ifneq (, $(findstring MINGW32,$(OSNAME)))
16 MINGW = Yes
17 endif
18
ec0a9b4 @tonyrog initial add
authored
19 MAC_OS_X = No
a25b4d5 @dgud Compiles on windows
dgud authored
20 WIN32_GCC = No
21 WIN32_CL = No
ec0a9b4 @tonyrog initial add
authored
22 LINUX = No
23
24 ALTIVEC = No
25 MMX = No
26 SSE = No
27 SSE2 = No
28 SSE3 = No
29 SSE4 = No
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
30 EXT = so
ec0a9b4 @tonyrog initial add
authored
31
2fa5683 @dgud Makefile win32 fixes
dgud authored
32 ifneq ($(MINGW), Yes)
33 CONFIG_FILE_64 = config.64.build
34 CONFIG_FILE_32 = config.32.build
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
35 ifeq ($(WORDSIZE), 64)
2fa5683 @dgud Makefile win32 fixes
dgud authored
36 include $(CONFIG_FILE_64)
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
37 endif
38 ifeq ($(WORDSIZE), 32)
2fa5683 @dgud Makefile win32 fixes
dgud authored
39 include $(CONFIG_FILE_32)
40 endif
41 else
42 # Skip configure on windows for now we don't have
43 # 64bits support anyway, autoconf and lib are a mess
44 # to install
45 ifeq ($(WORDSIZE), 64)
46 CL_BUILD=false
47 else
48 CL_BUILD=true
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
49 endif
2fa5683 @dgud Makefile win32 fixes
dgud authored
50 endif
51
52
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
53
ec0a9b4 @tonyrog initial add
authored
54 ifeq ($(TYPE), debug)
55 OBJDIR=../obj/debug
56 LIBDIR=../lib/debug
2fa5683 @dgud Makefile win32 fixes
dgud authored
57 CFLAGS += -Ddebug -DDEBUG -g -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE
a25b4d5 @dgud Compiles on windows
dgud authored
58 CFLAGS += -D_REENTRANT -fno-common -I$(ERL_C_INCLUDE_DIR)
59 WIN_DEBUG = -Ddebug -DDEBUG
ec0a9b4 @tonyrog initial add
authored
60 endif
61
62 ifeq ($(TYPE), release)
63 OBJDIR=../obj/release
64 LIBDIR=../lib/release
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
65 CFLAGS += -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE -D_REENTRANT -fno-common
a25b4d5 @dgud Compiles on windows
dgud authored
66 CFLAGS += -I$(ERL_C_INCLUDE_DIR)
ec0a9b4 @tonyrog initial add
authored
67 endif
68
69 ifeq ($(OSNAME), Linux)
70 LINUX = Yes
0e5e0df @tonyrog added nvidia-current to search path, include stdarg
authored
71 CFLAGS += -I/usr/include/nvidia-current
ec0a9b4 @tonyrog initial add
authored
72 ifeq ($(WORDSIZE), 32)
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
73 CFLAGS += -O3 -fPIC -m32 -DWORDSIZE=32
ec0a9b4 @tonyrog initial add
authored
74 endif
75 ifeq ($(WORDSIZE), 64)
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
76 CFLAGS += -O3 -fPIC -m64 -DWORDSIZE=64
ec0a9b4 @tonyrog initial add
authored
77 endif
9e3727d @dgud Fix linking on linux
dgud authored
78 LD_SHARED := $(CC) -shared
79 LDFLAGS += -lOpenCL
ec0a9b4 @tonyrog initial add
authored
80 endif
81
82 ifeq ($(OSNAME), Darwin)
83 MAC_OS_X = Yes
84 ifeq ($(WORDSIZE), 32)
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
85 CFLAGS += -O3 -fPIC -m32 -DWORDSIZE=32 -DDARWIN -no-cpp-precomp
ec0a9b4 @tonyrog initial add
authored
86 LD_SHARED := $(CC) -m32 -bundle -flat_namespace -undefined suppress
87 endif
88 ifeq ($(WORDSIZE), 64)
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
89 CFLAGS += -O3 -fPIC -m64 -DWORDSIZE=64 -DDARWIN -no-cpp-precomp
ec0a9b4 @tonyrog initial add
authored
90 LD_SHARED := $(CC) -m64 -bundle -flat_namespace -undefined suppress
91 endif
92 endif
93
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
94 ifeq ($(MINGW), Yes)
a25b4d5 @dgud Compiles on windows
dgud authored
95 EXT = dll
96
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
97 ifneq ($(MCL), )
a25b4d5 @dgud Compiles on windows
dgud authored
98 ## Use Microsoft CL
99 WIN32_CL = Yes
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
100 ifeq ($(OPENCL_DIR), )
101 OPENCL_DIR = c:/msysgit/opt/local/
102 endif
a25b4d5 @dgud Compiles on windows
dgud authored
103 else
104 ## Use mingw-gcc
105 WIN32_GCC = Yes
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
106 CFLAGS += -D__WIN32__
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
107 ifeq ($(OPENCL_DIR), )
108 OPENCL_DIR = /opt/local/
109 endif
110
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
111 ifeq ($(WORDSIZE), 32)
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
112 CFLAGS += -shared -I$(OPENCL_DIR)/include -m32 -DWIN32 -DWORDSIZE=32
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
113 endif
114 ifeq ($(WORDSIZE), 64)
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
115 CFLAGS += -shared -I$(OPENCL_DIR)/include -m64 -DWIN32 -DWORDSIZE=64
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
116 endif
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
117
a25b4d5 @dgud Compiles on windows
dgud authored
118 LD_SHARED := $(CC) -shared
119
b8c6a92 @dgud Windows gcc-4.4.0 -O is broken.
dgud authored
120 ## Optimizations is broken on mingw 4.4.0 (it crashes with it on)
121 GCC_VERSION = $(shell gcc -dumpversion)
122 ifneq ($(GCC_VERSION), 4.4.0)
123 CFLAGS += -O3
124 endif
125
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
126 endif
a25b4d5 @dgud Compiles on windows
dgud authored
127 endif
128 ## Windows end
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
129
ec0a9b4 @tonyrog initial add
authored
130 ifeq ($(MACHINE), "Power Macintosh")
131 ALTIVEC = Yes
132 endif
133
134 ifeq ($(MACHINE), i386)
135 MMX = No
136 SSE = No
137 SSE2 = Yes
138 SSE3 = No
139 endif
140
141 ifeq ($(MACHINE), i686)
142 MMX = No
143 SSE = No
144 SSE2 = Yes
145 SSE3 = No
146 endif
147
148 ifeq ($(ALTIVEC),Yes)
149 CFLAGS += -maltivec -DUSE_ALTIVEC
150 endif
151
152 ifeq ($(SSE),Yes)
153 CFLAGS += -msse
154 endif
155
156 ifeq ($(SSE2),Yes)
157 CFLAGS += -msse2 -DUSE_SSE2
a25b4d5 @dgud Compiles on windows
dgud authored
158 SIMD_OBJS += ocl_simd_sse2.$(BIT).$(OBJ)
ec0a9b4 @tonyrog initial add
authored
159 endif
160
161 ifeq ($(SSE3),Yes)
162 MCFLAGS += -msse3
163 endif
164
165 ifeq ($(MMX),Yes)
166 MCFLAGS += -mmmx -DUSE_MMX
a25b4d5 @dgud Compiles on windows
dgud authored
167 SIMD_OBJS += ocl_simd_mmx.$(BIT).$(OBJ)
168 endif
169
170
171 ifeq ($(MAC_OS_X),Yes)
172 LDFLAGS += -framework OpenCL
173 endif
174
175 ifeq ($(WIN32_GCC),Yes)
176 CFLAGS += -DWIN32
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
177 LDFLAGS += -Wl--enable-stdcall-fixup -L$(OPENCL_DIR)/lib -lOpenCL
ec0a9b4 @tonyrog initial add
authored
178 endif
179
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
180 CL_DRV = $(LIBDIR)/$(WORDSIZE)/cl_drv.$(EXT)
ec0a9b4 @tonyrog initial add
authored
181
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
182 CL_NIF = $(LIBDIR)/$(WORDSIZE)/cl_nif.$(EXT)
75bdfa3 @tonyrog use of ECL_USE_ASYNC (default), replaces the thread loop, started som…
authored
183
184 CL_DRV_OBJS = \
a25b4d5 @dgud Compiles on windows
dgud authored
185 $(OBJDIR)/$(WORDSIZE)/cl_drv.$(OBJ) \
186 $(OBJDIR)/$(WORDSIZE)/cl_hash.$(OBJ)
ec0a9b4 @tonyrog initial add
authored
187
75bdfa3 @tonyrog use of ECL_USE_ASYNC (default), replaces the thread loop, started som…
authored
188 CL_NIF_OBJS = \
a25b4d5 @dgud Compiles on windows
dgud authored
189 $(OBJDIR)/$(WORDSIZE)/cl_nif.$(OBJ) \
190 $(OBJDIR)/$(WORDSIZE)/cl_hash.$(OBJ)
75bdfa3 @tonyrog use of ECL_USE_ASYNC (default), replaces the thread loop, started som…
authored
191
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
192 CL_NIF_SRC = \
193 cl_nif.c \
194 cl_hash.c
195
ec0a9b4 @tonyrog initial add
authored
196 CL_ASM = \
197 $(OBJDIR)/$(WORDSIZE)/cl_drv.s \
198 $(OBJDIR)/$(WORDSIZE)/cl_hash.s
199
200 OCL_SIMD_OBJS = $(SIMD_OBJS:%=$(OBJDIR)/%)
201
202 all: all32 all64
203
2fa5683 @dgud Makefile win32 fixes
dgud authored
204 all32: $(CONFIG_FILE_32)
4063eaf @tonyrog NIF version of the openCL binding
authored
205 $(MAKE) nif TYPE=release WORDSIZE=32
206 $(MAKE) nif TYPE=debug WORDSIZE=32
ec0a9b4 @tonyrog initial add
authored
207
2fa5683 @dgud Makefile win32 fixes
dgud authored
208 all64: $(CONFIG_FILE_64)
4063eaf @tonyrog NIF version of the openCL binding
authored
209 $(MAKE) nif TYPE=release WORDSIZE=64
210 $(MAKE) nif TYPE=debug WORDSIZE=64
ec0a9b4 @tonyrog initial add
authored
211
01ac058 @tonyrog changed all pointers and size_t to 64 bit erlang side, according to s…
authored
212 config.32.build: configure
ec0a9b4 @tonyrog initial add
authored
213 ./configure --with-wordsize=32
214
01ac058 @tonyrog changed all pointers and size_t to 64 bit erlang side, according to s…
authored
215 config.64.build: configure
ec0a9b4 @tonyrog initial add
authored
216 ./configure --with-wordsize=64
217
218 configure: configure.in
219 autoheader; autoconf
220
221 clean:
a45b825 @dgud Fixed linking on linux and examples when no cpu target is available.
dgud authored
222 $(MAKE) clean_internal TYPE=release WORDSIZE=32
223 $(MAKE) clean_internal TYPE=debug WORDSIZE=32
224 $(MAKE) clean_internal TYPE=release WORDSIZE=64
225 $(MAKE) clean_internal TYPE=debug WORDSIZE=64
ec0a9b4 @tonyrog initial add
authored
226
227 # Make cl library
228 debug:
4063eaf @tonyrog NIF version of the openCL binding
authored
229 $(MAKE) nif TYPE=debug
ec0a9b4 @tonyrog initial add
authored
230
231 clean_debug:
232 $(MAKE) clean_internal TYPE=debug
233
234 release:
4063eaf @tonyrog NIF version of the openCL binding
authored
235 $(MAKE) nif TYPE=release
ec0a9b4 @tonyrog initial add
authored
236
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
237 ifeq ($(CL_BUILD), false)
4063eaf @tonyrog NIF version of the openCL binding
authored
238 nif:
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
239 @echo
4063eaf @tonyrog NIF version of the openCL binding
authored
240 @echo Skipping nif for wordsize=$(WORDSIZE), not supported on this system
70012c4 @dgud Improved the building on 32 bits systems
dgud authored
241 @echo
242 else
75bdfa3 @tonyrog use of ECL_USE_ASYNC (default), replaces the thread loop, started som…
authored
243 nif: $(CL_NIF)
4063eaf @tonyrog NIF version of the openCL binding
authored
244 endif
ec0a9b4 @tonyrog initial add
authored
245
246 depend:
247
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
248 ifeq ($(WIN32_CL),No)
ec0a9b4 @tonyrog initial add
authored
249 clean_internal:
a25b4d5 @dgud Compiles on windows
dgud authored
250 -rm -f $(OBJDIR)/$(WORDSIZE)/*.$(OBJ)
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
251 -rm -f $(LIBDIR)/$(WORDSIZE)/*.$(EXT)
ec0a9b4 @tonyrog initial add
authored
252
75bdfa3 @tonyrog use of ECL_USE_ASYNC (default), replaces the thread loop, started som…
authored
253 $(CL_NIF): $(OCL_LIB) $(CL_NIF_OBJS) # $(CL_ASM)
2eadf1c @dgud Supply senders env in enif_send if done by a scheduler thread
dgud authored
254 $(LD_SHARED) $(OUT_L) $@ $(CL_NIF_OBJS) $(LDFLAGS)
f0eec68 @dgud Update vsn.mk and added a msvc++ proj and fixed issue with function c…
dgud authored
255 else
256 clean_internal:
257 msbuild.exe CL.sln -t:clean
258
259 $(CL_NIF): $(CL_NIF_SRC) cl_hash.h
260 msbuild.exe CL.sln -p:Configuration=$(TYPE) -p:ERL_C_INCLUDE_DIR=$(ERL_C_INCLUDE_DIR) \
261 -p:OPENCL_DIR=$(OPENCL_DIR)
262 endif
ec0a9b4 @tonyrog initial add
authored
263
a25b4d5 @dgud Compiles on windows
dgud authored
264 $(OBJDIR)/$(WORDSIZE)/cl_nif.$(OBJ): cl_hash.h
ec0a9b4 @tonyrog initial add
authored
265
a25b4d5 @dgud Compiles on windows
dgud authored
266 $(OBJDIR)/$(WORDSIZE)/%.$(OBJ): %.c
2eadf1c @dgud Supply senders env in enif_send if done by a scheduler thread
dgud authored
267 $(CC) -c $(OUT_C) $@ $(CFLAGS) $<
ec0a9b4 @tonyrog initial add
authored
268
eec2697 @dgud Fixed Windows build and instructions for windows.
dgud authored
269 $(OBJDIR)/$(WORDSIZE)/%.s: %.c
2eadf1c @dgud Supply senders env in enif_send if done by a scheduler thread
dgud authored
270 $(CC) -S $(OUT_C) $@ $(CFLAGS) $<
ec0a9b4 @tonyrog initial add
authored
271
Something went wrong with that request. Please try again.