diff --git a/Makefile.am b/Makefile.am index 3ec4b23d..cc82e205 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1153,6 +1153,24 @@ check_local += check-local-build-headers ############################################################################### +if HAS_CXX +%.build-headers-test-cxx.c: % + mkdir -p "$(dir $@)" + printf "#include \n#include <$$(echo "$<" | sed 's|.*\\nint main(void) { return 0; }" > $@ + +%.build-headers-test-cxx.o: %.build-headers-test-cxx.c + $(CXX) -Wall -Werror -I$(srcdir)/include -I$(builddir)/include -D_NL_NO_WARN_DEPRECATED_HEADER -c -o $@ $< + +BUILD_HEADERS_OBJS_CXX = $(patsubst %,%.build-headers-test-cxx.o,$(public_headers)) +check-local-build-headers-cxx: $(BUILD_HEADERS_OBJS_CXX) +else +check-local-build-headers-cxx: +endif + +check_local += check-local-build-headers-cxx + +############################################################################### + check-local: $(check_local) .PHONY: $(check_local) diff --git a/configure.ac b/configure.ac index cce0ad0b..f61a73a1 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,7 @@ AC_SUBST(LT_AGE) AC_PROG_CC AM_PROG_CC_C_O +AC_PROG_CXX AC_PROG_INSTALL LT_INIT AC_PROG_MKDIR_P @@ -72,6 +73,15 @@ AC_CHECK_PROGS(YACC, 'bison -y') AC_C_CONST AC_C_INLINE +AC_LANG_PUSH([C++]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#ifndef __cplusplus + #error "broken C++" + #endif]])],, + [CXX=;]) +AC_LANG_POP([C++]) +AM_CONDITIONAL([HAS_CXX], [test "x$CXX" != x]) + PKG_CHECK_MODULES([CHECK], [check >= 0.9.0], [has_check="yes"], [AC_MSG_WARN([*** Disabling building of unit tests]) @@ -155,6 +165,11 @@ fi AC_OUTPUT +CXX_MSG="none" +if test "x$CXX" != x ; then + CXX_MSG="[$CXX]" +fi + echo echo "libnl $LIBNL_VERSION configuration${LIBNL_GIT_SHA:+ (git:$LIBNL_GIT_SHA)}:" echo " --enable-pthreads=$enable_pthreads" @@ -164,4 +179,5 @@ echo " --enable-debug=$enable_debug" echo " --enable-cli=$enable_cli" echo echo " check: $has_check" +echo " CXX: $CXX_MSG (only used for tests)" echo