fix compile with MINGW

pull/2/head
weidai 2013-01-26 17:15:07 +00:00
parent 334a611e8a
commit ed7652256c
2 changed files with 14 additions and 13 deletions

View File

@ -1,5 +1,5 @@
CXXFLAGS = -DNDEBUG -g -O2 CXXFLAGS = -DNDEBUG -g -O2
#CXXFLAGS = -g # -O3 fails to link on Cygwin GCC version 4.5.3
# -fPIC is supported. Please report any breakage of -fPIC as a bug. # -fPIC is supported. Please report any breakage of -fPIC as a bug.
# CXXFLAGS += -fPIC # CXXFLAGS += -fPIC
# the following options reduce code size, but breaks link or makes link very slow on some systems # the following options reduce code size, but breaks link or makes link very slow on some systems
@ -13,6 +13,9 @@ EGREP = egrep
UNAME = $(shell uname) UNAME = $(shell uname)
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64") ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun") IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
IS_LINUX = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -c "linux")
IS_MINGW = $(shell $(CXX) -dumpmachine 2>&1 | $(EGREP) -c "mingw")
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang version")
# Default prefix for make install # Default prefix for make install
ifeq ($(PREFIX),) ifeq ($(PREFIX),)
@ -28,11 +31,9 @@ ifeq ($(ISX86),1)
GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])") GCC42_OR_LATER = $(shell $(CXX) -v 2>&1 | $(EGREP) -c "^gcc version (4.[2-9]|[5-9])")
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)") INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])") ICC111_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\) ([2-9][0-9]|1[2-9]|11\.[1-9])")
CLANG_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang version")
GAS210_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])") GAS210_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
GAS217_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])") GAS217_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
GAS219_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])") GAS219_OR_LATER = $(shell $(CXX) -xc -c /dev/null -Wa,-v -o/dev/null 2>&1 | $(EGREP) -c "GNU assembler version (2\.19|2\.[2-9]|[3-9])")
ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
ifneq ($(GCC42_OR_LATER),0) ifneq ($(GCC42_OR_LATER),0)
ifeq ($(UNAME),Darwin) ifeq ($(UNAME),Darwin)
@ -51,10 +52,6 @@ CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
endif endif
endif endif
ifneq ($(CLANG_COMPILER),0)
CXXFLAGS += -Wno-tautological-compare
endif
ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10 ifeq ($(GAS210_OR_LATER),0) # .intel_syntax wasn't supported until GNU assembler 2.10
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
else else
@ -70,10 +67,6 @@ CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif endif
endif endif
ifeq ($(ISMINGW),1)
LDLIBS += -lws2_32
endif
endif # ISX86 endif # ISX86
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
@ -82,7 +75,11 @@ else
CXXFLAGS += -pipe CXXFLAGS += -pipe
endif endif
ifeq ($(UNAME),Linux) ifeq ($(IS_MINGW),1)
LDLIBS += -lws2_32
endif
ifeq ($(IS_LINUX),1)
LDFLAGS += -pthread LDFLAGS += -pthread
ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0) ifneq ($(shell uname -i | $(EGREP) -c "(_64|d64)"),0)
M32OR64 = -m64 M32OR64 = -m64
@ -106,6 +103,10 @@ LDLIBS += -lnsl -lsocket
M32OR64 = -m$(shell isainfo -b) M32OR64 = -m$(shell isainfo -b)
endif endif
ifneq ($(CLANG_COMPILER),0)
CXXFLAGS += -Wno-tautological-compare
endif
ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler ifneq ($(IS_SUN_CC),0) # override flags for CC Sun C++ compiler
CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64) CXXFLAGS = -DNDEBUG -O -g0 -native -template=no%extdef $(M32OR64)
LDFLAGS = LDFLAGS =

2
misc.h
View File

@ -141,7 +141,7 @@ const T & Singleton<T, F, instance>::Ref(CRYPTOPP_NOINLINE_DOTDOTDOT) const
// ************** misc functions *************** // ************** misc functions ***************
#if (!__STDC_WANT_SECURE_LIB__) #if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED))
inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count) inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
{ {
if (count > sizeInBytes) if (count > sizeInBytes)