From 309c65796d772150c249659f79f6d84dd9985d30 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Mon, 24 Nov 2014 22:12:17 +0300
Subject: [PATCH] mingw-w64 have matherr routine

---
 src/extlib/ib_udf.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/extlib/ib_udf.cpp b/src/extlib/ib_udf.cpp
index fc6d69c..5a6f21b 100644
--- a/src/extlib/ib_udf.cpp
+++ b/src/extlib/ib_udf.cpp
@@ -50,10 +50,12 @@ extern "C"
 #else
 #define exception_type __exception
 #endif
+#ifndef matherr
 int MATHERR(struct exception_type*)
 {
 	return 1;
 }
+#endif
 #undef exception_type
 #endif // SOLARIS
 #endif //__ICC
-- 
2.2.0

From e705380c785638ef80fa737b8e7a4654c85986ab Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Fri, 28 Nov 2014 12:28:31 +0300
Subject: [PATCH] Fix linkng error for mingw.

---
 src/utilities/install/services.cpp |  2 ++
 1 files changed, 2 insertions(+)

diff --git a/src/utilities/install/services.cpp b/src/utilities/install/services.cpp
index 04abff3..f28e7fa 100644
--- a/src/utilities/install/services.cpp
+++ b/src/utilities/install/services.cpp
@@ -563,6 +563,7 @@ USHORT SERVICES_grant_access_rights(const char* service_name, const TEXT* accoun
 // Until the fb_assert could be converted to a function/object linked with each module
 // we need this ugly workaround.
 //
+#ifndef __MINGW32__
 extern "C" void API_ROUTINE gds__log(const TEXT* text, ...)
 {
 	va_list ptr;
@@ -572,6 +573,7 @@ extern "C" void API_ROUTINE gds__log(const TEXT* text, ...)
 	va_end(ptr);
 	printf("\n\n");
 }
+#endif
 
 //
 // EOF
-- 
2.2.0

From 24cb71b609b43165672c75278985388b033f1806 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Sun, 30 Nov 2014 15:26:04 +0300
Subject: [PATCH] DLL's are in BIN folder.

---
 builds/posix/make.defaults | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults
index 90724e6..bd6f8cb
--- a/builds/posix/make.defaults
+++ b/builds/posix/make.defaults
@@ -203,7 +203,7 @@ include $(ROOT)/gen/Make.Version
 
 vpath %.so $(LIB)
 vpath %.a $(LIB)
-vpath %.dll $(LIB)
+vpath %.dll $(BIN)
 
 #_____________________________________________________________________________
 
-- 
2.2.0

From a1b086945a7ed8952b3a4075d7badb18618dbdfb Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Sun, 30 Nov 2014 15:08:19 +0300
Subject: [PATCH] Auto detect WINDRES with autoconf.
Fix building .rc files.

---
 builds/posix/make.defaults |  4 +++-
 builds/posix/make.rules    |  4 ++--
 builds/posix/make.shared.targets | 14 +++++++-------
 configure.ac               | 10 ++++++++++
 4 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults
index 7ed6ec0..90724e6
--- a/builds/posix/make.defaults
+++ b/builds/posix/make.defaults
@@ -151,9 +151,11 @@ ECHO=			echo
 QUIET_ECHO=		@echo
 CD=			cd
 CAT=			cat
-AR=			ar @AR_OPTIONS@
+AR=			@AR@ @AR_OPTIONS@
 LN=			@LN_S@
+DLLTOOL=			@DLLTOOL@
 RANLIB=			@RANLIB@
+RC=			@RC@
 BTYACC=$(ROOT)/extern/btyacc/btyacc
 
 CC =	@CC@
diff --git a/builds/posix/make.rules b/builds/posix/make.rules
index ac717d1..01d9910 100644
--- a/builds/posix/make.rules
+++ b/builds/posix/make.rules
@@ -103,4 +103,4 @@ $(OBJ)/%.o: $(SRC_ROOT)/%.cpp
 # Rules for making resource files
 
-$(GEN_ROOT)/%.res: $(SRC_ROOT)/%.rc
-	windres --output-format=coff --include-dir=$(<D) $< $@
+$(OBJ)/%.res: $(SRC_ROOT)/%.rc
+	$(RC) --output-format=coff --include-dir=$(<D) $< $@
diff --git a/builds/posix/make.shared.targets b/builds/posix/make.shared.targets
index 07afa91..62097a7 100644
--- a/builds/posix/make.shared.targets
+++ b/builds/posix/make.shared.targets
@@ -75,16 +75,16 @@ $(OBJ)/dsql/PackageNodes.cpp: $(SRC_ROOT)/dsql/PackageNodes.epp
 
 # Adding resources as prerequisite for some files
 
-$(FilesToAddVersionInfo): $(GEN_ROOT)/jrd/version.res
-$(FilesToAddDialog): $(GEN_ROOT)/remote/os/win32/window.res
-$(FilesToAddDialog2): $(GEN_ROOT)/iscguard/iscguard.res
+$(FilesToAddVersionInfo): $(OBJ)/jrd/version.res
+$(FilesToAddDialog): $(OBJ)/remote/server/os/win32/window.res
+$(FilesToAddDialog2): $(OBJ)/iscguard/iscguard.res
 
 # Explicit dependence of resource script
-$(GEN_ROOT)/remote/os/win32/window.res: $(SRC_ROOT)/remote/os/win32/window.rc $(SRC_ROOT)/remote/os/win32/window.rh \
- $(SRC_ROOT)/jrd/version.rc $(SRC_ROOT)/jrd/build_no.h $(SRC_ROOT)/remote/os/win32/property.rc \
- $(SRC_ROOT)/remote/os/win32/property.rh
+$(OBJ)/remote/server/os/win32/window.res: $(SRC_ROOT)/remote/server/os/win32/window.rc $(SRC_ROOT)/remote/server/os/win32/window.rh \
+ $(SRC_ROOT)/jrd/version.rc $(SRC_ROOT)/jrd/build_no.h $(SRC_ROOT)/remote/server/os/win32/property.rc \
+ $(SRC_ROOT)/remote/server/os/win32/property.rh
 
-$(GEN_ROOT)/iscguard/iscguard.res: $(SRC_ROOT)/iscguard/iscguard.rc $(SRC_ROOT)/iscguard/iscguard.rh \
+$(OBJ)/iscguard/iscguard.res: $(SRC_ROOT)/iscguard/iscguard.rc $(SRC_ROOT)/iscguard/iscguard.rh \
  $(SRC_ROOT)/jrd/version.rc
 
 .PHONY: FORCE
diff --git a/configure.ac b/configure.ac
index 7491444..d153b44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -680,6 +680,16 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 LT_INIT([dlopen win32-dll])
+if test $PLATFORM = win32; then
+  # Checks for mingw resource compiler.
+  AC_CHECK_PROGS([RC],
+     [$target-windres \
+      windres])
+  
+  if test -z "${RC}"; then
+    AC_MSG_ERROR(windres command is not found.);
+  fi
+fi
 
 dnl Check for system header files
 AC_HEADER_DIRENT
-- 
2.2.0

From 9977b806d9da94725c49887016cd88d79c14a66d Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Wed, 19 Nov 2014 08:59:48 +0300
Subject: [PATCH] Define AMD64 for 64-bit mingw.

---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index ea1b81a..8db3f4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -468,6 +468,11 @@ dnl CPU_TYPE=ppc64
     EDITLINE_FLG=N
     RAW_DEVICES_FLG=N
     SHRLIB_EXT=dll
+    case "$target" in
+        x86_64-*-mingw*)
+            AC_DEFINE(AMD64, 1, [Define this if CPU is amd64])
+        ;;
+    esac
     ;;
 
   *)
