1
1
2
- PKG_CXXFLAGS = @CXX11STD @
2
+ R = @R @
3
3
4
- TBB_LIB = @TBB_LIB@
5
- TBB_INC = @TBB_INC@
4
+ TBB_LIB = @TBB_LIB@
5
+ TBB_INC = @TBB_INC@
6
+ TBB_NAME = @TBB_NAME@
6
7
7
- # If TBB_INC is defined, include those library paths.
8
- ifdef TBB_INC
9
- PKG_CPPFLAGS = -I../inst/include -I$(TBB_INC)
10
- else
11
- PKG_CPPFLAGS = -I../inst/include
12
- endif
13
-
14
- # If TBB_LIB is defined, link to that explicitly.
15
- ifdef TBB_LIB
16
- ifeq ($(OS), Windows_NT)
17
- PKG_LIBS = -Wl,-L"$(TBB_LIB)" -ltbb -ltbbmalloc
18
- else
19
- PKG_LIBS = -Wl,-L"$(TBB_LIB)" -Wl,-rpath,"$(TBB_LIB)" -ltbb -ltbbmalloc
20
- endif
21
- endif
22
-
23
- ifeq ($(OS), Windows_NT)
24
-
25
- USE_TBB=Windows
26
- TBB_COPY_PATTERN=tbb*.dll
27
-
28
- ARCH=$(shell "${R_HOME}/bin/R" --vanilla -s -e 'cat(R.version$$arch)')
29
- TBB_CXXFLAGS = @CXX11FLAGS@ -DTBB_NO_LEGACY=1
30
- ifeq "$(ARCH)" "aarch64"
31
- PKG_CPPFLAGS += -DTBB_USE_GCC_BUILTINS
32
- TBB_CXXFLAGS += -DTBB_USE_GCC_BUILTINS
33
- CLANG_CHECK := $(shell echo | $(CC) -E -dM - | findstr __clang__)
34
- ifneq ($(CLANG_CHECK), )
35
- WINARM64_CLANG=true
36
- endif
37
- endif
38
-
39
- MAKE = make
40
- MAKEFLAGS = -e -j1
41
- MAKE_CMD = \
42
- MSYS2_ARG_CONV_EXCL="*" \
43
- CYGWIN=nodosfilewarning \
44
- CONLY="@WINDOWS_CC@" \
45
- CPLUS="@WINDOWS_CXX11@" \
46
- CXXFLAGS="$(TBB_CXXFLAGS)" \
47
- PIC_KEY="@CXX11PICFLAGS@" \
48
- WARNING_SUPPRESS="" \
49
- WINARM64_CLANG="$(WINARM64_CLANG)" \
50
- $(MAKE)
51
-
52
- else
53
-
54
- UNAME := $(shell uname)
55
- TBB_COPY_PATTERN=libtbb*.*
56
-
57
- ifeq ($(UNAME), Darwin)
58
- USE_TBB=Mac
59
- MAKE_ARGS += arch=$(shell uname -m)
60
- endif
61
-
62
- ifeq ($(UNAME), Linux)
63
- USE_TBB=Linux
64
- endif
65
-
66
- ifeq ($(UNAME), SunOS)
67
- SUNOS_ARCH = $(shell uname -p)
68
- ifeq ($(SUNOS_ARCH), i386)
69
- USE_TBB=SunOS
70
- endif
71
- endif
72
-
73
- MAKEFLAGS += -e
74
- MAKE_CMD = \
75
- CONLY="@CC@ $(PKG_CPPFLAGS) @CPPFLAGS@" \
76
- CPLUS="@CXX11@ $(PKG_CPPFLAGS) @CPPFLAGS@" \
77
- CXXFLAGS="@CXX11FLAGS@ -DTBB_NO_LEGACY=1" \
78
- PIC_KEY="@CXX11PICFLAGS@" \
79
- WARNING_SUPPRESS="" \
80
- $(MAKE)
81
-
82
- endif
83
-
84
- ifdef USE_TBB
85
-
86
- PKG_CXXFLAGS += -DRCPP_PARALLEL_USE_TBB=1
8
+ PKG_CPPFLAGS = @PKG_CPPFLAGS@
9
+ PKG_CXXFLAGS = @CXX11STD@ -DRCPP_PARALLEL_USE_TBB=1
87
10
PKG_CXXFLAGS += -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1
88
11
89
- MAKE_TARGETS = tbb_build_prefix=lib tbb_release tbbmalloc_release
90
-
91
- ifeq ($(USE_TBB), Windows)
92
-
93
- # rtools: turn on hacks to compensate for make and shell differences rtools<=>MinGW
94
- # compiler: overwrite default (which is cl = MS compiler)
95
- MAKE_ARGS += rtools=true compiler=gcc
96
-
97
- # TBB configure will detect mingw runtime with unknown arch on WINARM64_CLANG but not an
98
- # issue as we are using compiler built-ins instead of arch-specific code
99
- ifneq ($(WINARM64_CLANG), true)
100
- ifeq ($(WIN), 64)
101
- MAKE_ARGS += arch=intel64 runtime=mingw
102
- ARCH_DIR=x64/
103
- else
104
- MAKE_ARGS += arch=ia32 runtime=mingw
105
- ARCH_DIR=i386/
106
- endif
107
- endif
108
-
109
- # Linker needs access to the tbb dll; otherwise you get errors such as:
110
- # "undefined reference to `tbb::task_scheduler_init::terminate()'"
111
- PKG_LIBS += -Ltbb/build/lib_release -ltbb -ltbbmalloc
112
- endif
113
-
114
- # write compiler if set
115
- ifneq (@COMPILER@, )
116
- MAKE_ARGS += compiler=@COMPILER@
117
- endif
118
-
119
- # When TBB_LIB is unset on MacOS, link to the bundled version (#206)
120
- ifeq ($(USE_TBB)$(TBB_LIB),Mac)
121
- PKG_LIBS += -Ltbb/build/lib_release -ltbb -Wl,-rpath,'@loader_path/../lib'
122
- endif
123
-
124
- # For Solaris detect if this is 32-bit R on x86 and if so forward that to TBB
125
- ifeq ($(USE_TBB), SunOS)
126
- R_32BIT = $(shell ${R_HOME}/bin/Rscript -e 'cat(.Machine$$sizeof.pointer == 4)')
127
- ifeq ($(R_32BIT), TRUE)
128
- MAKE_ARGS += arch=ia32
129
- endif
130
- endif
131
-
132
- # Write compilation output to file, and log it if installation fails.
133
- ifeq ($(VERBOSE), )
134
- MAKE_LOG = > tbb.log 2>&1 \
135
- && echo "(tbb) TBB compilation finished successfully." \
136
- || cat tbb.log; rm -f tbb.log
137
- endif
12
+ PKG_LIBS = -Wl,-L"$(TBB_LIB)" @TBB_RPATH@ -l$(TBB_NAME) -ltbbmalloc
13
+ PKG_LIBS += @PKG_LIBS_EXTRA@
138
14
139
15
.PHONY: all tbb tbb-clean
140
16
141
- # Order is important in Windows' case. See PKG_LIBS above
142
17
all: tbb $(SHLIB)
143
18
144
19
# TBB needs to be built before our C++ sources are built, so that
@@ -148,20 +23,7 @@ $(OBJECTS): tbb
148
23
# NOTE: TBB libraries are installed via install.libs.R.
149
24
# However, we need to copy headers here so that they are visible during compilation.
150
25
tbb: tbb-clean
151
- ifdef TBB_LIB
152
- @echo "(tbb) Using system (Intel / OneAPI) TBB library."
153
- @echo "(tbb) TBB_LIB = $(TBB_LIB)"
154
- @echo "(tbb) TBB_INC = $(TBB_INC)"
155
- @mkdir -p ../inst/include
156
- @cp -R $(TBB_INC)/oneapi ../inst/include/ 2> /dev/null || :
157
- @cp -R $(TBB_INC)/serial ../inst/include/ 2> /dev/null || :
158
- @cp -R $(TBB_INC)/tbb ../inst/include/ 2> /dev/null || :
159
- else
160
- @echo "(tbb) Building TBB using bundled sources ..."
161
- @mkdir -p ../inst/include
162
- @cp -R tbb/include/* ../inst/include/
163
- @(cd tbb; mkdir -p build; cd build; cmake -DTBB_TEST=0 ..; cmake --build .; mkdir -p lib_release; cp -R *_relwithdebinfo/ lib_release/)
164
- endif
26
+ TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" TBB_NAME="$(TBB_NAME)" @R@ -s -f install.libs.R --args build
165
27
166
28
# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
167
29
# as we may be writing to those locations in multiarch builds
@@ -170,13 +32,3 @@ tbb-clean:
170
32
@rm -rf ../inst/include/oneapi
171
33
@rm -rf ../inst/include/tbb_local
172
34
@rm -rf ../inst/include/serial
173
-
174
- clean: tbb-clean
175
- ifdef TBB_LIB
176
- @echo "Nothing to clean for TBB."
177
- else
178
- @(cd tbb/src; make clean)
179
- endif
180
-
181
-
182
- endif
0 commit comments