File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11CXX_FLAGS =-Wall
2+ CXX =g++
3+
4+ HAS_CPP14 =$(shell \
5+ echo > /tmp/dummy.cpp ; \
6+ if $(CXX ) -std=c++14 -c -o /dev/null /tmp/dummy.cpp 2>/dev/null ; then \
7+ echo yes ; \
8+ else \
9+ echo no ; \
10+ fi)
11+
12+ HAS_CPP11 =$(shell \
13+ echo > /tmp/dummy.cpp ; \
14+ if $(CXX ) -std=c++11 -c -o /dev/null /tmp/dummy.cpp 2>/dev/null ; then \
15+ echo yes ; \
16+ else \
17+ echo no ; \
18+ fi)
19+
20+ ifeq ($(HAS_CPP14 ) , yes)
21+ PREFER_STANDARD:=cpp14
22+ else
23+ ifeq ($(HAS_CPP11 ) , yes)
24+ PREFER_STANDARD:=cpp11
25+ endif
26+ endif
227
328all : examples
429
530example_% _cpp14 : % .cpp
6- g++ -std=c++14 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
31+ $( CXX ) -std=c++14 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
732
833example_% _cpp11 : % .cpp
9- g++ -std=c++11 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
34+ $( CXX ) -std=c++11 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
1035
1136example_% _cpp98 : % .cpp
12- g++ -std=c++98 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
37+ $( CXX ) -std=c++98 -o $@ $^ $(CXX_FLAGS ) $($@ _cxx_flags) $($@ _ld_flags)
1338
1439clean :
1540 rm -fr example_*
Original file line number Diff line number Diff line change 11include ../common.mk
22
3- examples : example_test_cpp14 example_test_cpp11
3+ ifeq ($(HAS_CPP14 ) , yes)
4+ examples : example_test_cpp14
5+ endif
6+
7+ ifeq ($(HAS_CPP11 ) , yes)
8+ examples : example_test_cpp11
9+ endif
Original file line number Diff line number Diff line change 11include ../common.mk
22
3+
4+ ifeq ($(HAS_CPP14 ) , yes)
5+ examples : \
6+ example_codestyle_cpp14 \
7+ example_compile_cpp14 \
8+ example_oop_cpp14 \
9+ example_preprocess_cpp14
10+ endif
11+
12+ ifeq ($(HAS_CPP11 ) , yes)
313examples : \
4- example_codestyle_cpp14 example_codestyle_cpp11 \
5- example_compile_cpp14 example_compile_cpp11 \
6- example_oop_cpp14 example_oop_cpp11 \
7- example_preprocess_cpp14 example_preprocess_cpp11
14+ example_codestyle_cpp11 \
15+ example_compile_cpp11 \
16+ example_oop_cpp11 \
17+ example_preprocess_cpp11
18+ endif
819
920# example_preprocess_cpp98 is showing version check with compile failed.
1021# please explicit using `make example_preprocess_cpp98` under section1 folder
Original file line number Diff line number Diff line change 11include ../common.mk
22
3+ ifeq ($(HAS_CPP14 ) , yes)
34examples : \
4- example_auto_cpp14 example_auto_cpp11 \
5- example_const_cpp14 example_const_cpp11 \
6- example_exception_cpp14 example_exception_cpp11 \
7- example_lambda_cpp14 example_lambda_cpp11 \
8- example_smart_ptr_cpp14 example_smart_ptr_cpp11
5+ example_auto_cpp14 \
6+ example_const_cpp14 \
7+ example_exception_cpp14 \
8+ example_lambda_cpp14 \
9+ example_smart_ptr_cpp14
10+ endif
11+
12+ ifeq ($(HAS_CPP11 ) , yes)
13+ examples : \
14+ example_exception_cpp11
15+ endif
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ include ../common.mk
33example_thread_cpp14_ld_flags =-lpthread
44example_thread_cpp11_ld_flags =-lpthread
55
6+
7+ ifeq ($(HAS_CPP14 ) , yes)
68examples : \
7- example_algo_cpp14 example_algo_cpp11 \
8- example_container_cpp14 example_container_cpp11 \
9- example_string_cpp14 example_string_cpp11 \
10- example_thread_cpp14 example_thread_cpp11
9+ example_algo_cpp14 \
10+ example_container_cpp14 \
11+ example_string_cpp14 \
12+ example_thread_cpp14
13+ endif
You can’t perform that action at this time.
0 commit comments