VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-10-01 00:48:57 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-10-01 00:48:57 +0200
commitda49ebb927cc15e5d77574b608b3a59b05cebc56 (patch)
tree13d28e6adab424bace72ae7a2b424b2da35d9eb0
parent0df7976e32f7a3b59a6c356a96235b0a8b94cec2 (diff)
downloadVeraCrypt-da49ebb927cc15e5d77574b608b3a59b05cebc56.tar.gz
VeraCrypt-da49ebb927cc15e5d77574b608b3a59b05cebc56.zip
Linux: Better detection of gcc version to correctly enable c++11
This allows to build correctly under CentOS 6 and CentOS 7
-rw-r--r--src/Makefile23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile
index 356f0a7b..ed62a4f0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -195,14 +195,21 @@ ifeq "$(shell uname -s)" "Linux"
# PCSC
C_CXX_FLAGS += $(shell pkg-config --cflags libpcsclite)
-
- # GNU GCC version 11 and higher compile with -std=gnu++17 by default
- # which breaks "byte" definitions in Crypto++ library. So set
- # -std=gnu++14 instead.
- GCC11PLUS := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 11)
- ifeq "$(GCC11PLUS)" "1"
- CXXFLAGS += -std=gnu++14
- endif
+ # Extract the major and minor version numbers of GCC in a combined format for easy comparison
+ GCC_VERSION := $(shell $(CC) -dumpversion | awk -F. '{printf "%d%02d", $$1, $$2}')
+
+ # Set the C++ standard based on the version numbers
+ ifeq ($(shell expr $(GCC_VERSION) \< 408), 1)
+ # GCC version below 4.8 support minimal C++11 features through the switch -std=c++0x
+ CXXFLAGS += -std=c++0x
+ else ifeq ($(GCC_VERSION), 408)
+ # GCC version 4.8 supports C++11 features through the switch -std=gnu++11
+ CXXFLAGS += -std=gnu++11
+ else ifeq ($(shell expr $(GCC_VERSION) \>= 1100), 1)
+ # GNU GCC version 11 and higher compile with -std=gnu++17 by default
+ # which breaks "byte" definitions in Crypto++ library. So set -std=gnu++14 instead.
+ CXXFLAGS += -std=gnu++14
+ endif
ifeq "$(SIMD_SUPPORTED)" "1"