-- 
2.2.0

From df3755c079857c16be06b17d17cd47d6f484f62d Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Wed, 19 Nov 2014 23:16:18 +0300
Subject: [PATCH] Use mingw-w64 crt for Vista and later. Remove unneeded 
flag "-Dlint"

---
 builds/posix/prefix.mingw | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builds/posix/prefix.mingw b/builds/posix/prefix.mingw
index 5f8dde8..c469cb8 100644
--- a/builds/posix/prefix.mingw
+++ b/builds/posix/prefix.mingw
@@ -20,8 +20,8 @@
 # 
 
 # -Wno-unused-variable is used due to unused gpre generated variables
-PROD_FLAGS=-O2  -DMINGW -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
-DEV_FLAGS=-ggdb -DMINGW -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
+PROD_FLAGS=-O2  -DMINGW -D_WIN32_WINNT=0x0600 -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
+DEV_FLAGS=-ggdb -DMINGW -D_WIN32_WINNT=0x0600 -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
 
 PLATFORM_PATH=os/win32
 
-- 
2.2.0

From dca9b4a320ec175c841a0818cf2884a4a82013b7 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Thu, 20 Nov 2014 07:31:40 +0300
Subject: [PATCH] Add AuthSspi to remote common - needed for win32 target.

---
 builds/posix/make.shared.variables | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builds/posix/make.shared.variables b/builds/posix/make.shared.variables
