11
2- PKG_CXXFLAGS = @CXX11STD@
2+ CMAKE = @CMAKE@
3+ R = @R@
34
4- TBB_LIB = @TBB_LIB@
5- TBB_INC = @TBB_INC@
5+ TBB_LIB = @TBB_LIB@
6+ TBB_INC = @TBB_INC@
7+ TBB_NAME = @TBB_NAME@
8+ TBB_MALLOC_NAME = @TBB_MALLOC_NAME@
69
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
10+ PKG_CPPFLAGS = @PKG_CPPFLAGS@
11+ PKG_CXXFLAGS = @PKG_CXXFLAGS@
1312
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
13+ PKG_LIBS = @PKG_LIBS@ @PKG_LIBS_EXTRA@
2214
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
87- PKG_CXXFLAGS += -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1
88-
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
138-
139- .PHONY: all tbb tbb-clean
140-
141- # Order is important in Windows' case. See PKG_LIBS above
14215all: tbb $(SHLIB)
14316
14417# TBB needs to be built before our C++ sources are built, so that
@@ -148,21 +21,11 @@ $(OBJECTS): tbb
14821# NOTE: TBB libraries are installed via install.libs.R.
14922# However, we need to copy headers here so that they are visible during compilation.
15023tbb: 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/src && $(MAKE_CMD) $(MAKE_ARGS) info)
164- @(cd tbb/src && $(MAKE_CMD) $(MAKE_ARGS) $(MAKE_TARGETS) $(MAKE_LOG))
165- endif
24+ TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" \
25+ TBB_NAME="$(TBB_NAME)" TBB_MALLOC_NAME="$(TBB_MALLOC_NAME)" \
26+ CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
27+ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
28+ CMAKE="$(CMAKE)" "@R@" -s -f install.libs.R --args build
16629
16730# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
16831# as we may be writing to those locations in multiarch builds
@@ -171,13 +34,3 @@ tbb-clean:
17134 @rm -rf ../inst/include/oneapi
17235 @rm -rf ../inst/include/tbb_local
17336 @rm -rf ../inst/include/serial
174-
175- clean: tbb-clean
176- ifdef TBB_LIB
177- @echo "Nothing to clean for TBB."
178- else
179- @(cd tbb/src; make clean)
180- endif
181-
182-
183- endif
0 commit comments