Index: lib/clang/llvm.build.mk =================================================================== --- lib/clang/llvm.build.mk +++ lib/clang/llvm.build.mk @@ -95,7 +95,7 @@ CFLAGS+= -fdata-sections LDFLAGS+= -Wl,--gc-sections -CXXFLAGS+= -std=c++11 +CXXSTD?= c++11 CXXFLAGS+= -fno-exceptions CXXFLAGS+= -fno-rtti CXXFLAGS.clang+= -stdlib=libc++ Index: lib/libc++/Makefile =================================================================== --- lib/libc++/Makefile +++ lib/libc++/Makefile @@ -76,9 +76,7 @@ CFLAGS+= -nostdlib CFLAGS+= -D_LIBCPP_BUILDING_LIBRARY CFLAGS+= -DLIBCXXRT -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++11 -.endif +CXXSTD?= c++11 LIBADD+= cxxrt INCSGROUPS= STD EXP EXT Index: lib/libc++experimental/Makefile =================================================================== --- lib/libc++experimental/Makefile +++ lib/libc++experimental/Makefile @@ -20,8 +20,6 @@ CXXFLAGS+= -nostdlib CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY CXXFLAGS+= -DLIBCXXRT -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++14 -.endif +CXXSTD?= c++14 .include Index: lib/libc++fs/Makefile =================================================================== --- lib/libc++fs/Makefile +++ lib/libc++fs/Makefile @@ -22,8 +22,6 @@ CXXFLAGS+= -nostdlib CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY CXXFLAGS+= -DLIBCXXRT -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++14 -.endif +CXXSTD?= c++14 .include Index: lib/libc/tests/stdlib/Makefile =================================================================== --- lib/libc/tests/stdlib/Makefile +++ lib/libc/tests/stdlib/Makefile @@ -50,8 +50,8 @@ CFLAGS+= -I${.CURDIR} -CXXFLAGS.cxa_thread_atexit_test+= -std=c++11 -CXXFLAGS.cxa_thread_atexit_nothr_test+= -std=c++11 +CXXSTD.cxa_thread_atexit_test= c++11 +CXXSTD.cxa_thread_atexit_nothr_test= c++11 LIBADD.cxa_thread_atexit_test+= pthread .for t in h_getopt h_getopt_long Index: lib/libclang_rt/Makefile.inc =================================================================== --- lib/libclang_rt/Makefile.inc +++ lib/libclang_rt/Makefile.inc @@ -41,4 +41,4 @@ CXXFLAGS+= -fvisibility-inlines-hidden CXXFLAGS+= -fvisibility=hidden CFLAGS+= -I${CRTSRC}/lib -CXXFLAGS+= -std=c++11 +CXXSTD?= c++11 Index: lib/libcxxrt/Makefile =================================================================== --- lib/libcxxrt/Makefile +++ lib/libcxxrt/Makefile @@ -22,9 +22,7 @@ WARNS= 0 CFLAGS+= -isystem ${SRCDIR} -nostdinc++ -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++11 -.endif +CXXSTD?= c++11 VERSION_MAP= ${.CURDIR}/Version.map .include Index: lib/libgcc_eh/Makefile.inc =================================================================== --- lib/libgcc_eh/Makefile.inc +++ lib/libgcc_eh/Makefile.inc @@ -27,9 +27,7 @@ .endfor CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY -.if empty(CXXFLAGS:M-std=*) -CXXFLAGS+= -std=c++11 -.endif +CXXSTD?= c++11 CXXFLAGS+= -fno-rtti STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC # Probably need to just move this earlier or use CXXFLAGS Index: lib/libomp/Makefile =================================================================== --- lib/libomp/Makefile +++ lib/libomp/Makefile @@ -53,9 +53,9 @@ CFLAGS+= -ffunction-sections CFLAGS+= -fdata-sections CXXFLAGS+= -fvisibility-inlines-hidden -CXXFLAGS+= -std=c++11 CXXFLAGS+= -fno-exceptions CXXFLAGS+= -fno-rtti +CXXSTD?= c++11 LDFLAGS+= -Wl,--warn-shared-textrel LDFLAGS+= -Wl,--gc-sections Index: lib/ofed/libibnetdisc/Makefile =================================================================== --- lib/ofed/libibnetdisc/Makefile +++ lib/ofed/libibnetdisc/Makefile @@ -31,9 +31,7 @@ CFLAGS+= -DHAVE_CONFIG_H=1 CFLAGS+= -I${_spath} CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband -.if ${COMPILER_FEATURES:Mc++11} -CXXFLAGS+= -std=c++11 -.endif +CXXSTD?= c++11 VERSION_MAP= ${_spath}/libibnetdisc.map .include Index: share/mk/bsd.progs.mk =================================================================== --- share/mk/bsd.progs.mk +++ share/mk/bsd.progs.mk @@ -22,8 +22,8 @@ .if defined(PROG) # just one of many -PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \ - PROGNAME SRCS STRIP WARNS +PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE CSTD CXXSTD DPSRCS MAN \ + NO_WERROR PROGNAME SRCS STRIP WARNS PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \ LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS} .for v in ${PROG_VARS:O:u} Index: share/mk/bsd.sys.mk =================================================================== --- share/mk/bsd.sys.mk +++ share/mk/bsd.sys.mk @@ -24,6 +24,19 @@ .else # CSTD CFLAGS+= -std=${CSTD} .endif # CSTD + +.if ${COMPILER_FEATURES:Mc++11} +CXXSTD?= c++11 +.elif ${COMPILER_TYPE} == "gcc" +# Prior versions of g++ support CC++98 with GNU extensions. +CXXSTD?= gnu++98 +.else +# Assume that the compiler supports at least C++98. +CXXSTD?= c++98 +.endif +CXXFLAGS+= -std=${CXXSTD} +# CXXSTD + # -pedantic is problematic because it also imposes namespace restrictions #CFLAGS+= -pedantic .if defined(WARNS) Index: share/mk/googletest.test.inc.mk =================================================================== --- share/mk/googletest.test.inc.mk +++ share/mk/googletest.test.inc.mk @@ -1,13 +1,9 @@ # $FreeBSD$ -# XXX: this should be defined in bsd.sys.mk -CXXSTD?= c++11 - GTESTS_CXXFLAGS+= -DGTEST_HAS_POSIX_RE=1 GTESTS_CXXFLAGS+= -DGTEST_HAS_PTHREAD=1 GTESTS_CXXFLAGS+= -DGTEST_HAS_STREAM_REDIRECTION=1 GTESTS_CXXFLAGS+= -frtti -GTESTS_CXXFLAGS+= -std=${CXXSTD} # XXX: src.libnames.mk should handle adding this directory. GTESTS_CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private Index: usr.bin/dtc/Makefile =================================================================== --- usr.bin/dtc/Makefile +++ usr.bin/dtc/Makefile @@ -6,7 +6,7 @@ WARNS?= 3 -CXXFLAGS+= -std=c++11 -fno-rtti -fno-exceptions +CXXFLAGS+= -fno-rtti -fno-exceptions NO_SHARED?=NO Index: usr.sbin/pmc/Makefile =================================================================== --- usr.sbin/pmc/Makefile +++ usr.sbin/pmc/Makefile @@ -6,7 +6,8 @@ PROG_CXX= pmc MAN= WARNS?= 3 -CXXFLAGS+= -O0 -std=c++14 +CXXFLAGS+= -O0 +CXXSTD= c++14 CWARNFLAGS.gcc+= -Wno-redundant-decls LIBADD= kvm pmc m ncursesw pmcstat elf