index 2d3143f..53597e6 100644
--- a/builds/posix/make.shared.variables
+++ b/builds/posix/make.shared.variables
@@ -52,7 +52,7 @@ AllObjects += $(YValve_Objects)
 
 
 # Remote
-Remote_Common:= $(call dirObjects,remote) $(call dirObjects,auth/SecureRemotePassword)
+Remote_Common:= $(call dirObjects,remote) $(call dirObjects,auth/SecureRemotePassword) $(call dirObjects,auth/trusted)
 Remote_Server:= $(call dirObjects,remote/server) $(call dirObjects,auth/SecureRemotePassword/server)
 Remote_Client:= $(call dirObjects,remote/client) $(call dirObjects,auth/SecureRemotePassword/client) \
 				$(call makeObjects,auth/SecurityDatabase,LegacyClient.cpp) \
-- 
2.2.0

From 6c42accb286598f4d8e7749b8e320c869c811e15 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Mon, 24 Nov 2014 09:08:35 +0300
Subject: [PATCH] Some utilities need to link with additional windows libraries

---
 builds/posix/Makefile.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builds/posix/Makefile.in b/builds/posix/Makefile.in
index 86ea5da..34cafdc 100644
--- a/builds/posix/Makefile.in
+++ b/builds/posix/Makefile.in
@@ -357,7 +357,7 @@ utilities: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix g
 firebird_server:	$(FB_DAEMON)
 
 $(FB_DAEMON):	$(Remote_Server_Objects) $(COMMON_LIB)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIB_GUI)
 
 fb_lock_print:	$(LOCKPRINT)
 
@@ -367,7 +367,7 @@ $(LOCKPRINT):	$(LOCKPRINT_Objects) $(COMMON_LIB)
 fbguard:		$(FBGUARD)
 
 $(FBGUARD):		$(FBGUARD_Objects) $(COMMON_LIB)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIB_GUI)
 
 fbsvcmgr:		$(FBSVCMGR)
 
-- 
2.2.0

From 2da7f65171d99bfcd666c5b84419d295fdebd039 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Mon, 24 Nov 2014 10:10:35 +0300
Subject: [PATCH] Fix linking executables and libraries with resources.
 Generate proper import libraries.

---
 builds/posix/make.defaults |  9 +++++----
 builds/posix/Makefile.in.plugins_examples | 2 +-
 builds/posix/prefix.mingw  | 40 ++++++++++++++++++--------------------
 3 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults
index 1a091f6..b2d8939
--- a/builds/posix/make.defaults
+++ b/builds/posix/make.defaults
@@ -215,7 +215,7 @@ vpath %.dll $(LIB)
 #
 
 #LibraryFileName=libfbclient
