title: Why am I getting the following syntax error with autoconf?
body: <p>I have the following line in autoconf:</p>
  
  <pre><code>AX_CHECK_COMPILE_FLAG([-std=c++0x], [CXXFLAGS="$CXXFLAGS -std=c++0x"], AC_MSG_ERROR([Need C++11 support]))
  </code></pre>
  
  <p>aclocal, autoconf and automake -a -c go smoothly.</p>
  
  <p>However, when I run configure, I get the error:</p>
  
  <pre><code>./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)'
  </code></pre>
  
  <p>Any ideas why?</p>
  
  <p>EDIT: This seems to be different than the other questions, because </p>
  
  <pre><code>   AX_CHECK_COMPILE_FLAG(-std=c++0x)
  </code></pre>
  
  <p>by itself works...</p>
  
  <p>EDIT:</p>
  
  <p>Here is a full configure.ac</p>
  
  <pre><code># 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 &gt;= 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
  # --&gt; 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
  </code></pre>