I have the following line in autoconf:
AX_CHECK_COMPILE_FLAG([-std=c++0x], [CXXFLAGS="$CXXFLAGS -std=c++0x"], AC_MSG_ERROR([Need C++11 support]))
aclocal, autoconf and automake -a -c go smoothly.
However, when I run configure, I get the error:
./configure: line 2142: syntax error near unexpected token `-std=c++0x,'
./configure: line 2142: `AX_CHECK_COMPILE_FLAG(-std=c++0x, CXXFLAGS="$CXXFLAGS -std=c++0x", as_fn_error $? "Need C++11 support" "$LINENO" 5)'
Any ideas why?
EDIT: This seems to be different than the other questions, because
AX_CHECK_COMPILE_FLAG(-std=c++0x)
by itself works...
EDIT:
Here is a full configure.ac
# initial information about the project
AC_INIT([myproject],[0.1],[project@gmail.com])
# check if the source folder is available
AC_CONFIG_SRCDIR([src/main.cpp])
# check for C++ preprocessor and compiler
CXXFLAGS="$CXXFLAGS -std=c++0x"
CXXFLAGS="$CXXFLAGS -O3"
AX_CHECK_COMPILE_FLAG([-std=c++0x], [CXXFLAGS="$CXXFLAGS -std=c++0x"], AC_MSG_ERROR([Need C++11 support]))
AC_PROG_CXXCPP
AC_PROG_CXX
AC_PROG_CC
# automake initialization (mandatory) including a check for automake API version >= 1.9
AM_INIT_AUTOMAKE([1.9])
# use the C++ compiler for the following checks
AC_LANG([C++])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([string])
AC_CHECK_HEADERS([iostream])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
# distribute additional compiler and linker flags among Makefiles
# --> set and change these variables instead of CXXFLAGS or LDFLAGS (for user only)
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
# files to generate via autotools (prepare .am or .in source files)
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
# finally this generates the Makefiles etc. for the build
AC_OUTPUT