diff options
Diffstat (limited to 'cpp')
41 files changed, 669 insertions, 197 deletions
diff --git a/cpp/INSTALL.MINGW b/cpp/INSTALL.MINGW new file mode 100644 index 00000000000..cc6e3cf22b4 --- /dev/null +++ b/cpp/INSTALL.MINGW @@ -0,0 +1,128 @@ +====================================================================== +Introduction +====================================================================== + +This file describes the Ice source distribution, including information +about compiler requirements, third-party dependencies, and +instructions for building and testing the distribution. + + http://www.zeroc.com/download.html + +MinGW is only supported for building the Ice extension for Ruby. + +MinGW is not supported for general application development in this +release. + + +====================================================================== +Requirements +====================================================================== + + +Windows version +--------------- + +Ice for MinGW is only supported in Windows XP and Windows 7. + + +MinGW Setup +------------ + +The only supported MinGW version is the one that is included in the +Ruby Development Kit, which you can download here: + + http://rubyinstaller.org/downloads/ + +You must download the file DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe, +which is a self-extracting archive. + +To build Ice with MinGW, you also need to install Cygwin. The Cygwin +installer is available at: + + http://www.cygwin.com/install.html + +When installing Cygwin, make sure you select "make" in the package +list. You do not need to install the MinGW packages from Cygwin. + + +Third-party libraries +--------------------- + +Ice has dependencies on a number of third-party libraries: + +- OpenSSL 1.0 or later +- bzip2 1.0.x +- mcpp 2.7.2 (with patches) + +You do not need to build these packages yourself, as ZeroC supplies a +Windows installer that contains all of the third-party dependencies. + +If you intend to build the third-party dependencies from source, we +recommend downloading the Ice third-party source archive from + + http://www.zeroc.com/download.html + +This archive contains the source distributions for each of the +third-party dependencies, as well as required source patches and +configuration instructions. + +For more information about these dependencies, please refer to +the links below: + +OpenSSL http://www.openssl.org +bzip2 http://sources.redhat.com/bzip2 +mcpp http://mcpp.sourceforge.net + + +====================================================================== +Compilation and Testing +====================================================================== + +Using your favorite Zip tool, unzip the Ice source archive anywhere +you like. + +Open a Cygwin command prompt and change the working directory to the +location of the extracted source archive. For example: + +$ cd ~/Ice-@ver@/cpp + +Update your PATH to include MinGW from the Ruby Development Kit. For +example, if you installed the kit into C:\RubyDevKit-4.5.2, you would +update PATH as follows: + +$ export PATH=/cygdrive/c/RubyDevKit-4.5.2/mingw/bin:$PATH + +Edit config/Make.rules to establish your build configuration. The +comments in the file provide more information. In particular, if +Ice third-party packages are not installed in the default location, +set THIRDPARTY_HOME to the Ice third-party installation directory. + +Now you are ready to build Ice: + +$ make + +This will build the Ice core, libraries, and tests. + +Python is required to run the test suite: + + http://www.python.org/download + +After a successful build, you can run the test suite. Open a Windows +(not Cygwin) command prompt and change the working directory to +Ice-@ver@: + +> cd C:\Ice-@ver@\cpp +> set CPP_COMPILER=MINGW +> python allTests.py + +If everything worked out, you should see lots of "ok" messages. In +case of a failure, the tests abort with "failed". + + +====================================================================== +Installation +====================================================================== + +From a Cygwin command prompt, simply run "make install". This will +install Ice in the directory specified by the "prefix" variable in +config/Make.rules. diff --git a/cpp/Makefile b/cpp/Makefile index b2f079a30a2..67d4542b71c 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -11,7 +11,11 @@ top_srcdir = . include $(top_srcdir)/config/Make.rules -SUBDIRS = config src include test demo +SUBDIRS = config src include test + +ifneq ($(MinGW), yes) +SUBDIRS := $(SUBDIRS) demo +endif INSTALL_SUBDIRS = $(install_bindir) $(install_libdir) $(install_includedir) $(install_configdir) diff --git a/cpp/allTests.py b/cpp/allTests.py index 095a203853b..c0432217228 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -35,7 +35,7 @@ tests = [ ("Slice/errorDetection", ["once"]), ("Slice/keyword", ["once"]), ("Slice/structure", ["once"]), - ("Ice/properties", ["once", "novc6"]), + ("Ice/properties", ["once", "novc6", "nomingw"]), ("Ice/proxy", ["core"]), ("Ice/operations", ["core"]), ("Ice/exceptions", ["core"]), @@ -58,7 +58,7 @@ tests = [ ("Ice/custom", ["core", "novc6", "nossl"]), ("Ice/retry", ["core"]), ("Ice/timeout", ["core"]), - ("Ice/background", ["core"]), + ("Ice/background", ["core", "nomingw"]), ("Ice/servantLocator", ["core"]), ("Ice/interceptor", ["core"]), ("Ice/stringConverter", ["core"]), @@ -67,39 +67,39 @@ tests = [ ("Ice/defaultValue", ["core"]), ("Ice/invoke", ["core", "novc6"]), ("IceSSL/configuration", ["once", "novalgrind"]), # valgrind doesn't work well with openssl - ("IceBox/configuration", ["core", "noipv6", "novc6"]), - ("Freeze/dbmap", ["once", "novc6"]), - ("Freeze/complex", ["once", "novc6"]), - ("Freeze/evictor", ["core", "novc6"]), - ("Freeze/fileLock", ["core", "novc6"]), - ("IceStorm/single", ["service", "novc6", "noappverifier"]), # This test doensn't work with appverifier is sensitive to timeouts. - ("IceStorm/federation", ["service", "novc6"]), - ("IceStorm/federation2", ["service", "novc6"]), - ("IceStorm/stress", ["service", "stress", "novc6", "noappverifier"]), # This test is very slow with appverifier. - ("IceStorm/rep1", ["service", "novc6"]), - ("IceStorm/repgrid", ["service", "novc6"]), - ("IceStorm/repstress", ["service", "noipv6", "stress", "novc6"]), - ("FreezeScript/dbmap", ["once", "novc6"]), - ("FreezeScript/evictor", ["once", "novc6"]), - ("IceGrid/simple", ["service", "novc6"]), - ("IceGrid/fileLock", ["service", "novc6"]), - ("IceGrid/deployer", ["service", "novc6"]), - ("IceGrid/session", ["service", "novc6"]), - ("IceGrid/update", ["service", "novc6"]), - ("IceGrid/activation", ["service", "novc6"]), - ("IceGrid/replicaGroup", ["service", "novc6"]), - ("IceGrid/replication", ["service", "novc6"]), - ("IceGrid/allocation", ["service", "novc6"]), - ("IceGrid/distribution", ["service", "novc6"]), - ("IceGrid/admin", ["service", "novc6"]), - ("Glacier2/router", ["service", "novc6"]), - ("Glacier2/attack", ["service", "novc6"]), - ("Glacier2/override", ["service", "novc6"]), - ("Glacier2/sessionControl", ["service", "novc6"]), - ("Glacier2/ssl", ["service", "novalgrind", "novc6"]), # valgrind doesn't work well with openssl - ("Glacier2/dynamicFiltering", ["service", "novc6"]), - ("Glacier2/staticFiltering", ["service", "noipv6", "novc6"]), - ("Glacier2/sessionHelper", ["service", "novc6"]), + ("IceBox/configuration", ["core", "noipv6", "novc6", "nomingw"]), + ("Freeze/dbmap", ["once", "novc6", "nomingw"]), + ("Freeze/complex", ["once", "novc6", "nomingw"]), + ("Freeze/evictor", ["core", "novc6", "nomingw"]), + ("Freeze/fileLock", ["core", "novc6", "nomingw"]), + ("IceStorm/single", ["service", "novc6", "noappverifier", "nomingw"]), # This test doensn't work with appverifier is sensitive to timeouts. + ("IceStorm/federation", ["service", "novc6", "nomingw"]), + ("IceStorm/federation2", ["service", "novc6", "nomingw"]), + ("IceStorm/stress", ["service", "stress", "novc6", "noappverifier", "nomingw"]), # This test is very slow with appverifier. + ("IceStorm/rep1", ["service", "novc6", "nomingw"]), + ("IceStorm/repgrid", ["service", "novc6", "nomingw"]), + ("IceStorm/repstress", ["service", "noipv6", "stress", "novc6", "nomingw"]), + ("FreezeScript/dbmap", ["once", "novc6", "nomingw"]), + ("FreezeScript/evictor", ["once", "novc6", "nomingw"]), + ("IceGrid/simple", ["service", "novc6", "nomingw"]), + ("IceGrid/fileLock", ["service", "novc6", "nomingw"]), + ("IceGrid/deployer", ["service", "novc6", "nomingw"]), + ("IceGrid/session", ["service", "novc6", "nomingw"]), + ("IceGrid/update", ["service", "novc6", "nomingw"]), + ("IceGrid/activation", ["service", "novc6", "nomingw"]), + ("IceGrid/replicaGroup", ["service", "novc6", "nomingw"]), + ("IceGrid/replication", ["service", "novc6", "nomingw"]), + ("IceGrid/allocation", ["service", "novc6", "nomingw"]), + ("IceGrid/distribution", ["service", "novc6", "nomingw"]), + ("IceGrid/admin", ["service", "novc6", "nomingw"]), + ("Glacier2/router", ["service", "novc6", "nomingw"]), + ("Glacier2/attack", ["service", "novc6", "nomingw"]), + ("Glacier2/override", ["service", "novc6", "nomingw"]), + ("Glacier2/sessionControl", ["service", "novc6", "nomingw"]), + ("Glacier2/ssl", ["service", "novalgrind", "novc6", "nomingw"]), # valgrind doesn't work well with openssl + ("Glacier2/dynamicFiltering", ["service", "novc6", "nomingw"]), + ("Glacier2/staticFiltering", ["service", "noipv6", "novc6", "nomingw"]), + ("Glacier2/sessionHelper", ["service", "novc6", "nomingw"]), ] # diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index 9fbff56550c..e159318b676 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -130,6 +130,13 @@ USE_READLINE ?= no #GENPIC ?= yes # +# If building with MinGW and Ice third party packages is not installed +# in the default location set THIRDPARTY_HOME to the Ice third party +# installation directory. +# +#THIRDPARTY_HOME ?= C:\Program Files\ZeroC\Ice-$(VERSION)-ThirdParty + +# # Default Mutex protocol: one of PrioNone or PrioInherit. # #DEFAULT_MUTEX_PROTOCOL ?= PrioNone @@ -138,12 +145,22 @@ USE_READLINE ?= no # Don't change anything below this line! # ---------------------------------------------------------------------- +ifeq ($(shell test -f $(top_srcdir)/config/Make.rules.common && echo 0),0) + include $(top_srcdir)/config/Make.rules.common +else + include $(top_srcdir)/../cpp/config/Make.rules.common +endif + # # Common definitions # ice_language = cpp ifneq ($(shell test "$(USE_BIN_DIST)" != "yes" -a -d $(top_srcdir)/../$(ice_language) && echo 0),0) - slice_translator = slice2cpp + ifeq ($(MinGW), yes) + slice_translator = slice2cpp.exe + else + slice_translator = slice2cpp + endif ice_require_cpp = 1 endif @@ -170,7 +187,11 @@ endif # # Platform specific definitions # -include $(top_srcdir)/config/Make.rules.$(UNAME) +ifeq ($(MinGW), yes) + include $(top_srcdir)/config/Make.rules.MinGW +else + include $(top_srcdir)/config/Make.rules.$(UNAME) +endif install_includedir := $(prefix)/include install_docdir := $(prefix)/doc @@ -188,58 +209,71 @@ ifeq ($(DEFAULT_MUTEX_PROTOCOL), PrioInherit) ICEUTIL_FLAGS = -DICE_PRIO_INHERIT endif -OPENSSL_FLAGS = $(if $(OPENSSL_HOME),-I$(OPENSSL_HOME)/include) -OPENSSL_LIBS = $(if $(OPENSSL_HOME),-L$(OPENSSL_HOME)/$(libsubdir)) -lssl -lcrypto -OPENSSL_RPATH_LINK = $(if $(OPENSSL_HOME),$(call rpathlink,$(OPENSSL_HOME)/$(libsubdir))) - -BZIP2_FLAGS = $(if $(BZIP2_HOME),-I$(BZIP2_HOME)/include) -BZIP2_LIBS = $(if $(BZIP2_HOME),-L$(BZIP2_HOME)/$(libsubdir)) -lbz2 -BZIP2_RPATH_LINK = $(if $(BZIP2_HOME),$(call rpathlink,$(BZIP2_HOME)/$(libsubdir))) - -ICONV_LIBS = $(if $(ICONV_HOME),-L$(ICONV_HOME)/$(libsubdir)) $(ICONV_LIB) - -ifneq ($(DB_HOME),) - DB_FLAGS = -I$(DB_HOME)/include - DB_LIBS = -L$(DB_HOME)/$(libsubdir) -ldb_cxx - DB_RPATH_LINK = $(call rpathlink,$(DB_HOME)/$(libsubdir)) +ifeq ($(MinGW), yes) + OPENSSL_LIBS = -leay32_mingw -lssleay32_mingw + BZIP2_LIBS = -lbzip2_mingw + MCPP_LIBS = -lmcpp + slicedir_win = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(slicedir)) + ICECPPFLAGS = -I"$(slicedir_win)" else - ifeq ($(shell if [ -d /usr/include/db48 -a -d /usr/$(libsubdir)/db48 ] ; then echo yes; fi), yes) - DB_FLAGS = -I/usr/include/db48 - DB_LIBS = -L/usr/$(libsubdir)/db48 -ldb_cxx - else - DB_LIBS = -ldb_cxx - endif + OPENSSL_FLAGS = $(if $(OPENSSL_HOME),-I$(OPENSSL_HOME)/include) + OPENSSL_LIBS = $(if $(OPENSSL_HOME),-L$(OPENSSL_HOME)/$(libsubdir)) -lssl -lcrypto + OPENSSL_RPATH_LINK = $(if $(OPENSSL_HOME),$(call rpathlink,$(OPENSSL_HOME)/$(libsubdir))) + BZIP2_FLAGS = $(if $(BZIP2_HOME),-I$(BZIP2_HOME)/include) + BZIP2_LIBS = $(if $(BZIP2_HOME),-L$(BZIP2_HOME)/$(libsubdir)) -lbz2 + BZIP2_RPATH_LINK = $(if $(BZIP2_HOME),$(call rpathlink,$(BZIP2_HOME)/$(libsubdir))) + ICONV_LIBS = $(if $(ICONV_HOME),-L$(ICONV_HOME)/$(libsubdir)) $(ICONV_LIB) + + ifneq ($(DB_HOME),) + DB_FLAGS = -I$(DB_HOME)/include + DB_LIBS = -L$(DB_HOME)/$(libsubdir) -ldb_cxx + DB_RPATH_LINK = $(call rpathlink,$(DB_HOME)/$(libsubdir)) + else + ifeq ($(shell if [ -d /usr/include/db48 -a -d /usr/$(libsubdir)/db48 ] ; then echo yes; fi), yes) + DB_FLAGS = -I/usr/include/db48 + DB_LIBS = -L/usr/$(libsubdir)/db48 -ldb_cxx + else + DB_LIBS = -ldb_cxx + endif + endif + EXPAT_FLAGS = $(if $(EXPAT_HOME),-I$(EXPAT_HOME)/include) + EXPAT_LIBS = $(if $(EXPAT_HOME),-L$(EXPAT_HOME)/$(libsubdir)) -lexpat + EXPAT_RPATH_LINK = $(if $(EXPAT_HOME),$(call rpathlink,$(EXPAT_HOME)/$(libsubdir))) + MCPP_LIBS = $(if $(MCPP_HOME),-L$(MCPP_HOME)/$(libsubdir)) -lmcpp + MCPP_RPATH_LINK = $(if $(MCPP_HOME),$(call rpathlink,$(MCPP_HOME)/$(libsubdir))) + + ifeq ($(PLATFORM_HAS_READLINE),yes) + ifeq ($(USE_READLINE),yes) + READLINE_FLAGS = -DHAVE_READLINE $(if $(READLINE_HOME),-I$(READLINE_HOME)/include) + READLINE_LIBS = $(if $(READLINE_HOME),-L$(READLINE_HOME)/$(libsubdir)) -lreadline -lncurses + endif + endif + ICECPPFLAGS = -I$(slicedir) endif -EXPAT_FLAGS = $(if $(EXPAT_HOME),-I$(EXPAT_HOME)/include) -EXPAT_LIBS = $(if $(EXPAT_HOME),-L$(EXPAT_HOME)/$(libsubdir)) -lexpat -EXPAT_RPATH_LINK = $(if $(EXPAT_HOME),$(call rpathlink,$(EXPAT_HOME)/$(libsubdir))) -MCPP_LIBS = $(if $(MCPP_HOME),-L$(MCPP_HOME)/$(libsubdir)) -lmcpp -MCPP_RPATH_LINK = $(if $(MCPP_HOME),$(call rpathlink,$(MCPP_HOME)/$(libsubdir))) - -ifeq ($(PLATFORM_HAS_READLINE),yes) - ifeq ($(USE_READLINE),yes) - READLINE_FLAGS = -DHAVE_READLINE $(if $(READLINE_HOME),-I$(READLINE_HOME)/include) - READLINE_LIBS = $(if $(READLINE_HOME),-L$(READLINE_HOME)/$(libsubdir)) -lreadline -lncurses - endif -endif - -ifneq ($(DB_HOME),) -endif - -ICECPPFLAGS = -I$(slicedir) SLICE2CPPFLAGS = $(ICECPPFLAGS) ifeq ($(ice_dir), /usr) CPPFLAGS = LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) else - CPPFLAGS = -I$(includedir) - ifdef ice_src_dist - LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir) + ifeq ($(MinGW), yes) + includedir_win = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(includedir)) + CPPFLAGS = -I"$(includedir_win)" + ice_dir_win = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(ice_dir)) + ifdef ice_src_dist + LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir) + else + LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L"$(ice_dir_win)\$(binsubdir)" + endif else - LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(ice_dir)/$(libsubdir) + CPPFLAGS = -I$(includedir) + ifdef ice_src_dist + LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir) + else + LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(ice_dir)/$(libsubdir) + endif endif endif @@ -255,18 +289,35 @@ else BISONFLAGS := -dvt endif +ifneq ($(MinGW), yes) ifeq ($(mkshlib),) $(error You need to define mkshlib in Make.rules.$(UNAME)) endif +endif ifdef ice_src_dist - SLICEPARSERLIB = $(libdir)/$(call mklibfilename,Slice,$(VERSION)) - SLICE2CPP = $(bindir)/slice2cpp - SLICE2FREEZE = $(bindir)/slice2freeze + ifeq ($(MinGW), yes) + SLICEPARSERLIB = $(bindir)/$(SLICE_LIBNAME).dll + SLICE2CPP = $(bindir)/slice2cpp.exe + else + SLICEPARSERLIB = $(libdir)/$(call mklibfilename,Slice,$(VERSION)) + SLICE2CPP = $(bindir)/slice2cpp + SLICE2FREEZE = $(bindir)/slice2freeze + endif else - SLICEPARSERLIB = $(ice_dir)/$(libsubdir)/$(call mklibfilename,Slice,$(VERSION)) - SLICE2CPP = $(ice_dir)/$(binsubdir)/slice2cpp - SLICE2FREEZE = $(ice_dir)/$(binsubdir)/slice2freeze + ifeq ($(MinGW), yes) + SLICEPARSERLIB = $(ice_dir)/$(binsubdir)/$(SLICE_LIBNAME).dll + SLICE2CPP = $(ice_dir)/$(binsubdir)/slice2cpp.exe + else + SLICEPARSERLIB = $(ice_dir)/$(libsubdir)/$(call mklibfilename,Slice,$(VERSION)) + SLICE2CPP = $(ice_dir)/$(binsubdir)/slice2cpp + SLICE2FREEZE = $(ice_dir)/$(binsubdir)/slice2freeze + endif +endif + +ifeq ($(MinGW), yes) + CPPFLAGS := $(CPPFLAGS) -I"$(THIRDPARTY_HOME_WIN)\include" + LDFLAGS := $(LDFLAGS) -L"$(THIRDPARTY_HOME_WIN)\lib\mingw" -L"$(THIRDPARTY_HOME_WIN)\bin" -L$(libdir) -L$(bindir) endif EVERYTHING = all depend clean install @@ -280,7 +331,6 @@ EVERYTHING = all depend clean install .c.o: $(CC) -c $(CPPFLAGS) $(CFLAGS) $< - $(HDIR)/%F.h: $(SDIR)/%F.ice $(SLICE2CPP) $(SLICEPARSERLIB) rm -f $(HDIR)/$(*F)F.h $(*F)F.cpp $(SLICE2CPP) $(SLICE2CPPFLAGS) $< diff --git a/cpp/config/Make.rules.MINGW b/cpp/config/Make.rules.MINGW new file mode 100644 index 00000000000..2342da1e3c7 --- /dev/null +++ b/cpp/config/Make.rules.MINGW @@ -0,0 +1,56 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# +# This file is included by Make.rules when building with MinGW. +# + +# +# build with CygWin MinGW? +# +#ifeq ($(CygWin), yes) +# CXX = i686-pc-mingw32-c++ +#endif + +# +# Default compiler is c++ (aka g++). +# +ifeq ($(CXX),) + CXX = c++ +endif + +CXXFLAGS = $(CXXARCHFLAGS) -fexceptions -mthreads -Wall -DWIN32_LEAN_AND_MEAN +LDFLAGS = -Wl,-no-undefined + +ifeq ($(CXX), i686-pc-mingw32-c++) + LDPLATFORMFLAGS := $(LDFLAGS) -static-libstdc++ -static-libgcc +endif + +ifeq ($(OPTIMIZE),yes) + CXXFLAGS += -O2 -DNDEBUG +else + CXXFLAGS += -g -D_DEBUG + LIBSUFFIX = d +endif + +COMPSUFFIX = mingw_ + +# +# MinGW lib names +# +ICEUTIL_LIBNAME = iceutil$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) +SLICE_LIBNAME = slice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) +ICE_LIBNAME = ice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) +ICESSL_LIBNAME = icessl$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) + +BASELIBS = -l$(ICEUTIL_LIBNAME) +LIBS = -l$(ICE_LIBNAME) $(BASELIBS) +ICEUTIL_OS_LIBS = -lrpcrt4 -ladvapi32 +ICE_OS_LIBS = $(ICEUTIL_OS_LIBS) -lIphlpapi -lws2_32 + diff --git a/cpp/config/Make.rules.common b/cpp/config/Make.rules.common new file mode 100644 index 00000000000..5a5ded6a947 --- /dev/null +++ b/cpp/config/Make.rules.common @@ -0,0 +1,33 @@ +UNAME = $(shell uname) + +# +# CygWin on Windows XP x86 +# +ifeq ($(UNAME), CYGWIN_NT-5.1) + CygWin = yes + MinGW = yes +endif + +# +# CygWin on Windows XP x64 +# +ifeq ($(UNAME), CYGWIN_NT-5.1-WOW64) + CygWin = yes + MinGW = yes +endif + +# +# CygWin on Windows 7 x64 +# +ifeq ($(UNAME), CYGWIN_NT-6.1) + CygWin = yes + MinGW = yes +endif + +# +# CygWin on Windows 7 x64 +# +ifeq ($(UNAME), CYGWIN_NT-6.1-WOW64) + CygWin = yes + MinGW = yes +endif diff --git a/cpp/config/cygpath-unix.sh b/cpp/config/cygpath-unix.sh new file mode 100755 index 00000000000..9f0bd94c704 --- /dev/null +++ b/cpp/config/cygpath-unix.sh @@ -0,0 +1,4 @@ +# +# Convert Windows path to Unix path, also escape whitespace. +# +v=`cygpath -u "$1"`; v=${v//[[:blank:]]/\\ }; v=${v/(/\\(}; echo ${v/)/\\)} diff --git a/cpp/config/cygpath-win.sh b/cpp/config/cygpath-win.sh new file mode 100755 index 00000000000..dd3e36e25fb --- /dev/null +++ b/cpp/config/cygpath-win.sh @@ -0,0 +1,4 @@ +#
+# Convert Unix path to Windows path.
+#
+echo `cygpath -w $1`
diff --git a/cpp/include/Ice/DynamicLibrary.h b/cpp/include/Ice/DynamicLibrary.h index 3e4d6e1c257..dd1aa9f9526 100644 --- a/cpp/include/Ice/DynamicLibrary.h +++ b/cpp/include/Ice/DynamicLibrary.h @@ -86,7 +86,6 @@ private: #else void* _hnd; #endif - std::string _err; const Ice::StringConverterPtr _stringConverter; }; diff --git a/cpp/include/IceUtil/FileUtil.h b/cpp/include/IceUtil/FileUtil.h index 666ea5ec6a7..054a8c9fef0 100644 --- a/cpp/include/IceUtil/FileUtil.h +++ b/cpp/include/IceUtil/FileUtil.h @@ -38,7 +38,7 @@ ICE_UTIL_API bool directoryExists(const std::string&); #ifdef _WIN32 -#if (defined(_MSC_VER) && (_MSC_VER < 1300)) +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) typedef struct _stat structstat; #else typedef struct _stat64i32 structstat; diff --git a/cpp/include/Makefile b/cpp/include/Makefile index e0cc01b3c42..5de48e060d4 100644 --- a/cpp/include/Makefile +++ b/cpp/include/Makefile @@ -11,17 +11,22 @@ top_srcdir = .. include $(top_srcdir)/config/Make.rules -SUBDIRS = Freeze \ - Glacier2 \ - Ice \ - IceBox \ - IceGrid \ - IcePatch2 \ +SUBDIRS = Ice \ IceSSL \ - IceStorm \ IceUtil \ - IceXML \ Slice + +ifneq ($(MinGW), yes) +SUBDIRS := $(SUBDIRS) \ + Freeze \ + Glacier2 \ + IceBox \ + IceGrid \ + IcePatch2 \ + IceStorm \ + IceXML +endif + $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 1075caa7e1a..6c5a4f5d75b 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -30,7 +30,7 @@ namespace Slice { -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__MINGW32__) const IceUtil::Int64 Int32Max = 0x7fffffffi64; const IceUtil::Int64 Int32Min = -Int32Max - 1i64; diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp index c7abb540a69..2a879eeaaee 100644 --- a/cpp/src/Ice/Application.cpp +++ b/cpp/src/Ice/Application.cpp @@ -141,7 +141,7 @@ destroyOnInterruptCallback(int signal) // return; } - if(_nohup && signal == SIGHUP) + if(_nohup && signal == static_cast<int>(SIGHUP)) { return; } @@ -197,7 +197,7 @@ shutdownOnInterruptCallback(int signal) // return; } - if(_nohup && signal == SIGHUP) + if(_nohup && signal == static_cast<int>(SIGHUP)) { return; } diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index 150f27d89e6..e95f66163da 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -9,11 +9,17 @@ top_srcdir = ../.. -LIBFILENAME = $(call mklibfilename,Ice,$(VERSION)) -SONAME = $(call mksoname,Ice,$(SOVERSION)) -LIBNAME = $(call mklibname,Ice) - -TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +include $(top_srcdir)/config/Make.rules.common + +ifeq ($(MinGW), yes) + DLLNAME = $(top_srcdir)/bin/ice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX).dll + TARGETS = $(DLLNAME) $(LIBNAME) +else + LIBFILENAME = $(call mklibfilename,Ice,$(VERSION)) + SONAME = $(call mksoname,Ice,$(SOVERSION)) + LIBNAME = $(call mklibname,Ice) + TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +endif OBJS = Acceptor.o \ Application.o \ @@ -95,8 +101,7 @@ OBJS = Acceptor.o \ Stats.o \ StreamI.o \ Stream.o \ - StringConverter.o \ - SysLoggerI.o \ + StringConverter.o \ TcpAcceptor.o \ TcpConnector.o \ TcpEndpointI.o \ @@ -109,6 +114,12 @@ OBJS = Acceptor.o \ UdpEndpointI.o \ UdpTransceiver.o +ifneq ($(MinGW), yes) +OBJS := $(OBJS) \ + SysLoggerI.o +endif + + SRCS = $(OBJS:.o=.cpp) \ DLLMain.cpp @@ -156,8 +167,16 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_API_EXPORTS $(BZIP2_FLAGS) SLICE2CPPFLAGS := --ice --include-dir Ice --dll-export ICE_API $(SLICE2CPPFLAGS) +ifeq ($(MinGW), yes) +CPPFLAGS := $(CPPFLAGS) -DCOMPSUFFIX=\"$(COMPSUFFIX)\" +LINKWITH := $(ICE_OS_LIBS) -l$(ICEUTIL_LIBNAME) $(BZIP2_LIBS) +$(DLLNAME): $(OBJS) + $(CXX) -shared $(LDFLAGS) -o $(DLLNAME) $(OBJS) $(LINKWITH) + +install:: all + $(call installprogram,$(DLLNAME),$(install_bindir)) +else LINKWITH := -lIceUtil $(BZIP2_LIBS) $(ICONV_LIBS) $(ICE_OS_LIBS) - $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ $(call mkshlib,$@,$(SONAME),$(OBJS),$(LINKWITH)) @@ -172,6 +191,7 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) +endif $(HDIR)/BuiltinSequences.h BuiltinSequences.cpp: $(SDIR)/BuiltinSequences.ice $(SLICE2CPP) $(SLICEPARSERLIB) rm -f $(HDIR)/BuiltinSequences.h BuiltinSequences.cpp diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index ed730a8bb88..c29cd00a78b 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -2277,7 +2277,7 @@ IceInternal::doFinishConnectAsync(SOCKET fd, AsyncInfo& info) // failure to connect. The socket isn't closed by this method. // - if(info.count == SOCKET_ERROR) + if(static_cast<int>(info.count) == SOCKET_ERROR) { WSASetLastError(info.error); if(connectionRefused()) diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index b8e30a34876..1643c5eae8f 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -24,7 +24,9 @@ #elif defined(_WIN32) # include <winsock2.h> # include <ws2tcpip.h> +# if !defined(__MINGW32__) typedef int ssize_t; +# endif #else # include <unistd.h> # include <fcntl.h> @@ -85,6 +87,21 @@ typedef int socklen_t; # define NETDB_SUCCESS 0 #endif +#if defined(__MINGW32__) && !defined WSAID_CONNECTEX +# define WSAID_CONNECTEX {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}} +# define WSAID_ACCEPTEX {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} +# define SO_UPDATE_ACCEPT_CONTEXT 0x700B +# define SO_UPDATE_CONNECT_CONTEXT 0x7010 + typedef BOOL (PASCAL FAR * LPFN_CONNECTEX) (IN SOCKET s, IN const struct sockaddr FAR *name, IN int namelen, + IN PVOID lpSendBuffer OPTIONAL, IN DWORD dwSendDataLength, + OUT LPDWORD lpdwBytesSent, IN LPOVERLAPPED lpOverlapped); + + typedef BOOL (PASCAL FAR * LPFN_ACCEPTEX)(IN SOCKET sListenSocket, IN SOCKET sAcceptSocket, + IN PVOID lpOutputBuffer, IN DWORD dwReceiveDataLength, + IN DWORD dwLocalAddressLength, IN DWORD dwRemoteAddressLength, + OUT LPDWORD lpdwBytesReceived, IN LPOVERLAPPED lpOverlapped); +#endif + namespace IceInternal { diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 3c5c8df8f85..196e31ae6b7 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -852,7 +852,16 @@ Ice::Service::main(int argc, char* const argv[], const InitializationData& initi int Ice::Service::main(int& argc, wchar_t* argv[], const InitializationData& initializationData) { + +# ifdef __MINGW32__ // COMPILER FIX + // + // MinGW doesn't see the main overload if we don't create the temp args object here. + // + Ice::StringSeq args = Ice::argsToStringSeq(argc, argv, initializationData.stringConverter); + return main(args, initializationData); +# else return main(Ice::argsToStringSeq(argc, argv, initializationData.stringConverter), initializationData); +# endif } #endif diff --git a/cpp/src/Ice/StringConverter.cpp b/cpp/src/Ice/StringConverter.cpp index f8e385e7a23..35269b6cf23 100644 --- a/cpp/src/Ice/StringConverter.cpp +++ b/cpp/src/Ice/StringConverter.cpp @@ -16,10 +16,15 @@ #include <Ice/LocalException.h> #include <Ice/LoggerUtil.h> #include <Ice/Communicator.h> + #ifndef _WIN32 #include <Ice/IconvStringConverter.h> #endif +#ifdef __MINGW32__ +# include <limits.h> +#endif + using namespace IceUtil; using namespace IceUtilInternal; using namespace std; diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp index 0fc4fbc710c..8453863a25b 100644 --- a/cpp/src/Ice/TcpAcceptor.cpp +++ b/cpp/src/Ice/TcpAcceptor.cpp @@ -126,7 +126,7 @@ IceInternal::TcpAcceptor::startAccept() void IceInternal::TcpAcceptor::finishAccept() { - if(_info.count == SOCKET_ERROR || _fd == INVALID_SOCKET) + if(static_cast<int>(_info.count) == SOCKET_ERROR || _fd == INVALID_SOCKET) { closeSocketNoThrow(_acceptFd); _acceptFd = INVALID_SOCKET; diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index 3d59ae68bf1..61fda069922 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -313,7 +313,7 @@ IceInternal::TcpTransceiver::finishWrite(Buffer& buf) return; } - if(_write.count == SOCKET_ERROR) + if(static_cast<int>(_write.count) == SOCKET_ERROR) { WSASetLastError(_write.error); if(connectionLost()) @@ -385,7 +385,7 @@ IceInternal::TcpTransceiver::startRead(Buffer& buf) void IceInternal::TcpTransceiver::finishRead(Buffer& buf) { - if(_read.count == SOCKET_ERROR) + if(static_cast<int>(_read.count) == SOCKET_ERROR) { WSASetLastError(_read.error); if(connectionLost()) diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 5d45363a494..e46f244dce1 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -337,7 +337,7 @@ public: // of the event handler. We need to lock the event handler here to call // finishMessage. // -#if (defined(_MSC_VER) && (_MSC_VER < 1300)) +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) IceUtil::LockT<T> sync(_mutex); #else IceUtil::LockT<typename T> sync(_mutex); diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 855527b144d..b1aa39ddd96 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -545,7 +545,7 @@ IceInternal::UdpTransceiver::finishWrite(Buffer& buf) return; } - if(_write.count == SOCKET_ERROR) + if(static_cast<int>(_write.count) == SOCKET_ERROR) { #ifndef ICE_OS_WINRT WSASetLastError(_write.error); @@ -675,7 +675,7 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf) checkErrorCode(__FILE__, __LINE__, ex->HResult); } #else - if(_read.count == SOCKET_ERROR) + if(static_cast<int>(_read.count) == SOCKET_ERROR) { WSASetLastError(_read.error); diff --git a/cpp/src/IceSSL/AcceptorI.cpp b/cpp/src/IceSSL/AcceptorI.cpp index 96fc56f2d19..f1b45d6afc7 100644 --- a/cpp/src/IceSSL/AcceptorI.cpp +++ b/cpp/src/IceSSL/AcceptorI.cpp @@ -132,7 +132,7 @@ IceSSL::AcceptorI::startAccept() void IceSSL::AcceptorI::finishAccept() { - if(_info.count == SOCKET_ERROR || _fd == INVALID_SOCKET) + if(static_cast<int>(_info.count) == SOCKET_ERROR || _fd == INVALID_SOCKET) { IceInternal::closeSocketNoThrow(_acceptFd); _acceptFd = INVALID_SOCKET; diff --git a/cpp/src/IceSSL/Makefile b/cpp/src/IceSSL/Makefile index 868cdb0acaa..ab2d6ca690b 100644 --- a/cpp/src/IceSSL/Makefile +++ b/cpp/src/IceSSL/Makefile @@ -10,11 +10,17 @@ top_srcdir = ../.. -LIBFILENAME = $(call mklibfilename,IceSSL,$(VERSION)) -SONAME = $(call mksoname,IceSSL,$(SOVERSION)) -LIBNAME = $(call mklibname,IceSSL) - -TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +include $(top_srcdir)/config/Make.rules.common + +ifeq ($(MinGW), yes) + DLLNAME = $(top_srcdir)/bin/icessl$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX).dll + TARGETS = $(DLLNAME) $(LIBNAME) +else + LIBFILENAME = $(call mklibfilename,IceSSL,$(VERSION)) + SONAME = $(call mksoname,IceSSL,$(SOVERSION)) + LIBNAME = $(call mklibname,IceSSL) + TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +endif OBJS = AcceptorI.o \ Certificate.o \ @@ -42,6 +48,17 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_SSL_API_EXPORTS $(OPENSSL_FLAGS) SLICE2CPPFLAGS := --ice --include-dir IceSSL --dll-export ICE_SSL_API $(SLICE2CPPFLAGS) +ifeq ($(MinGW), yes) + +LINKWITH := -lice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) -liceutil$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) $(ICE_OS_LIBS) $(OPENSSL_LIBS) + +$(DLLNAME): $(OBJS) + $(CXX) -shared $(LDFLAGS) -o $(DLLNAME) $(OBJS) $(LINKWITH) + +install:: all + $(call installprogram,$(DLLNAME),$(install_bindir)) + +else LINKWITH := $(BZIP2_RPATH_LINK) -lIce -lIceUtil $(OPENSSL_LIBS) $(CXXLIBS) $(libdir)/$(LIBFILENAME): $(OBJS) @@ -58,5 +75,6 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) +endif include .depend diff --git a/cpp/src/IceSSL/TransceiverI.cpp b/cpp/src/IceSSL/TransceiverI.cpp index 3c75c6331bc..a052fbd8f00 100644 --- a/cpp/src/IceSSL/TransceiverI.cpp +++ b/cpp/src/IceSSL/TransceiverI.cpp @@ -692,7 +692,7 @@ IceSSL::TransceiverI::finishWrite(IceInternal::Buffer& buf) return; } - if(_write.count == SOCKET_ERROR) + if(static_cast<int>(_write.count) == SOCKET_ERROR) { WSASetLastError(_write.error); if(IceInternal::connectionLost()) @@ -763,7 +763,7 @@ IceSSL::TransceiverI::startRead(IceInternal::Buffer& buf) void IceSSL::TransceiverI::finishRead(IceInternal::Buffer& buf) { - if(_read.count == SOCKET_ERROR) + if(static_cast<int>(_read.count) == SOCKET_ERROR) { WSASetLastError(_read.error); if(IceInternal::connectionLost()) diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 350df152b29..fac85e5e01e 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -14,7 +14,7 @@ #include <ostream> #include <cstdlib> -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) # include <execinfo.h> # include <cxxabi.h> #endif @@ -52,7 +52,7 @@ public: Init init; -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) string getStackTrace() { @@ -183,7 +183,7 @@ getStackTrace() IceUtil::Exception::Exception() : _file(0), _line(0) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) , _stackTrace(getStackTrace()) #endif { @@ -192,7 +192,7 @@ IceUtil::Exception::Exception() : IceUtil::Exception::Exception(const char* file, int line) : _file(file), _line(line) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) , _stackTrace(getStackTrace()) #endif { diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index 0888ff8281c..b69e8d6b20a 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -170,7 +170,7 @@ IceUtilInternal::unlink(const string& path) int IceUtilInternal::close(int fd) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) || defined(__MINGW32__) return _close(fd); #else return ::close(fd); @@ -197,6 +197,12 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); } +#ifdef __MINGW32__ + if(::LockFile(_fd, 0, 0, 0, 0) == 0) + { + throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); + } +#else OVERLAPPED overlaped; overlaped.Internal = 0; overlaped.InternalHigh = 0; @@ -208,6 +214,7 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : ::CloseHandle(_fd); throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); } +#endif // // In Windows implementation we don't write the process pid to the file, as is // not posible to read the file from other process while it is locked here. @@ -310,14 +317,23 @@ IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) #else -IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : std::ifstream(IceUtil::stringToWstring(path).c_str(), mode) +IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : +#ifdef __MINGW32__ + std::ifstream(path.c_str(), mode) +#else + std::ifstream(IceUtil::stringToWstring(path).c_str(), mode) +#endif { } void IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) { +#ifdef __MINGW32__ + std::ifstream::open(path.c_str(), mode); +#else std::ifstream::open(IceUtil::stringToWstring(path).c_str(), mode); +#endif } #endif @@ -371,14 +387,23 @@ IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) #else -IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : std::ofstream(IceUtil::stringToWstring(path).c_str(), mode) +IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : +#ifdef __MINGW32__ + std::ofstream(path.c_str(), mode) +#else + std::ofstream(IceUtil::stringToWstring(path).c_str(), mode) +#endif { } void IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) { +#ifdef __MINGW32__ + std::ofstream::open(path.c_str(), mode); +#else std::ofstream::open(IceUtil::stringToWstring(path).c_str(), mode); +#endif } #endif diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp index 1b29658afbe..8f5edab81f9 100644 --- a/cpp/src/IceUtil/InputUtil.cpp +++ b/cpp/src/IceUtil/InputUtil.cpp @@ -11,7 +11,7 @@ #include <stdlib.h> #include <errno.h> -#if defined(_MSC_VER) && (_MSC_VER < 1300) +#if (defined(_MSC_VER) && (_MSC_VER < 1300) ) || (__MINGW32__) #include <limits.h> #endif @@ -25,7 +25,9 @@ using namespace IceUtil; namespace IceUtilInternal { -#if (defined(_MSC_VER) && (_MSC_VER < 1300)) + +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) + // // The VC60 runtime does not include _strtoi64, so we provide our own implementation // @@ -177,7 +179,7 @@ Int64 strToInt64(const char* s, char** endptr, int base) { #if defined(_WIN32) -# if (defined(_MSC_VER) && (_MSC_VER < 1300)) +# if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) return strToInt64Impl(s, endptr, base); # else return _strtoi64(s, endptr, base); diff --git a/cpp/src/IceUtil/Makefile b/cpp/src/IceUtil/Makefile index 4fb25718adf..a3e19c0914f 100644 --- a/cpp/src/IceUtil/Makefile +++ b/cpp/src/IceUtil/Makefile @@ -9,11 +9,17 @@ top_srcdir = ../.. -LIBFILENAME = $(call mklibfilename,IceUtil,$(VERSION)) -SONAME = $(call mksoname,IceUtil,$(SOVERSION)) -LIBNAME = $(call mklibname,IceUtil) +include $(top_srcdir)/config/Make.rules.common -TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +ifeq ($(MinGW), yes) + DLLNAME = $(top_srcdir)/bin/iceutil$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX).dll + TARGETS = $(DLLNAME) $(LIBNAME) +else + LIBFILENAME = $(call mklibfilename,IceUtil,$(VERSION)) + SONAME = $(call mksoname,IceUtil,$(SOVERSION)) + LIBNAME = $(call mklibname,IceUtil) + TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +endif OBJS = ArgVector.o \ Cond.o \ @@ -21,7 +27,6 @@ OBJS = ArgVector.o \ CountDownLatch.o \ CtrlCHandler.o \ Exception.o \ - FileUtil.o \ InputUtil.o \ Options.o \ OutputUtil.o \ @@ -35,7 +40,8 @@ OBJS = ArgVector.o \ Timer.o \ UUID.o \ Unicode.o \ - MutexProtocol.o + MutexProtocol.o \ + FileUtil.o SRCS = $(OBJS:.o=.cpp) @@ -43,8 +49,15 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := $(CPPFLAGS) $(ICEUTIL_FLAGS) -DICE_UTIL_API_EXPORTS -I.. -LINKWITH := $(STLPORT_LIBS) $(ICEUTIL_OS_LIBS) +LINKWITH := $(ICEUTIL_OS_LIBS) +ifeq ($(MinGW), yes) +$(DLLNAME): $(OBJS) + $(CXX) -shared $(LDFLAGS) -o $(DLLNAME) $(OBJS) $(LINKWITH) + +install:: all + $(call installprogram,$(DLLNAME),$(install_bindir)) +else ifeq ($(STATICLIBS),yes) $(libdir)/$(LIBNAME): $(OBJS) rm -f $@ @@ -62,9 +75,9 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) rm -f $@ ln -s $(SONAME) $@ endif - install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) +endif include .depend diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index e82a55d93ab..d47d424357f 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -44,7 +44,7 @@ namespace // Mutex* staticMutex = 0; #ifdef _WIN32 -HCRYPTPROV context = NULL; +HCRYPTPROV context = 0; #else int fd = -1; #endif @@ -61,10 +61,10 @@ public: ~Init() { #ifdef _WIN32 - if(context != NULL) + if(context != 0) { CryptReleaseContext(context, 0); - context = NULL; + context = 0; } #else if(fd != -1) @@ -102,7 +102,7 @@ IceUtilInternal::generateRandom(char* buffer, int size) // IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(staticMutex); - if(context == NULL) + if(context == 0) { if(!CryptAcquireContext(&context, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { diff --git a/cpp/src/IceUtil/RecMutex.cpp b/cpp/src/IceUtil/RecMutex.cpp index c632f4b7b63..9558a6fed2b 100644 --- a/cpp/src/IceUtil/RecMutex.cpp +++ b/cpp/src/IceUtil/RecMutex.cpp @@ -33,7 +33,11 @@ IceUtil::RecMutex::RecMutex(const IceUtil::MutexProtocol protocol) : void IceUtil::RecMutex::init(const MutexProtocol) { +# ifdef ICE_OS_WINRT InitializeCriticalSectionEx(&_mutex, 0, 0); +# else + InitializeCriticalSection(&_mutex); +# endif } IceUtil::RecMutex::~RecMutex() diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index a629586a43b..4c63bd7b0e2 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -251,7 +251,7 @@ IceUtil::Thread::start(size_t stackSize, int priority) { throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); } - if(ResumeThread(_handle) == -1) + if(static_cast<int>(ResumeThread(_handle)) == -1) { __decRef(); throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp index 585335191e8..bef48d9ab3d 100644 --- a/cpp/src/IceUtil/Time.cpp +++ b/cpp/src/IceUtil/Time.cpp @@ -95,8 +95,13 @@ IceUtil::Time::now(Clock clock) if(clock == Realtime) { #ifdef _WIN32 +# if defined(_MSC_VER) struct _timeb tb; _ftime(&tb); +# elif defined(__MINGW32__) + struct timeb tb; + ftime(&tb); +# endif return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) + tb.millitm * 1000); #else struct timeval tv; @@ -123,8 +128,13 @@ IceUtil::Time::now(Clock clock) } else { +# if defined(_MSC_VER) struct _timeb tb; _ftime(&tb); +# elif defined(__MINGW32__) + struct timeb tb; + ftime(&tb); +# endif return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) + tb.millitm * 1000); } #elif defined(__hpux) diff --git a/cpp/src/Makefile b/cpp/src/Makefile index a7930b2e6ec..4917e0a96ef 100644 --- a/cpp/src/Makefile +++ b/cpp/src/Makefile @@ -11,33 +11,42 @@ top_srcdir = .. include $(top_srcdir)/config/Make.rules -SUBDIRS = IceUtil \ - Slice \ - slice2cpp \ - slice2cs \ - slice2freeze \ - slice2freezej \ - slice2java \ - slice2php \ - slice2py \ - slice2rb \ - slice2html \ - Ice \ - IceXML \ - IceSSL \ - Freeze \ - FreezeScript \ - IceBox \ - Glacier2Lib \ - Glacier2 \ - IceDB \ - IcePatch2Lib \ - IcePatch2 \ - IceStormLib \ - IceGridLib \ - IceStorm \ - IceGrid \ - ca +ifeq ($(MinGW), yes) + SUBDIRS = IceUtil \ + Slice \ + slice2cpp \ + slice2rb \ + Ice \ + IceSSL +else + SUBDIRS = IceUtil \ + Slice \ + slice2cpp \ + slice2cs \ + slice2freeze \ + slice2freezej \ + slice2java \ + slice2php \ + slice2py \ + slice2rb \ + slice2html \ + Ice \ + IceXML \ + IceSSL \ + Freeze \ + FreezeScript \ + IceBox \ + Glacier2Lib \ + Glacier2 \ + IceDB \ + IcePatch2Lib \ + IcePatch2 \ + IceStormLib \ + IceGridLib \ + IceStorm \ + IceGrid \ + ca +endif $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index c6e5718f866..f07c97d1340 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -9,11 +9,17 @@ top_srcdir = ../.. -LIBFILENAME = $(call mklibfilename,Slice,$(VERSION)) -SONAME = $(call mksoname,Slice,$(SOVERSION)) -LIBNAME = $(call mklibname,Slice) +include $(top_srcdir)/config/Make.rules.common -TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +ifeq ($(MinGW), yes) + DLLNAME = $(top_srcdir)/bin/slice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX).dll + TARGETS = $(DLLNAME) $(LIBNAME) +else + LIBFILENAME = $(call mklibfilename,Slice,$(VERSION)) + SONAME = $(call mksoname,Slice,$(SOVERSION)) + LIBNAME = $(call mklibname,Slice) + TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +endif OBJS = Scanner.o \ ../Slice/Grammar.o \ @@ -36,10 +42,19 @@ SRCS = $(OBJS:.o=.cpp) include $(top_srcdir)/config/Make.rules + CPPFLAGS := -I.. $(CPPFLAGS) -DSLICE_API_EXPORTS -LINKWITH := -lIceUtil $(MCPP_LIBS) BISONFLAGS := --name-prefix "slice_" $(BISONFLAGS) +ifeq ($(MinGW), yes) +LINKWITH := -l$(ICEUTIL_LIBNAME) $(MCPP_LIBS) +$(DLLNAME): $(OBJS) + $(CXX) -shared $(LDFLAGS) -o $(DLLNAME) $(OBJS) $(LINKWITH) + +install:: all + $(call installprogram,$(DLLNAME),$(install_bindir)) +else +LINKWITH := -lIceUtil $(MCPP_LIBS) ifeq ($(STATICLIBS),yes) $(libdir)/$(LIBNAME): $(OBJS) rm -f $@ @@ -57,9 +72,8 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) rm -f $@ ln -s $(SONAME) $@ endif - install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) - +endif include .depend diff --git a/cpp/src/slice2cpp/Makefile b/cpp/src/slice2cpp/Makefile index dc15e514e7e..167f35e7dc8 100644 --- a/cpp/src/slice2cpp/Makefile +++ b/cpp/src/slice2cpp/Makefile @@ -9,7 +9,13 @@ top_srcdir = ../.. -NAME = $(top_srcdir)/bin/slice2cpp +include $(top_srcdir)/config/Make.rules.common + +ifeq ($(MinGW), yes) + NAME = $(top_srcdir)/bin/slice2cpp.exe +else + NAME = $(top_srcdir)/bin/slice2cpp +endif TARGETS = $(NAME) @@ -22,10 +28,15 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I. $(CPPFLAGS) +ifeq ($(MinGW), yes) +$(NAME): $(OBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) -lslice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) $(BASELIBS) $(MCPP_RPATH_LINK) +else $(NAME): $(OBJS) rm -f $@ $(CXX) $(LDFLAGS) -o $@ $(OBJS) -lSlice $(BASELIBS) $(MCPP_RPATH_LINK) - +endif install:: all $(call installprogram,$(NAME),$(install_bindir)) diff --git a/cpp/src/slice2rb/Makefile b/cpp/src/slice2rb/Makefile index 7e014004b32..1e4df68e074 100644 --- a/cpp/src/slice2rb/Makefile +++ b/cpp/src/slice2rb/Makefile @@ -9,7 +9,13 @@ top_srcdir = ../.. -NAME = $(top_srcdir)/bin/slice2rb +include $(top_srcdir)/config/Make.rules.common + +ifeq ($(MinGW), yes) + NAME = $(top_srcdir)/bin/slice2rb.exe +else + NAME = $(top_srcdir)/bin/slice2rb +endif TARGETS = $(NAME) @@ -21,9 +27,15 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I. $(CPPFLAGS) +ifeq ($(MinGW), yes) +$(NAME): $(OBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(OBJS) -lslice$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX) $(BASELIBS) $(MCPP_RPATH_LINK) +else $(NAME): $(OBJS) rm -f $@ $(CXX) $(LDFLAGS) -o $@ $(OBJS) -lSlice $(BASELIBS) $(MCPP_RPATH_LINK) +endif install:: all $(call installprogram,$(NAME),$(install_bindir)) diff --git a/cpp/test/Ice/info/Makefile b/cpp/test/Ice/info/Makefile index fabbe5521b0..5df66daac71 100644 --- a/cpp/test/Ice/info/Makefile +++ b/cpp/test/Ice/info/Makefile @@ -31,14 +31,18 @@ SLICE_SRCS = Test.ice include $(top_srcdir)/config/Make.rules +ifneq ($(MinGW), yes) + ICESSL_LIBNAME = IceSSL +endif + CPPFLAGS := -I. -I../../include $(CPPFLAGS) $(CLIENT): $(COBJS) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(OPENSSL_RPATH_LINK) -lIceSSL $(LIBS) + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(OPENSSL_RPATH_LINK) -l$(ICESSL_LIBNAME) $(LIBS) $(SERVER): $(SOBJS) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) -l$(ICESSL_LIBNAME) include .depend diff --git a/cpp/test/IceSSL/configuration/Makefile b/cpp/test/IceSSL/configuration/Makefile index e8b3203729c..776f8219eea 100644 --- a/cpp/test/IceSSL/configuration/Makefile +++ b/cpp/test/IceSSL/configuration/Makefile @@ -31,14 +31,18 @@ GENPIC = no include $(top_srcdir)/config/Make.rules +ifneq ($(MinGW), yes) +ICESSL_LIBNAME = IceSSL +endif + CPPFLAGS := -I. -I../../include $(CPPFLAGS) $(CLIENT): $(COBJS) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS) $(OPENSSL_RPATH_LINK) -lIceSSL + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS) $(OPENSSL_RPATH_LINK) -l$(ICESSL_LIBNAME) $(SERVER): $(SOBJS) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) $(OPENSSL_RPATH_LINK) -lIceSSL + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) $(LIBS) $(OPENSSL_RPATH_LINK) -l$(ICESSL_LIBNAME) include .depend diff --git a/cpp/test/IceUtil/unicode/Client.cpp b/cpp/test/IceUtil/unicode/Client.cpp index 3f703e0f7f2..f05cb7646b7 100644 --- a/cpp/test/IceUtil/unicode/Client.cpp +++ b/cpp/test/IceUtil/unicode/Client.cpp @@ -23,7 +23,8 @@ using namespace std; // converts these BOMs back and forth. // -#ifdef _WIN32 +//COMPILERFIX: MINGW doesn't support wmain for console applications. +#if defined(_WIN32) && !defined(__MINGW32__) int wmain(int argc, wchar_t* argv[]) @@ -40,7 +41,12 @@ main(int argc, char* argv[]) if(argc > 1) { #ifdef _WIN32 + +# ifdef __MINGW32__ + dir = argv[1]; +# else dir = IceUtil::wstringToString(argv[1]); +# endif dir += "\\"; #else dir = argv[1]; @@ -174,6 +180,7 @@ main(int argc, char* argv[]) cout << "ok" << endl; } +#ifndef __MINGW32__ { cout << "testing UTF-8 filename... "; IceUtilInternal::ifstream fn(dir + "filename.txt"); @@ -200,11 +207,11 @@ main(int argc, char* argv[]) int fd = IceUtilInternal::open(filepath, O_RDONLY); test(fd > 0); -#if defined(_MSC_VER) && (_MSC_VER >= 1400) +# if defined(_MSC_VER) && (_MSC_VER >= 1400) test(_close(fd) == 0); -#else +# else test(close(fd) == 0); -#endif +# endif FILE* f = IceUtilInternal::fopen(filepath, "r"); test(f != 0); @@ -245,5 +252,6 @@ main(int argc, char* argv[]) cout << "ok" << endl; } +#endif return EXIT_SUCCESS; } diff --git a/cpp/test/Makefile b/cpp/test/Makefile index 4dbb8f55c7e..a56cf17c9f0 100644 --- a/cpp/test/Makefile +++ b/cpp/test/Makefile @@ -14,13 +14,17 @@ include $(top_srcdir)/config/Make.rules SUBDIRS = IceUtil \ Slice \ Ice \ - IceSSL \ - IceBox \ - IceStorm \ - Freeze \ - FreezeScript \ - Glacier2 \ - IceGrid + IceSSL + +ifneq ($(MinGW), yes) +SUBDIRS := $(SUBDIRS) \ + IceBox \ + IceStorm \ + Freeze \ + FreezeScript \ + Glacier2 \ + IceGrid +endif $(EVERYTHING):: @for subdir in $(SUBDIRS); \ |