configure: test for presence of C++ compiler
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/configure b/configure
index 25c4142..c02a978 100755
--- a/configure
+++ b/configure
@@ -10,6 +10,7 @@
fi
cc=gcc
+cxx=g++
for opt do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
@@ -30,6 +31,8 @@
;;
--cc=*) cc="$optarg"
;;
+ --cxx=*) cxx="$optarg"
+ ;;
*)
echo "ERROR: unkown option $opt"
echo "Try '$0 --help' for more information"
@@ -126,6 +129,13 @@
printf " '%s'" "$0" "$@" >> $config_host_mak
echo >> $config_host_mak
+do_cxx() {
+ # Run the compiler, capturing its output to the log.
+ echo $cxx "$@" >> config.log
+ $cxx "$@" >> config.log 2>&1 || return $?
+ return 0
+}
+
do_cc() {
# Run the compiler, capturing its output to the log.
echo $cc "$@" >> config.log
@@ -151,10 +161,6 @@
fatal "You can run configure with --disable-werror to bypass this check."
}
-compile_object() {
- do_cc $CFLAGS -c -o $TMPO $TMPC
-}
-
compile_prog() {
local_cflags="$1"
local_ldflags="$2 $LIBS"
@@ -162,6 +168,13 @@
do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
}
+compile_prog_cxx() {
+ local_cflags="$1"
+ local_ldflags="$2 $LIBS"
+ echo "Compiling test case $3" >> config.log
+ do_cxx $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
+}
+
has() {
type "$1" >/dev/null 2>&1
}
@@ -267,6 +280,22 @@
fi
print_config "statx" "$statx"
+##########################################
+# check for C++
+has_cxx="no"
+cat > $TMPC << EOF
+#include <iostream>
+int main(int argc, char **argv)
+{
+ std::cout << "Test";
+ return 0;
+}
+EOF
+if compile_prog_cxx "" "" "C++"; then
+ has_cxx="yes"
+fi
+print_config "C++" "$has_cxx"
+
#############################################################################
if test "$__kernel_rwf_t" = "yes"; then
@@ -281,8 +310,12 @@
if test "$statx" = "yes"; then
output_sym "CONFIG_HAVE_STATX"
fi
+if test "$has_cxx" = "yes"; then
+ output_sym "CONFIG_HAVE_CXX"
+fi
echo "CC=$cc" >> $config_host_mak
+echo "CXX=$cxx" >> $config_host_mak
# generate compat.h
compat_h="src/include/liburing/compat.h"