-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
executable file
·81 lines (59 loc) · 2.24 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
ifeq ($(mode),)
mode := debug
endif
xtra_args := -Xswiftc -Ounchecked $(addprefix -Xcc ,-ffast-math -O3 -march=native)
#xtra_args := #$(xtra_args) $(addprefix -Xcc ,-Rpass-missed=loop-vectorize -Rpass=loop-vectorize) # -Xllvm -force-vector-width=4 -Xllvm -force-vector-interleave=4)
UNAME = ${shell uname}
ifeq ($(UNAME), Darwin)
PLATFORM = x86_64-apple-macosx*
EXECUTABLE = ./.build/${PLATFORM}/${mode}
LIB_SUF = dylib
xtra_args := $(xtra_args) -Xlinker -rpath -Xlinker ${shell pwd}/Darwin
else ifeq ($(UNAME), Linux)
PLATFORM = x86_64-unknown-linux
EXECUTABLE = ./.build/${PLATFORM}/${mode}
LIB_SUF = so
endif
# Use these if linking against full IPP/MKL
#libs := $(addprefix -l,ippi ipps ippvm ippcore mkl_intel_lp64 mkl_sequential mkl_core m pthread dl)
#libs_args := -Xcc -I${MKLROOT}/include -Xcc -I${IPPROOT}/include $(addprefix -Xlinker ,-L${MKLROOT}/lib -L${IPPROOT}/lib $(libs))
# Use these if linking against custom lib (recommended)
custom := ./$(UNAME)
libs_args := -Xcc -I$(custom) -Xlinker -L$(custom)
prefix := LD_LIBRARY_PATH=$(custom)
link_args := $(libs_args) $(xtra_args)
gybs := $(shell find Sources Tests -type f -name '*.gyb')
conv_gybs := $(patsubst %.gyb,%,$(gybs))
sources := $(conv_gybs) $(shell find Sources Tests -type f -name '*.swift')
sources := $(sources) $(shell find Sources Tests -type f -name '*.c')
sources := $(sources) $(shell find Sources Tests -type f -name '*.h')
headers := $(wildcard all_%.h)
yaml := ./.build/${mode}.yaml
run_args := -c $(mode) $(link_args)
custom_dir := $(UNAME)/.dirstamp
all: $(yaml)
run: $(yaml)
$(prefix) swift run $(run_args)
test: $(yaml)
$(prefix) swift test $(run_args)
$(yaml): gyb $(custom_dir)
swift build -v $(run_args)
Tests/LinuxMain.swift: Tests/SwiftyMKLTests/SwiftyMKLTests.swift
gyb: $(sources)
$(custom_dir): $(UNAME).tgz
tar xf $(UNAME).tgz
touch $(custom_dir)
$(UNAME).tgz:
wget http://files.fast.ai/files/$(UNAME).tgz
%.swift: %.swift.gyb
gyb --line-directive '' -o $@ $<
%.c: %.c.gyb
gyb --line-directive '' -o $@ $<
%.h: %.h.gyb
gyb --line-directive '' -o $@ $<
Sources/SwiftyMKL/MathFunctions.swift Sources/SwiftyMKL/Vector-impl.swift: mkl_funcs.py funcs.py
mkl_funcs.py: get_headers.py $(headers)
python get_headers.py
.PHONY: clean
clean:
rm -rf .build $(conv_gybs)