-LibraryFileName=libfbclient
+LibraryFileName=$(LIB_PREFIX)fbclient
 LibraryFullName=$(LibraryFileName).${SHRLIB_EXT}.${FirebirdVersion}
 LibrarySoName=$(LibraryFileName).${SHRLIB_EXT}.2
 LibraryBaseName=$(LibraryFileName).${SHRLIB_EXT}
@@ -226,7 +226,7 @@ LIBFIREBIRD_BASENAME = $(LIB)/$(LibrarySoName)
 
 # The firebird engine library name
 
-EngineFileName=libEngine${OdsVersion}
+EngineFileName=$(LIB_PREFIX)Engine${OdsVersion}
 EngineSoName=$(EngineFileName).${SHRLIB_EXT}
 ENGINE_SONAME = $(PLUGINS)/$(EngineSoName)
 
@@ -287,6 +287,7 @@ else
 endif
 LIB_PATH_OPTS = $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_RPATH,intl)
 LIB_LINK_SONAME= -Wl,-soname,$(1)
+LIB_LINK_IMPLIB=
 LIB_LINK_MAPFILE= -Wl,--version-script,$(1)
 FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfbclient $(MATHLIB)
 
@@ -301,7 +302,7 @@ LINK_UDF = $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(1).$(SHRLIB_
 LINK_UDF_LIBS = $(THR_LIBS) -L$(LIB) -lib_util
 
 LINK_IB_UTIL = $(LIB_LINK) $(LINK_IBUTIL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\
- $(call LIB_LINK_SONAME,$(IbUtilLibraryName)) $(call LIB_LINK_RPATH,lib)
+ $(call LIB_LINK_SONAME,$(IbUtilLibraryName)) $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_IMPLIB,$(LIB)/lib$(IbUtilLibraryName).a)
 LINK_IB_UTIL_LIBS = $(THR_LIBS)
 
 LINK_INTL = $(LIB_LINK) $(LINK_FBINTL_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAGS)\
@@ -313,7 +314,7 @@ LINK_TRACE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(UNDEF_FLAG
 LINK_TRACE_LIBS = -L$(LIB) $(SO_LINK_LIBS)
 
 LINK_FIREBIRD = $(LIB_LINK) $(LINK_FIREBIRD_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\
- $(call LIB_LINK_SONAME,$(LibrarySoName)) $(call LIB_LINK_RPATH,lib)
+ $(call LIB_LINK_SONAME,$(LibrarySoName)) $(call LIB_LINK_RPATH,lib) $(call LIB_LINK_IMPLIB,$(LIB)/lib$(LibraryBaseName).a)
 LINK_FIREBIRD_LIBS = -L$(LIB) $(LIB_GUI) $(SO_LINK_LIBS) $(MATHLIB)
 
 LINK_ENGINE = $(LIB_LINK) $(LINK_PLUGIN_SYMBOLS) $(LIB_LINK_OPTIONS) $(LIB_FIREBIRD_OPTIONS) $(UNDEF_FLAGS)\
diff --git a/builds/posix/Makefile.in.plugins_examples b/builds/posix/Makefile.in.plugins_examples
index a5331c8..7b3f8b0 100644
--- a/builds/posix/Makefile.in.plugins_examples
+++ b/builds/posix/Makefile.in.plugins_examples
@@ -66,7 +66,7 @@ ifeq ($(PLATFORM),DARWIN)
 	$(LIB_LINK) $(LIB_BUNDLE_OPTIONS) -o $@ $^ @PTHREAD_CFLAGS@ @PTHREAD_LIBS@ \
 		$(FIREBIRD_LIBRARY_LINK)
 else
-	$(LIB_LINK) $(LIB_LINK_OPTIONS) $(LIB_LINK_SONAME)udrcpp_example.$(SHRLIB_EXT) \
+	$(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(LIB_PREFIX)udrcpp_example.$(SHRLIB_EXT)) \
 		$(LIB_PATH_OPTS) -o $@ $^ $(THR_LIBS) $(PLUGINS)/$(LIB_PREFIX)udr_engine.$(SHRLIB_EXT) \
 		$(FIREBIRD_LIBRARY_LINK)
 endif
diff --git a/builds/posix/prefix.mingw b/builds/posix/prefix.mingw
index 626e90c..1754712 100644
--- a/builds/posix/prefix.mingw
+++ b/builds/posix/prefix.mingw
@@ -28,42 +28,38 @@ PLATFORM_PATH=os/win32
 # Override link command for implicit stdc++ linking
 LIB_LINK=$(LD)
 
-LIB_LINK_OPTIONS+=-Wl,--enable-stdcall-fixup
-
 # Strip symbols from release versions to decrease size
 ifeq ($(IsProdTypeBuild),Y)
 EXE_LINK_OPTIONS+=-Wl,-s
 LIB_LINK_OPTIONS+=-Wl,-s
 endif
 
-# Generation of fbclient_ms.lib
-LIB_LINK_IMPLIB:=-Wl,--out-implib,firebird/lib/fbclient_ms.lib
 LIB_GUI:= -mwindows -lcomctl32 -lgdi32
 
 # Add resources to some files
-FilesToAddVersionInfo=$(LIBFBEMBED_SO) $(LIBFBCLIENT_SO) $(LIBFBINTL_SO) \
- $(GSTAT) $(GSEC) $(GFIX) $(QLI) $(ISQL) $(GBAK) $(GPRE)
+FilesToAddVersionInfo=$(FBTRACEMGR) $(LIBFIREBIRD_FULLNAME) $(ENGINE_SONAME) $(LIBFBINTL_SO) \
+ $(FBSVCMGR) $(FBTRACEMGR) $(FBTRACE) $(FBUDF_SO) $(LIBIBUTIL_SO) \
+ $(GBAK) $(GFIX) $(GPRE) $(GSEC) $(GSPLIT) $(GSTAT) $(QLI) $(ISQL) $(NBACKUP)
 # TODO: guardians also must be here
-FilesToAddDialog=$(FB_SUPER_SERVER) $(FB_CLASSIC_SERVER)
-FilesToAddDialog2=$(IBGUARD)
+FilesToAddDialog=$(FB_DAEMON)
+FilesToAddDialog2=$(FBGUARD)
 
 # Suppress 'lib'-prefix
 LIB_PREFIX=
 
 # Override library names to suppress version suffix
-ClientLibraryNameFull := $(ClientLibraryName)
-ClientLibrarySoName := $(ClientLibraryName)
+LibrarySoName := $(LibraryBaseName)
+LibraryFullName := $(LibraryBaseName)
+LIBFIREBIRD_FULLNAME = $(BIN)/$(LibraryBaseName)
+LIBFIREBIRD_SONAME = $(LIBFIREBIRD_FULLNAME)
+LIBFIREBIRD_BASENAME = $(LIBFIREBIRD_FULLNAME)
+LIBIBUTIL_SO = $(BIN)/$(IbUtilLibraryName)
 
-# Looks like MinGW 3 does not support version scripts but support def-files
-LINK_FIREBIRD_SYMBOLS = $(BLD_ROOT)/win32/defs/fbclient_s.def $(BLD_ROOT)/win32/defs/fbclient.def
+LINK_FIREBIRD_SYMBOLS =
+LINK_FBINTL_SYMBOLS =
+LINK_IBUTIL_SYMBOLS =
+LINK_UDRENG_SYMBOLS =
+LINK_EMPTY_SYMBOLS =
+LINK_PLUGIN_SYMBOLS =
-
-# This is required for newly built executable to find newly built shared
-# libraries because on Win32 there is no such thing as LD_LIBRARY_PATH
-LIB=$(BIN)
+LIB_LINK_IMPLIB= -Wl,--out-implib,$(1)
 
-# Special options for UDF link
-LINK_UDF = $(LIB_LINK) $(LIB_LINK_OPTIONS) $(call LIB_LINK_SONAME,$(1).$(SHRLIB_EXT)) -L$(LIB) -lib_util
-LINK_UDF_LIBS = 
-
-# Special options for trace plugin link
-LINK_TRACE_LIBS = -L$(LIB) $(SO_LINK_LIBS)
-- 
2.2.0

From c07f3dacc132799ac4300b1e65369c895f2bd4d9 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Mon, 24 Nov 2014 11:12:17 +0300
Subject: [PATCH] Windows have another sources for FBGUARD.

---
 builds/posix/make.shared.variables | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/builds/posix/make.shared.variables b/builds/posix/make.shared.variables
index 53597e6..ef25f37 100644
--- a/builds/posix/make.shared.variables
+++ b/builds/posix/make.shared.variables
@@ -122,7 +122,11 @@ AllObjects += $(LOCKPRINT_Objects)
 
 
 # Guardian
+ifeq ($(PLATFORM),win32)
+FBGUARD_Objects:= $(call dirObjects,iscguard) $(call makeObjects,remote/server/os/win32,chop.cpp)
+else
 FBGUARD_Objects:= $(call dirObjects,utilities/guard)
+endif
 
 AllObjects += $(FBGUARD_Objects)
 
-- 
2.2.0

From aede726ceaa9cf25424806a0ba438c1216bc0675 Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Thu, 27 Nov 2014 15:57:53 +0300
Subject: [PATCH] Do not install posix scripts for win32 platform.

---
 configure.ac | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 8db3f4c..7491444 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1163,6 +1163,7 @@ if test "x$CROSS" != "x"; then
 AC_CONFIG_FILES([gen/make.crossPlatform:builds/posix/make.$CROSS])
 fi
 
+if test "$PLATFORM" != "win32"; then
 AC_CONFIG_FILES([
 gen/Release/firebird/bin/fb_config:builds/install/posix-common/fb_config.in
 gen/Release/firebird/bin/posixLibrary.sh:builds/install/posix-common/posixLibrary.sh.in
@@ -1176,8 +1177,9 @@ gen/Release/firebird/bin/taruninstall.sh:builds/install/posix-common/taruninstal
 gen/Release/firebird/bin/tarMainUninstall.sh:builds/install/posix-common/tarMainUninstall.sh.in
 gen/Release/firebird/bin/changeServerMode.sh:builds/install/posix-common/changeServerMode.sh.in
 gen/Release/firebird/bin/registerDatabase.sh:builds/install/posix-common/registerDatabase.sh.in
-gen/vers.sh:builds/posix/vers.sh.in
 ])
+fi
+AC_CONFIG_FILES(gen/vers.sh:builds/posix/vers.sh.in)
 
 dnl: Platform Specific Files
 
@@ -1272,6 +1274,11 @@ case "$PLATFORM" in
 
   DARWIN)
     ;;
+  win32)
+    AC_CONFIG_FILES(gen/install/install_classic.bat:builds/install/arch-specific/win32/install_classic.bat
+                     gen/install/install_super.bat:builds/install/arch-specific/win32/install_super.bat
+                     gen/install/uninstall.bat:builds/install/arch-specific/win32/uninstall.bat)
+    ;;
 esac
 if test -f ${MAKE_SRC_DIR}/postfix.${MAKEFILE_POSTFIX};then
 	POSTFIX_FILE=gen/make.platform.postfix:${MAKE_SRC_DIR}/postfix.${MAKEFILE_POSTFIX}
-- 
2.2.0

From 37c6bc45973bc4a83a6f4c9dfb6143eceebde8ea Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Thu, 27 Nov 2014 17:04:52 +0300
Subject: [PATCH] Use variables everywhere.

---
 builds/posix/Makefile.in.examples | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/builds/posix/Makefile.in.examples b/builds/posix/Makefile.in.examples
index 12c454e..544be0a 100644
--- a/builds/posix/Makefile.in.examples
+++ b/builds/posix/Makefile.in.examples
@@ -123,7 +123,7 @@ $(EXAMPLES_DEST)% : $(EXAMPLES_SRC)%
 
 $(EMPLOYEE_DB):	$(EXAMPLES_DEST)/empbuild$(EXEC_EXT) $(INPUT_Sources) $(EXAMPLES_DEST)/isql$(EXEC_EXT)
 	-$(RM) $(EMPLOYEE_DB)
-	./empbuild $(EMPLOYEE_DB)
+	$(EXAMPLES_DEST)/empbuild$(EXEC_EXT) $(EMPLOYEE_DB)
 	$(GFIX) -write sync $(EMPLOYEE_DB)
 	-$(CHMOD_6) $(EMPLOYEE_DB)
 
@@ -147,9 +147,9 @@ $(EXAMPLES_DEST)/empbuild.fdb : $(EXAMPLES_DEST)/empddl.sql $(EXAMPLES_DEST)/emp
 # the intlemp.fdb database.
 
 $(EXAMPLES_DEST)/intlemp.fdb:	$(EXAMPLES_DEST)/intlbld$(EXEC_EXT) $(INTL_Sources) $(EXAMPLES_DEST)/isql$(EXEC_EXT)
-	-$(RM) intlemp.fdb
-	./intlbld intlemp.fdb
-	-$(CHMOD_6) intlemp.fdb
+	-$(RM) $(EXAMPLES_DEST)/intlemp.fdb
+	$(EXAMPLES_DEST)/intlbld$(EXEC_EXT) intlemp.fdb
+	-$(CHMOD_6) $(EXAMPLES_DEST)/intlemp.fdb
 
 $(EXAMPLES_DEST)/intlbld$(EXEC_EXT): $(INTLBLD_Objects) $(COMMON_LIB)
 	$(EXE_LINK) $(EXE_LINK_OPTIONS) @^ -o $@ -L$(LIB) $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
@@ -157,8 +157,8 @@ $(EXAMPLES_DEST)/intlbld$(EXEC_EXT): $(INTLBLD_Objects) $(COMMON_LIB)
 $(EXAMPLES_DEST)/intlbld.c:	$(EXAMPLES_DEST)/intlbuild.fdb $(EXAMPLES_DEST)/intlbld.e
 
 $(EXAMPLES_DEST)/intlbuild.fdb : $(EXAMPLES_DEST)/intlddl.sql $(EXAMPLES_DEST)/intlbld.sql $(EXAMPLES_DEST)/isql$(EXEC_EXT)
-	-$(RM) intlbuild.fdb
-	$(EXAMPLES_DEST)/isql$(EXEC_EXT) -i intlbld.sql
+	-$(RM) $(EXAMPLES_DEST)/intlbuild.fdb
+	$(EXAMPLES_DEST)/isql$(EXEC_EXT) -i $(EXAMPLES_DEST)/intlbld.sql
 
 
 $(EXAMPLES_DEST)/%.sql: $(EXAMPLES_SRC)/empbuild/%.sql
-- 
2.2.0

From e705380c785638ef80fa737b8e7a4654c85986ab Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow@gmail.com>
Date: Fri, 28 Nov 2014 12:28:31 +0300
Subject: [PATCH] Build windows specific utilities for mingw.

---
 builds/posix/Makefile.in           | 26 ++++++++++++++++++++++++++
 builds/posix/make.defaults         |  1 +
 builds/posix/make.shared.variables |  9 +++++++++
 builds/posix/prefix.mingw          |  3 ++-
 4 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/builds/posix/Makefile.in b/builds/posix/Makefile.in
index 34cafdc..effbefb 100644
--- a/builds/posix/Makefile.in
+++ b/builds/posix/Makefile.in
@@ -160,6 +160,9 @@ endif
 	$(MAKE) plugins
 	$(MAKE) examples
 	$(MAKE) rest
+ifeq ($(PLATFORM), win32)
+	$(MAKE) helpers
+endif
 
 
 cross_process:
@@ -416,6 +419,29 @@ $(NBACKUP):		$(NBACKUP_Objects) $(COMMON_LIB)
 
 
 #___________________________________________________________________________
+# install helpers - utilities for Windows to install/uninstall services and etc
+#
+
+.PHONY:	instclient instreg instsvc
+
+helpers: instclient instreg instsvc
+
+instclient: $(INSTCLI)
+
+$(INSTCLI):	$(INSTCLIENT_Objects)
+	$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
+
+instreg: $(INSTREG)
+
+$(INSTREG):	$(INSTREG_Objects)
+	$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS)
+
+instsvc: $(INSTSVC)
+
+$(INSTSVC):	$(INSTSVC_Objects) $(YValve_Objects) $(Common_Objects) $(Remote_Client_Objects)
+	$(STATICEXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(LINK_LIBS) $(MATHLIB)
+
+#___________________________________________________________________________
 # plugins - some of them are required to build examples, use separate entry for them
 #
 
diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults
index 0c4fbd8..7ed6ec0
--- a/builds/posix/make.defaults
+++ b/builds/posix/make.defaults
@@ -348,6 +348,7 @@ GDS_INSTALL	= $(BIN)/gds_install_service$(EXEC_EXT)
 FBGUARD		= $(BIN)/fbguard$(EXEC_EXT)
 IBGUARD		= $(BIN)/ibguard$(EXEC_EXT)
 FBMGR_BIN	= $(BIN)/fbmgr.bin$(EXEC_EXT)
+INSTCLI		= $(BIN)/instclient$(EXEC_EXT)
 INSTREG		= $(BIN)/instreg$(EXEC_EXT)
 INSTSVC		= $(BIN)/instsvc$(EXEC_EXT)
 
diff --git a/builds/posix/make.shared.variables b/builds/posix/make.shared.variables
index ef25f37..18903b9 100644
--- a/builds/posix/make.shared.variables
+++ b/builds/posix/make.shared.variables
@@ -219,3 +219,12 @@ AllObjects += $(CODES_Objects)
 BUILD_Objects:= $(call makeObjects,msgs,build_file.epp)
 
 AllObjects += $(BUILD_Objects)
+
+# Install helpers
+ifeq ($(PLATFORM),win32)
+INSTCLIENT_Objects:= $(call makeObjects,utilities/install,install.cpp install_client.cpp)
+INSTREG_Objects:= $(call makeObjects,utilities/install,install_reg.cpp registry.cpp)
+INSTSVC_Objects:= $(call makeObjects,utilities/install,install_svc.cpp services.cpp)
+
+AllObjects += $(INSTCLIENT_Objects) $(INSTREG_Objects) $(INSTSVC_Objects)
+endif
diff --git a/builds/posix/prefix.mingw b/builds/posix/prefix.mingw
index 1754712..c2bd068 100644
--- a/builds/posix/prefix.mingw
+++ b/builds/posix/prefix.mingw
@@ -41,7 +41,8 @@ LIB_GUI:= -mwindows -lcomctl32 -lgdi32
 # Add resources to some files
 FilesToAddVersionInfo=$(FBTRACEMGR) $(LIBFIREBIRD_FULLNAME) $(ENGINE_SONAME) $(LIBFBINTL_SO) \
  $(FBSVCMGR) $(FBTRACEMGR) $(FBTRACE) $(FBUDF_SO) $(LIBIBUTIL_SO) \
- $(GBAK) $(GFIX) $(GPRE) $(GSEC) $(GSPLIT) $(GSTAT) $(QLI) $(ISQL) $(NBACKUP)
+ $(GBAK) $(GFIX) $(GPRE) $(GSEC) $(GSPLIT) $(GSTAT) $(QLI) $(ISQL) $(NBACKUP) \
+ $(INSTCLI) $(INSTREG) $(INSTSVC)
 # TODO: guardians also must be here
 FilesToAddDialog=$(FB_DAEMON)
 FilesToAddDialog2=$(FBGUARD)
-- 
2.2.0
