-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathMakevars.in
More file actions
172 lines (136 loc) · 4.2 KB
/
Makevars.in
File metadata and controls
172 lines (136 loc) · 4.2 KB
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
PKG_CXXFLAGS = @CXX11STD@
# If TBB_ROOT is defined, use it.
ifdef TBB_ROOT
ifndef TBB_LIB
TBB_LIB = $(TBB_ROOT)/lib
endif
ifndef TBB_INC
TBB_INC = $(TBB_ROOT)/include
endif
endif
# If TBB_LIB is defined by TBB_INC is not, make a guess.
ifdef TBB_LIB
ifndef TBB_INC
TBB_INC = $(TBB_LIB)/../include
endif
endif
ifdef TBB_INC
PKG_CPPFLAGS = -I../inst/include -I$(TBB_INC)
else
PKG_CPPFLAGS = -I../inst/include
endif
ifdef TBB_LIB
PKG_LIBS = -Wl,-L,"$(TBB_LIB)" -Wl,-rpath,"$(TBB_LIB)" -ltbb -ltbbmalloc
endif
ifeq ($(OS), Windows_NT)
USE_TBB=Windows
TBB_COPY_PATTERN=tbb*.dll
MAKE = make
MAKEFLAGS = -e -j1
MAKE_CMD = \
MSYS2_ARG_CONV_EXCL="*" \
CYGWIN=nodosfilewarning \
CONLY="@WINDOWS_CC@" \
CPLUS="@WINDOWS_CXX11@" \
CXXFLAGS="@CXX11FLAGS@ -DTBB_NO_LEGACY=1" \
PIC_KEY="@CXX11PICFLAGS@" \
WARNING_SUPPRESS="" \
$(MAKE)
else
UNAME := $(shell uname)
TBB_COPY_PATTERN=libtbb*.*
ifeq ($(UNAME), Darwin)
USE_TBB=Mac
endif
ifeq ($(UNAME), Linux)
USE_TBB=Linux
endif
ifeq ($(UNAME), SunOS)
SUNOS_ARCH = $(shell uname -p)
ifeq ($(SUNOS_ARCH), i386)
USE_TBB=SunOS
endif
endif
MAKEFLAGS += -e
MAKE_CMD = \
CONLY="@CC@ $(PKG_CPPFLAGS) @CPPFLAGS@" \
CPLUS="@CXX11@ $(PKG_CPPFLAGS) @CPPFLAGS@" \
CXXFLAGS="@CXX11FLAGS@ -DTBB_NO_LEGACY=1" \
PIC_KEY="@CXX11PICFLAGS@" \
WARNING_SUPPRESS="" \
$(MAKE)
endif
ifdef USE_TBB
PKG_CXXFLAGS += -DRCPP_PARALLEL_USE_TBB=1
PKG_CXXFLAGS += -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1
MAKE_TARGETS = tbb_build_prefix=lib tbb_release tbbmalloc_release
ifeq ($(USE_TBB), Windows)
# rtools: turn on hacks to compensate for make and shell differences rtools<=>MinGW
# compiler: overwrite default (which is cl = MS compiler)
MAKE_ARGS += rtools=true compiler=gcc
ifeq ($(WIN), 64)
MAKE_ARGS += arch=intel64 runtime=mingw
ARCH_DIR=x64/
else
MAKE_ARGS += arch=ia32 runtime=mingw
ARCH_DIR=i386/
endif
# Linker needs access to the tbb dll; otherwise you get errors such as:
# "undefined reference to `tbb::task_scheduler_init::terminate()'"
PKG_LIBS += -Ltbb/build/lib_release -ltbb -ltbbmalloc
endif
# write compiler if set
ifneq (@COMPILER@, )
MAKE_ARGS += compiler=@COMPILER@
endif
# For Solaris detect if this is 32-bit R on x86 and if so forward that to TBB
ifeq ($(USE_TBB), SunOS)
R_32BIT = $(shell ${R_HOME}/bin/Rscript -e 'cat(.Machine$$sizeof.pointer == 4)')
ifeq ($(R_32BIT), TRUE)
MAKE_ARGS += arch=ia32
endif
endif
# Write compilation output to file, and log it if installation fails.
ifeq ($(VERBOSE), )
MAKE_LOG = > tbb.log 2>&1 \
&& echo "(tbb) TBB compilation finished successfully." \
|| cat tbb.log; rm -f tbb.log
endif
.PHONY: all tbb tbb-clean
# Order is important in Windows' case. See PKG_LIBS above
all: tbb $(SHLIB)
# TBB needs to be built before our C++ sources are built, so that
# headers are copied and available from the expected locations.
$(OBJECTS): tbb
# NOTE: TBB libraries are installed via install.libs.R.
# However, we need to copy headers here so that they are visible during compilation.
tbb: tbb-clean
ifdef TBB_LIB
@echo "(tbb) Using system (Intel / OneAPI) TBB library."
@echo "(tbb) TBB_LIB = $(TBB_LIB)"
@echo "(tbb) TBB_INC = $(TBB_INC)"
@mkdir -p ../inst/include
@cp -R $(TBB_INC)/oneapi ../inst/include/ 2> /dev/null || :
@cp -R $(TBB_INC)/serial ../inst/include/ 2> /dev/null || :
@cp -R $(TBB_INC)/tbb ../inst/include/ 2> /dev/null || :
else
@echo "(tbb) Building TBB using bundled sources ..."
@mkdir -p ../inst/include
@cp -R tbb/include/* ../inst/include/
@(cd tbb/src && $(MAKE_CMD) $(MAKE_ARGS) info)
@(cd tbb/src && $(MAKE_CMD) @STDVER@ $(MAKE_ARGS) $(MAKE_TARGETS) $(MAKE_LOG))
endif
# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
# as we may be writing to those locations in multiarch builds
tbb-clean:
@rm -rf ../inst/include/tbb
@rm -rf ../inst/include/oneapi
@rm -rf ../inst/include/tbb_local
@rm -rf ../inst/include/serial
clean: tbb-clean
ifdef TBB_LIB
@echo "Nothing to clean for TBB."
else
@(cd tbb/src; make clean)
endif
endif