Skip to content

Commit df8a2d9

Browse files
committed
🔨 Windows configure
* This is the first attempt to create a configure script for Windows. It is built on the previous Makevars from Main, but uses Shell scripts to determine the CXXSTD. * The cleanup script have been updated accordingly.
1 parent 19b49e6 commit df8a2d9

File tree

4 files changed

+68
-12
lines changed

4 files changed

+68
-12
lines changed

cleanup

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
rm -f config.*
44
rm -f src/Makevars
5+
rm -f src/Makevars.win
56
rm -rf autom4te.cache

configure.win

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
# Script used to generate Makevars.win from Makevars.win.in on Windows
4+
# It checks for available C++ standards in descending order:
5+
# C++23, then C++20, then C++17.
6+
# If none is available, installation is aborted.
7+
8+
# Locate R executable (using R_HOME and R_ARCH_BIN provided by R)
9+
R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"
10+
11+
# First try C++23
12+
CXX23=`"${R_EXE}" CMD config CXX23`
13+
CXX23STD=`"${R_EXE}" CMD config CXX23STD`
14+
if test "${CXX23}" != ""; then
15+
CXX="${CXX23} ${CXX23STD}"
16+
CXXFLAGS=`"${R_EXE}" CMD config CXX23FLAGS`
17+
CXX_STD="CXX23"
18+
cpp_supported="yes"
19+
else
20+
cpp_supported="no"
21+
fi
22+
23+
# If C++23 is not supported, try C++20
24+
if test "${cpp_supported}" = "no"; then
25+
CXX20=`"${R_EXE}" CMD config CXX20`
26+
CXX20STD=`"${R_EXE}" CMD config CXX20STD`
27+
if test "${CXX20}" != ""; then
28+
CXX="${CXX20} ${CXX20STD}"
29+
CXXFLAGS=`"${R_EXE}" CMD config CXX20FLAGS`
30+
CXX_STD="CXX20"
31+
cpp_supported="yes"
32+
fi
33+
fi
34+
35+
# If neither C++23 nor C++20 is supported, try C++17
36+
if test "${cpp_supported}" = "no"; then
37+
CXX17=`"${R_EXE}" CMD config CXX17`
38+
CXX17STD=`"${R_EXE}" CMD config CXX17STD`
39+
if test "${CXX17}" != ""; then
40+
CXX="${CXX17} ${CXX17STD}"
41+
CXXFLAGS=`"${R_EXE}" CMD config CXX17FLAGS`
42+
CXX_STD="CXX17"
43+
cpp_supported="yes"
44+
fi
45+
fi
46+
47+
echo "Using C++ standard: $CXX_STD"
48+
49+
# Abort if none of the standards are supported
50+
if test "${cpp_supported}" = "no"; then
51+
echo "ERROR: Your C++ compiler does not support C++17 or later."
52+
exit 1
53+
fi
54+
55+
# Retrieve additional flags from R configuration if needed.
56+
CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`
57+
58+
# Generate Makevars.win from Makevars.win.in by substituting the C++ standard.
59+
# It replaces the placeholder @CXX_STD@ with the detected CXX_STD.
60+
sed -e "s/@CXX_STD@/$CXX_STD/" < src/Makevars.win.in > src/Makevars.win
61+
62+
exit 0

src/Makevars.win

-12
This file was deleted.

src/Makevars.win.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CXX_STD = @CXX_STD@
2+
PKG_CXX_STD = @CXX_STD@
3+
4+
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
5+
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

0 commit comments

Comments
 (0)