-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathconfigure.win
executable file
·125 lines (102 loc) · 2.77 KB
/
configure.win
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
# Script used to generate `Makevars.win` from `Makevars.win.in`
# on Windows
###########################
# find compiler and flags #
###########################
R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"
# As described in "Using C++ code" in "Writing R Extensions",
# Rtools35 shipped with g++ 4.9, which didn't support C++17.
#
# Testing here for C++17 support, to account for that possibility
# and to continue supporting R 3.6.
#
CXX17=`"${R_EXE}" CMD config CXX17`
CXX17STD=`"${R_EXE}" CMD config CXX17STD`
CXX="${CXX17} ${CXX17STD}"
CXXFLAGS=`"${R_EXE}" CMD config CXX17FLAGS`
CXX_STD="CXX17"
cpp17_supported="yes"
if test "${CXX17}" = "";
then
cpp17_supported="no"
CXX11=`"${R_EXE}" CMD config CXX11`
CXX11STD=`"${R_EXE}" CMD config CXX11STD`
CXX="${CXX11} ${CXX11STD}"
CXXFLAGS=`"${R_EXE}" CMD config CXX11FLAGS`
CXX_STD="CXX11"
fi
echo "checking whether C++17 is supported...${cpp17_supported}"
CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`
# LightGBM-specific flags
LGB_CPPFLAGS=""
#########
# Eigen #
#########
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY -DEIGEN_DONT_PARALLELIZE"
###############
# MM_PREFETCH #
###############
ac_mm_prefetch="no"
cat > conftest.cpp <<EOL
#include <xmmintrin.h>
int main() {
int a = 0;
_mm_prefetch(&a, _MM_HINT_NTA);
return 0;
}
EOL
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_prefetch="yes"
rm -f ./conftest
rm -f ./conftest.cpp
echo "checking whether MM_PREFETCH works...${ac_mm_prefetch}"
if test "${ac_mm_prefetch}" = "yes";
then
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DMM_PREFETCH=1"
fi
############
# MM_ALLOC #
############
ac_mm_malloc="no"
cat > conftest.cpp <<EOL
#include <mm_malloc.h>
int main() {
char *a = (char*)_mm_malloc(8, 16);
_mm_free(a);
return 0;
}
EOL
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc="yes"
rm -f ./conftest
rm -f ./conftest.cpp
echo "checking whether MM_MALLOC works...${ac_mm_malloc}"
if test "${ac_mm_malloc}" = "yes";
then
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DMM_MALLOC=1"
fi
#############
# INET_PTON #
#############
ac_inet_pton="no"
cat > conftest.cpp <<EOL
#include <ws2tcpip.h>
int main() {
int (*fptr)(int, const char*, void*);
fptr = &inet_pton;
return 0;
}
EOL
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_inet_pton="yes"
rm -f ./conftest
rm -f ./conftest.cpp
echo "checking whether INET_PTON works...${ac_inet_pton}"
if test "${ac_inet_pton}" = "yes";
then
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DWIN_HAS_INET_PTON=1"
fi
# Generate Makevars.win from Makevars.win.in
sed -e \
"s/@CXX_STD@/$CXX_STD/" \
< src/Makevars.win.in > src/Makevars.win
sed -e \
"s/@LGB_CPPFLAGS@/$LGB_CPPFLAGS/" \
< src/Makevars.win.in > src/Makevars.win