-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
174 lines (147 loc) · 5.22 KB
/
configure.ac
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
AC_INIT([qs2],[0.1.0],[[email protected]])
AC_PATH_PROG([PKGCONF],[pkg-config],[],[$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin:/opt/local/bin])
########################################################
AC_LANG(C++)
: ${R_HOME=`R RHOME`}
PATH_TO_CPP_COMPILER=`"${R_HOME}/bin/R" CMD config CXX`
AC_PROG_CXX([$PATH_TO_CPP_COMPILER])
echo "C++ compiler: $PATH_TO_CPP_COMPILER"
########################################################
### Configure args
AC_ARG_WITH([zstd-force-compile],
AS_HELP_STRING([--with-zstd-force-compile],[Force compilation of bundled zstd source files]),
[zstd_force_compile="true"])
AC_ARG_WITH([zstd-include],
AS_HELP_STRING([--with-zstd-include=INCLUDE_PATH],[the location of zstd header files]),
[zstd_include_path=$withval])
AC_ARG_WITH([zstd-lib],
AS_HELP_STRING([--with-zstd-lib=LIB_PATH],[the location of zstd library files]),
[zstd_lib_path=$withval])
AC_ARG_WITH([TBB],
AS_HELP_STRING([--with-TBB],[Manually select TBB support]),
[using_tbb="true"])
AC_ARG_WITH([dynamic-blocksize],
AS_HELP_STRING([--with-dynamic-blocksize],[Dynamic blocksize, for debugging and testing ONLY]),
[using_dynamic_blocksize="true"])
AC_ARG_WITH([simd],
AS_HELP_STRING([--with-simd],[Manually select SIMD support (options: AVX2, SSE2)]),
[with_simd=$withval])
########################################################
#### Version value function
getVersion()
{
VERSION_STRING=$1
MAJOR=`echo $VERSION_STRING | cut -d. -f1`
MINOR=`echo $VERSION_STRING | cut -d. -f2`
RELEASE=`echo $VERSION_STRING | cut -d. -f3`
echo $(($MAJOR*100000+$MINOR*100+$RELEASE))
}
########################################################
#### Compile ZSTD checks
ZSTD_INCLUDE_PATH=""
ZSTD_LIBS=""
ZSTD_SHLIB=""
ZSTD_CLEAN=""
if test xx$zstd_force_compile = "xxtrue"; then
echo "Compiling zstd from source due to --with-zstd-force-compile"
COMPILE_ZSTD="true"
elif test "xx$zstd_include_path" != "xx"; then
echo "Using user-defined zstd install paths"
ZSTD_LIBS="-L${zstd_lib_path}"
ZSTD_INCLUDE_PATH="-I${zstd_include_path}"
COMPILE_ZSTD="false"
elif test "xx$PKGCONF" != "xx"; then
if "${PKGCONF}" --exists libzstd; then
VERSION_STRING=`${PKGCONF} --modversion libzstd`
VER=`getVersion ${VERSION_STRING}`
if test "${VER}" -ge 100506; then
echo "zstd ${VERSION_STRING} library detected -- skipping zstd compilation"
ZSTD_LIBS=`"${PKGCONF}" --libs libzstd`
ZSTD_INCLUDE_PATH=`"${PKGCONF}" --cflags-only-I libzstd`
COMPILE_ZSTD="false"
else
echo "zstd ${VERSION_STRING} library detected but is lower than bundled version (1.5.2) -- compiling from source"
COMPILE_ZSTD="true"
fi
else
echo "zstd library not detected -- compiling from source"
COMPILE_ZSTD="true"
fi
else
echo "pkg-config not detected -- compiling zstd from source"
COMPILE_ZSTD="true"
fi
if test xx$COMPILE_ZSTD = "xxtrue"; then
ZSTD_LIBS="${LIBS} -lQSZSTD"
ZSTD_INCLUDE_PATH="-IZSTD -IZSTD/common -IZSTD/decompress -IZSTD/compress"
ZSTD_SHLIB="libQSZSTD.a"
ZSTD_CLEAN="\$(LIBZSTD) libQSZSTD.a"
fi
########################################################
#### Dynamic blocksize
if test xx$using_dynamic_blocksize = "xxtrue"; then
echo "Using dynamic blocksize (for debugging and testing ONLY)"
DYNAMIC_BLOCKSIZE_FLAG="-DQS2_DYNAMIC_BLOCKSIZE=1"
else
echo "Fixed blocksize"
fi
########################################################
#### Compile TBB checks, disable TBB by default
if test xx$using_tbb = "xxtrue"; then
echo "Using TBB"
TBB_FLAG=""
else
echo "Not using TBB"
TBB_FLAG="-DRCPP_PARALLEL_USE_TBB=0"
fi
########################################################
#### Check if -latomic flag is needed, only necessary if using TBB
if test xx$using_tbb = "xxtrue"; then
# Check if simple C++ program using atomic header can compile using AC_COMPILE_IFELSE
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <atomic>
#include <cstdint>
std::atomic<std::uint64_t> x1{0};
std::atomic<std::uint8_t> x2{0};
std::atomic<char*> x3{nullptr};
std::atomic<bool> x4{false};
int main() {
x1.fetch_add(1);
x2.fetch_add(1);
char temp = 'a';
x3.store(&temp);
x4.store(true);
return 0;
}
]])], [NEED_LIBATOMIC="no"], [NEED_LIBATOMIC="yes"])
if test xx$NEED_LIBATOMIC = "xxyes"; then
echo "Requires -latomic flag"
COMPILER_SPECIFIC_LIBS="-latomic"
else
echo "Does not require -latomic flag"
COMPILER_SPECIFIC_LIBS=""
fi
else
COMPILER_SPECIFIC_LIBS=""
fi
########################################################
#### Compile SIMD checks
SIMD_FLAG=""
if test xx$with_simd = "xxAVX2"; then
echo "Using AVX2"
SIMD_FLAG="-mavx2"
elif test xx$with_simd = "xxSSE2"; then
echo "Using SSE2"
SIMD_FLAG="-msse2"
fi
########################################################
AC_SUBST([COMPILER_SPECIFIC_LIBS], $COMPILER_SPECIFIC_LIBS)
AC_SUBST([ZSTD_INCLUDE_PATH], $ZSTD_INCLUDE_PATH)
AC_SUBST([ZSTD_LIBS], $ZSTD_LIBS)
AC_SUBST([ZSTD_SHLIB], $ZSTD_SHLIB)
AC_SUBST([ZSTD_CLEAN], $ZSTD_CLEAN)
AC_SUBST([DYNAMIC_BLOCKSIZE_FLAG], $DYNAMIC_BLOCKSIZE_FLAG)
AC_SUBST([TBB_FLAG], $TBB_FLAG)
AC_SUBST([SIMD_FLAG], $SIMD_FLAG)
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT