2020-07-29 05:05:59 +03:00
|
|
|
# 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"
|
2023-03-07 06:57:18 +03:00
|
|
|
|
|
|
|
# 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}"
|
|
|
|
|
2021-08-14 22:04:12 +03:00
|
|
|
CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`
|
2020-07-29 05:05:59 +03:00
|
|
|
|
|
|
|
# LightGBM-specific flags
|
|
|
|
LGB_CPPFLAGS=""
|
|
|
|
|
2021-01-18 15:44:38 +03:00
|
|
|
#########
|
|
|
|
# Eigen #
|
|
|
|
#########
|
|
|
|
|
2022-07-29 19:09:08 +03:00
|
|
|
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DEIGEN_MPL2_ONLY -DEIGEN_DONT_PARALLELIZE"
|
2021-01-18 15:44:38 +03:00
|
|
|
|
2020-07-29 05:05:59 +03:00
|
|
|
###############
|
|
|
|
# MM_PREFETCH #
|
|
|
|
###############
|
|
|
|
|
|
|
|
ac_mm_prefetch="no"
|
|
|
|
|
2021-08-14 22:04:12 +03:00
|
|
|
cat > conftest.cpp <<EOL
|
2020-07-29 05:05:59 +03:00
|
|
|
#include <xmmintrin.h>
|
|
|
|
int main() {
|
|
|
|
int a = 0;
|
|
|
|
_mm_prefetch(&a, _MM_HINT_NTA);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOL
|
|
|
|
|
2021-08-14 22:04:12 +03:00
|
|
|
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_prefetch="yes"
|
2021-10-30 19:14:06 +03:00
|
|
|
rm -f ./conftest
|
|
|
|
rm -f ./conftest.cpp
|
2020-07-29 05:05:59 +03:00
|
|
|
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"
|
|
|
|
|
2021-08-14 22:04:12 +03:00
|
|
|
cat > conftest.cpp <<EOL
|
2020-07-29 05:05:59 +03:00
|
|
|
#include <mm_malloc.h>
|
|
|
|
int main() {
|
|
|
|
char *a = (char*)_mm_malloc(8, 16);
|
|
|
|
_mm_free(a);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EOL
|
|
|
|
|
2021-08-14 22:04:12 +03:00
|
|
|
${CXX} ${CXXFLAGS} ${CPPFLAGS} -o conftest conftest.cpp 2>/dev/null && ./conftest && ac_mm_malloc="yes"
|
2021-10-30 19:14:06 +03:00
|
|
|
rm -f ./conftest
|
|
|
|
rm -f ./conftest.cpp
|
2020-07-29 05:05:59 +03:00
|
|
|
echo "checking whether MM_MALLOC works...${ac_mm_malloc}"
|
|
|
|
|
|
|
|
if test "${ac_mm_malloc}" = "yes";
|
|
|
|
then
|
|
|
|
LGB_CPPFLAGS="${LGB_CPPFLAGS} -DMM_MALLOC=1"
|
|
|
|
fi
|
|
|
|
|
2022-05-24 01:09:22 +03:00
|
|
|
#############
|
|
|
|
# INET_PTON #
|
|
|
|
#############
|
|
|
|
|
|
|
|
ac_inet_pton="no"
|
|
|
|
|
|
|
|
cat > conftest.cpp <<EOL
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
int main() {
|
2022-10-09 07:45:22 +03:00
|
|
|
int (*fptr)(int, const char*, void*);
|
|
|
|
fptr = &inet_pton;
|
2022-05-24 01:09:22 +03:00
|
|
|
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
|
|
|
|
|
2020-07-29 05:05:59 +03:00
|
|
|
# Generate Makevars.win from Makevars.win.in
|
2023-03-07 06:57:18 +03:00
|
|
|
sed -e \
|
|
|
|
"s/@CXX_STD@/$CXX_STD/" \
|
|
|
|
< src/Makevars.win.in > src/Makevars.win
|
2020-07-29 05:05:59 +03:00
|
|
|
sed -e \
|
|
|
|
"s/@LGB_CPPFLAGS@/$LGB_CPPFLAGS/" \
|
|
|
|
< src/Makevars.win.in > src/Makevars.win
|