summaryrefslogtreecommitdiffstats
path: root/external/firebird/firebird-cygwin-msvc.patch
blob: c59c614ba5da67cc0216e95321ae4a0a04989f54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
--- src/include/firebird.h	2016-07-15 11:31:27.151443500 +0200
+++ src/include/firebird.h	2016-07-17 14:50:04.043792400 +0200
@@ -32,11 +32,7 @@
 #ifndef INCLUDE_Firebird_H
 #define INCLUDE_Firebird_H
 
-#ifdef _MSC_VER
-#include "gen/autoconfig_msvc.h"
-#else
 #include "gen/autoconfig.h"
-#endif
 
 #if defined __clang__
 //#if __has_feature(address_sanitizer)
--- src/misc/writeBuildNum.sh	2016-07-07 15:57:04.538983200 +0200
+++ src/misc/writeBuildNum.sh	2016-07-13 11:31:18.132820200 +0200
@@ -95,9 +95,9 @@
 createMakeVersion() {

 OdsH="${Root}/src/jrd/ods.h"
-Mini="/tmp/miniods.h"
-TestCpp="/tmp/test.cpp"
-AOut="/tmp/a.out"
+Mini=$(cygpath -m "/tmp/miniods.h")
+TestCpp=$(cygpath -m "/tmp/test.cpp")
+AOut=$(cygpath -m "/tmp/a.out")

 grep ODS_VERSION $OdsH | grep -v ENCODE_ODS >$Mini

--- configure	2016-07-07 15:57:04.538983200 +0200
+++ configure	2016-07-13 11:31:18.132820200 +0200
@@ -21490,13 +21490,12 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
-#include <semaphore.h>
 int main () {
   struct s {
     char a;
-    union { long long x; sem_t y; } b;
+    long long b;
   };
   exit((int)&((struct s*)1024)->b - 1024);
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
--- builds/make.new/config/config.h.in	2016-07-07 15:55:55.693112800 +0200
+++ builds/make.new/config/config.h.in	2016-07-08 13:38:49.994986400 +0200
@@ -211,7 +211,7 @@
 #undef HAVE_GETMNTENT
 
 /* Define to 1 if you have the `getpagesize' function. */
-#undef HAVE_GETPAGESIZE
+#define HAVE_GETPAGESIZE 1
 
 /* Define to 1 if you have the `getrlimit' function. */
 #undef HAVE_GETRLIMIT
@@ -396,7 +396,7 @@
 #undef HAVE_SIGSET
 
 /* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
+#define HAVE_SNPRINTF
 
 /* Define to 1 if you have the <socket.h> header file. */
 #undef HAVE_SOCKET_H
@@ -551,7 +551,7 @@
 #undef HAVE_VFORK_H
 
 /* Define to 1 if you have the `vsnprintf' function. */
-#undef HAVE_VSNPRINTF
+#define HAVE_VSNPRINTF
 
 /* Define to 1 if you have the <winsock2.h> header file. */
 #undef HAVE_WINSOCK2_H
@@ -646,7 +646,7 @@
 #undef TIME_WITH_SYS_TIME
 
 /* Define this if OS is Windows NT */
-#undef WIN_NT
+#define WIN_NT
 
 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
    significant byte first (like Motorola and SPARC, unlike Intel). */
@@ -703,3 +703,20 @@
 #ifndef HAVE_SOCKLEN_T
 typedef int socklen_t;
 #endif
+
+/* taken from src/include/gen/autoconfig_msvc.h */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+#endif
+/* target architecture */
+#if defined(_M_AMD64)
+#define AMD64
+#endif
+
+#define HAVE_IO_H
+#define HAVE_CTIME_S
+
+#if defined _MSC_VER
+#define isnan _isnan
+#endif
+
--- src/common/common.h	2016-07-15 11:31:26.366735500 +0200
+++ src/common/common.h	2016-07-17 16:18:39.121579400 +0200
@@ -551,15 +551,6 @@
 #endif /* WIN_NT */
 
 
-#ifndef FB_CPU
-#error Define FB_CPU for your platform
-#endif
-#ifndef FB_OS
-#error Define FB_OS for your platform
-#endif
-#ifndef FB_CC
-#error Define FB_CC for your platform
-#endif
 
 
 /*****************************************************
diff -ur builds/posix/make.defaults builds/posix/make.defaults
--- builds/posix/make.defaults	2016-07-07 13:56:13.036235166 +0200
+++ builds/posix/make.defaults	2016-07-07 14:29:52.368289242 +0200
@@ -56,7 +56,7 @@
 else
   FIREBIRD=$(FB_BUILD)
 endif
-FIREBIRD_LOCK=$(FIREBIRD)
+FIREBIRD_LOCK=$(shell cygpath -w $(FIREBIRD))
 
 export FIREBIRD
 export FIREBIRD_LOCK
@@ -153,7 +153,7 @@
 CD=			cd
 CAT=			cat
 AR=			ar @AR_OPTIONS@
-LN=			@LN_S@
+LN=			cp
 RANLIB=			@RANLIB@
 BTYACC=$(ROOT)/extern/btyacc/btyacc
 CLOOP=$(GEN_ROOT)/$(TARGET)/cloop/release/bin/cloop
@@ -175,10 +175,10 @@
 
 # Default extensions
 
-ARCH_EXT=		.a
+ARCH_EXT=		.lib
 EXEC_EXT=		@EXEEXT@
 SHRLIB_EXT=@SHRLIB_EXT@
-LIB_PREFIX=		lib
+LIB_PREFIX=
 SHRLIB_FOREIGN_EXT=	$(SHRLIB_EXT)
 
 #_____________________________________________________________________________
@@ -201,9 +202,8 @@
 
 # Search path for libraries
 
-vpath %.so $(LIB)
-vpath %.a $(LIB)
 vpath %.dll $(LIB)
+vpath %.lib $(LIB)
 
 #_____________________________________________________________________________
 
@@ -217,9 +217,9 @@
 #
 
 #LibraryFileName=libfbclient
-LibraryFileName=libfbclient
-LibraryFullName=$(LibraryFileName).${SHRLIB_EXT}.${FirebirdVersion}
-LibrarySoName=$(LibraryFileName).${SHRLIB_EXT}.2
+LibraryFileName=ifbclient
+LibraryFullName=$(LibraryFileName).${SHRLIB_EXT}
+LibrarySoName=$(LibraryFileName).${SHRLIB_EXT}
 LibraryBaseName=$(LibraryFileName).${SHRLIB_EXT}
 
 LIBFIREBIRD_FULLNAME = $(LIB)/$(LibraryFullName)
@@ -228,7 +228,7 @@
 
 # The firebird engine library name
 
-EngineFileName=libEngine${OdsVersion}
+EngineFileName=Engine12
 EngineSoName=$(EngineFileName).${SHRLIB_EXT}
 ENGINE_SONAME = $(PLUGINS)/$(EngineSoName)
 
@@ -242,7 +242,7 @@
   ifeq ($(STD_EDITLINE), true)
 	LIBEDITLINE := -l$(READLINE)
   else
-	LIBEDITLINE := $(LIB)/libedit.a
+	LIBEDITLINE := $(LIB)/$(LIB_PREFIX)edit$(ARCH_EXT)
   endif
 endif
 
@@ -313,7 +313,7 @@
 
 LIB_LINK_SONAME= -Wl,-soname,$(1)
 LIB_LINK_MAPFILE= -Wl,--version-script,$(1)
-FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfbclient $(MATHLIB)
+FIREBIRD_LIBRARY_LINK= -L$(LIB) -lifbclient $(MATHLIB)
 
 EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(LINK_EMPTY_SYMBOLS)
 LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared
@@ -355,7 +355,7 @@
 
 # Pay attention - we place common library into obj, not lib dir
 # It's just a set of object files, prepared to be used by ld, not an output library
-COMMON_LIB	= $(OBJ)/common.a
+COMMON_LIB	= $(OBJ)/$(LIB_PREFIX)common$(ARCH_EXT)
 
 # From utilities
 CREATE_DB	= $(RBIN)/create_db$(EXEC_EXT)
--- builds/posix/Makefile.in	2016-07-07 15:56:06.459221300 +0200
+++ builds/posix/Makefile.in	2016-07-13 12:44:57.134217200 +0200
@@ -33,7 +33,7 @@
 #		Alex Peshkoff - created single makefile based on Mark's files
 #

-ROOT=$(shell cd ..; pwd)
+ROOT=$(shell cygpath -m '$(shell cd ..; pwd)')

 include     make.defaults
 ifeq ($(CROSS_OUT), Y)
@@ -178,7 +178,7 @@
 .PHONY:	cross1 cross2 boot yvalve engine fbintl gpre utilities plugins rest codes ids examples cross_rest preliminaryCheck
 
 master_process:
-	ln -sf $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
+	cp -f $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
 	$(MAKE) updateBuildNum
 	$(MAKE) export_lists
 	$(MAKE) extern
@@ -214,7 +215,7 @@
 	$(MAKE) CROSS_OUT=Y cross2

 cross1:
-	ln -sf $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
+	cp -f $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
 	$(MAKE) updateBuildNum
 	$(MAKE) export_lists
 	$(MAKE) extern
@@ -239,7 +240,7 @@
 	$(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/
 
 cross2:
-	ln -sf $(SRC_ROOT)/include/cross/$(CROSS_CONFIG) $(SRC_ROOT)/include/gen/autoconfig.h
+	cp -f $(SRC_ROOT)/include/cross/$(CROSS_CONFIG) $(SRC_ROOT)/include/gen/autoconfig.h
 	$(MAKE) prerequisites
 	$(MAKE) tommath
 	$(MAKE) yvalve
@@ -310,7 +311,7 @@
 
 # remote redirector is statically linked in main FB library
 $(LIBFIREBIRD_FULLNAME):	$(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
-	$(LINK_FIREBIRD) -o $@ $^ $(LINK_FIREBIRD_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,lib/libfbclient.$(SHRLIB_EXT))
+	$(LINK_FIREBIRD) $(CPPFLAGS) -o $@ $^ $(LINK_FIREBIRD_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,lib/libfbclient.$(SHRLIB_EXT))
 
 
 #___________________________________________________________________________
@@ -320,8 +321,8 @@
 
 engine: $(ENGINE_SONAME)
 
-$(ENGINE_SONAME):	$(Engine_Objects) $(SVC_Objects) $(COMMON_LIB)
-	$(LINK_ENGINE) -o $@ $^ $(LINK_ENGINE_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/$(EngineSoName))
+$(ENGINE_SONAME):	$(Engine_Objects) $(SVC_Objects) $(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
+	$(LINK_ENGINE) $(CPPFLAGS) -o $@ $^ $(LINK_ENGINE_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,plugins/$(EngineSoName))
 
 
 #___________________________________________________________________________
@@ -330,8 +331,8 @@
 
 fbintl: $(LIBFBINTL_SO)
 
-$(LIBFBINTL_SO):	$(INTL_Objects) $(COMMON_LIB)
-	$(LINK_INTL) -o $@ $^ $(LINK_INTL_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,intl/libfbintl.$(SHRLIB_EXT))
+$(LIBFBINTL_SO):	$(INTL_Objects) $(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
+	$(LINK_INTL) $(CPPFLAGS) -o $@ $^ $(LINK_INTL_LIBS) $(call LIB_LINK_DARWIN_INSTALL_NAME,intl/libfbintl.$(SHRLIB_EXT))
 
 
 #___________________________________________________________________________
@@ -427,12 +429,13 @@
 
 .PHONY:	firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup
 
-utilities: firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup udfsupport
+# fbguard currently fails to link, with missing fork etc, in util.cpp
+utilities: firebird_server fb_lock_print fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup udfsupport
 
 firebird_server:	$(FB_DAEMON)
 
-$(FB_DAEMON):	$(Remote_Server_Objects) $(COMMON_LIB)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(call LINK_DARWIN_RPATH,..)
+$(FB_DAEMON):	$(Remote_Server_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIB_GUI) $(call LINK_DARWIN_RPATH,..)
 
 fb_lock_print:	$(LOCKPRINT)
 
@@ -633,7 +635,7 @@
 IBASE_ExtraFiles = include/types_pub.h include/consts_pub.h dsql/sqlda_pub.h common/dsc_pub.h jrd/ibase.h jrd/inf_pub.h jrd/blr.h include/gen/iberror.h
 SRC_IBASE_ExtraFiles = $(addprefix $(SRC_ROOT)/, $(IBASE_ExtraFiles))
 MAKE_HEADER_Src = $(addprefix $(SRC_ROOT)/, misc/makeHeader.cpp)
-MAKE_HEADER_Bin = ./makeHeader
+MAKE_HEADER_Bin = ./makeHeader$(EXEC_EXT)
 
 $(INCLUDE_DEST)/ibase.h: $(SRC_IBASE_ExtraFiles)
 	$(STATICEXE_LINK) -o $(MAKE_HEADER_Bin) $(MAKE_HEADER_Src)
diff -ur builds/posix/make.rules builds/posix/make.rules
--- builds/posix/make.rules	2016-07-07 13:56:13.036235166 +0200
+++ builds/posix/make.rules	2016-07-07 14:31:16.116291485 +0200
@@ -92,26 +92,23 @@
 
 $(OBJ)/%.o: $(SRC_ROOT)/%.c
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 $(OBJ)/%.o: $(OBJ)/%.cpp
 	$(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 $(OBJ)/%.o: $(SRC_ROOT)/%.cpp
 	$(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 $(OBJ)/%.o: $(ROOT)/%.cpp
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 .SUFFIXES: .epp .e
 
 # Rules for making resource files
 
 $(GEN_ROOT)/%.res: $(SRC_ROOT)/%.rc
-	windres --output-format=coff --include-dir=$(<D) $< $@
+	mkdir -p $(@D)
+	rc.exe $(SOLARINC) /fo $@ $<
 
 # Rule for making gbak files when cross-compiling
 
--- src/common/utils.cpp	2016-07-15 11:31:26.746871100 +0200
+++ src/common/utils.cpp	2016-07-19 19:14:45.370689300 +0200
@@ -880,15 +880,15 @@
 	FILETIME utime, stime, dummy;
 	if (GetProcessTimes(GetCurrentProcess(), &dummy, &dummy, &stime, &utime))
 	{
-		LARGE_INTEGER lint;
+		LARGE_INTEGER myLargeInt;
 
-		lint.HighPart = stime.dwHighDateTime;
-		lint.LowPart = stime.dwLowDateTime;
-		sysTime = lint.QuadPart / 10000;
-
-		lint.HighPart = utime.dwHighDateTime;
-		lint.LowPart = utime.dwLowDateTime;
-		userTime = lint.QuadPart / 10000;
+		myLargeInt.HighPart = stime.dwHighDateTime;
+		myLargeInt.LowPart = stime.dwLowDateTime;
+		sysTime = myLargeInt.QuadPart / 10000;
+
+		myLargeInt.HighPart = utime.dwHighDateTime;
+		myLargeInt.LowPart = utime.dwLowDateTime;
+		userTime = myLargeInt.QuadPart / 10000;
 	}
 	else
 	{
diff -ur builds/posix/prefix.mingw builds/posix/prefix.mingw
--- builds/posix/prefix.mingw	2016-07-07 13:56:13.048235166 +0200
+++ builds/posix/prefix.mingw	2016-07-07 14:50:54.704323046 +0200
@@ -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  -Dlint -DWIN32_LEAN_AND_MEAN
+DEV_FLAGS=-ggdb  -DMINGW -Dlint -DWIN32_LEAN_AND_MEAN

 PLATFORM_PATH=os/win32

@@ -29,6 +29,7 @@
 LIB_LINK=$(LD)

 LIB_LINK_OPTIONS+=-Wl,--enable-stdcall-fixup
+LIB_PLATFORM_RPATH=

 # Strip symbols from release versions to decrease size
 ifeq ($(IsProdTypeBuild),Y)
@@ -36,6 +37,9 @@
 LIB_LINK_OPTIONS+=-Wl,-s
 endif

+LIB_LINK_OPTIONS=
+LINK_OPTS=
+
 # Generation of fbclient_ms.lib
 LIB_LINK_IMPLIB:=-Wl,--out-implib,firebird/lib/fbclient_ms.lib
 LIB_GUI:= -mwindows -lcomctl32 -lgdi32
@@ -55,7 +59,9 @@
 ClientLibrarySoName := $(ClientLibraryName)

 # 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 = /def:$(BLD_ROOT)/win32/defs/fbclient_s.def /def:$(BLD_ROOT)/win32/defs/firebird.def
+LINK_PLUGIN_SYMBOLS = /def:$(BLD_ROOT)/win32/defs/plugin.def
+LINK_IBUTIL_SYMBOLS = /def:$(BLD_ROOT)/win32/defs/ib_util.def

 # 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
--- builds/posix/make.shared.variables	2016-07-22 17:07:46.650672300 +0200
+++ builds/posix/make.shared.variables	2016-07-23 10:44:41.311454600 +0200
@@ -62,6 +62,7 @@
				$(SecDbCache)
 Remote_Client:= $(call dirObjects,remote/client) $(call dirObjects,auth/SecureRemotePassword/client) \
 				$(call makeObjects,auth/SecurityDatabase,LegacyClient.cpp) \
+				$(call dirObjects,auth/trusted) \
 				$(call dirObjects,plugins/crypt/arc4)
 Remote_Server_Objects:= $(Remote_Common) $(Remote_Server)
 Remote_Client_Objects:= $(Remote_Common) $(Remote_Client)
diff -ur configure configure
--- configure	2016-07-07 13:55:54.976234682 +0200
+++ configure	2016-07-07 14:54:30.012328812 +0200
@@ -3337,6 +3337,14 @@
     SHRLIB_EXT=dll
     ;;

+  *-*-cygwin*)
+    MAKEFILE_PREFIX=mingw
+    PLATFORM=win32
+    EDITLINE_FLG=N
+    RAW_DEVICES_FLG=N
+    SHRLIB_EXT=dll
+    ;;
+
   *)
     as_fn_error $? "unsupported platform ${build}" "$LINENO" 5
     ;;
@@ -8432,6 +8432,9 @@
 mingw*)
   opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
   ;;
+cygwin*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
 esac

 # Try without a prefix underscore, then with it.
diff -ur extern/btyacc/main.c extern/btyacc/main.c
--- extern/btyacc/main.c	2016-07-07 13:55:55.448234695 +0200
+++ extern/btyacc/main.c	2016-07-07 14:56:03.560331317 +0200
@@ -2,7 +2,7 @@
 #include <signal.h>
 #include <stdio.h>

-#if defined(WIN32)
+#if defined(WIN32) || defined(_WIN32)
 #include <io.h>
 #else
 #include <unistd.h>
diff -ur extern/btyacc/Makefile extern/btyacc/Makefile
--- extern/btyacc/Makefile	2016-07-07 13:55:55.448234695 +0200
+++ extern/btyacc/Makefile	2016-07-07 14:57:42.284333961 +0200
@@ -30,7 +30,7 @@
 
 PRINT	      = pr -f -l88
 
-PROGRAM	      = btyacc
+PROGRAM	      = btyacc.exe
 
 SRCS	      = closure.c error.c lalr.c lr0.c main.c mkpar.c output.c	\
 		mstring.c reader.c readskel.c skeleton.c symtab.c verbose.c warshall.c
@@ -58,7 +58,7 @@
 index:;		ctags -wx $(HDRS) $(SRCS)
 
 install:	$(PROGRAM)
-		cp $(PROGRAM).exe /bin
+		cp $(PROGRAM) /bin
 
 oldinstall:	$(PROGRAM)
 		@echo Installing $(PROGRAM) in $(DEST)
--- extern/cloop/src/tests/test1/CppTest.cpp	2016-07-07 15:56:27.948015300 +0200
+++ extern/cloop/src/tests/test1/CppTest.cpp	2016-07-13 18:58:48.529822600 +0200
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <assert.h>
 
+#define WIN32
 #ifdef WIN32
 #include <windows.h>
 #define DLL_EXPORT __declspec(dllexport)
--- extern/cloop/src/tests/test1/CTest.c	2016-07-07 15:56:27.611791300 +0200
+++ extern/cloop/src/tests/test1/CTest.c	2016-07-13 17:04:22.805090300 +0200
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#define WIN32
 #ifdef WIN32
 #include <windows.h>
 #define DLL_EXPORT __declspec(dllexport)
--- extern/cloop/Makefile	2016-07-07 15:56:28.279136300 +0200
+++ extern/cloop/Makefile	2016-07-13 16:22:38.493479800 +0200
@@ -11,8 +11,8 @@
 SRC_DIR		:= src
 BUILD_DIR	:= build
 OUT_DIR		:= output
-SHRLIB_EXT	:= .so
-EXE_EXT		:=
+SHRLIB_EXT	:= .dll
+EXE_EXT		:= .exe
 
 OBJ_DIR := $(BUILD_DIR)/$(TARGET)
 BIN_DIR := $(OUT_DIR)/$(TARGET)/bin
@@ -27,7 +27,7 @@
 OBJS_C := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS_C))
 OBJS_CPP := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRCS_CPP))
 
-C_FLAGS := -ggdb -fPIC -MMD -MP -W -Wall -Wno-unused-parameter
+C_FLAGS := -fPIC
 CXX_FLAGS := $(C_FLAGS)
 FPC_FLAGS := -Mdelphi
 
@@ -53,7 +53,7 @@
 .PHONY: all mkdirs clean
 
 all: mkdirs \
-	$(BIN_DIR)/cloop	\
+	$(BIN_DIR)/cloop$(EXE_EXT)	\
 	$(BIN_DIR)/test1-c$(SHRLIB_EXT)	\
 	$(BIN_DIR)/test1-c$(EXE_EXT)	\
 	$(BIN_DIR)/test1-cpp$(SHRLIB_EXT)	\
@@ -63,6 +63,10 @@
 
 mkdirs: $(OBJ_DIRS) $(BIN_DIR) $(LIB_DIR)
 
+# These files have the same basename, so various conflicting intermediate files break the build
+$(BIN_DIR)/test1-c$(EXE_EXT): | $(BIN_DIR)/test1-c$(SHRLIB_EXT)
+$(BIN_DIR)/test1-cpp$(EXE_EXT): | $(BIN_DIR)/test1-cpp$(SHRLIB_EXT)
+
 $(OBJ_DIRS) $(BIN_DIR) $(LIB_DIR):
 	@mkdir -p $@
 
@@ -74,7 +74,7 @@
 -include $(addsuffix .d,$(basename $(OBJS_C)))
 -include $(addsuffix .d,$(basename $(OBJS_CPP)))
 
-$(BIN_DIR)/cloop: \
+$(BIN_DIR)/cloop$(EXE_EXT): \
 	$(OBJ_DIR)/cloop/Expr.o \
 	$(OBJ_DIR)/cloop/Generator.o \
 	$(OBJ_DIR)/cloop/Lexer.o \
@@ -83,20 +83,20 @@
 
 	$(LD) $^ -o $@
 
-$(SRC_DIR)/tests/test1/CalcCApi.h: $(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl
-	$(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl c-header $@ CALC_C_API_H CALC_I
+$(SRC_DIR)/tests/test1/CalcCApi.h: $(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl
+	$(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl c-header $@ CALC_C_API_H CALC_I
 
-$(SRC_DIR)/tests/test1/CalcCApi.c: $(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl $(SRC_DIR)/tests/test1/CalcCApi.h
-	$(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl c-impl $@ CalcCApi.h CALC_I
+$(SRC_DIR)/tests/test1/CalcCApi.c: $(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl $(SRC_DIR)/tests/test1/CalcCApi.h
+	$(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl c-impl $@ CalcCApi.h CALC_I
 
-$(SRC_DIR)/tests/test1/CalcCppApi.h: $(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl
-	$(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl c++ $@ CALC_CPP_API_H calc I
+$(SRC_DIR)/tests/test1/CalcCppApi.h: $(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl
+	$(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl c++ $@ CALC_CPP_API_H calc I
 
-$(SRC_DIR)/tests/test1/CalcPascalApi.pas: $(BIN_DIR)/cloop \
+$(SRC_DIR)/tests/test1/CalcPascalApi.pas: $(BIN_DIR)/cloop$(EXE_EXT) \
 	$(SRC_DIR)/tests/test1/Interface.idl \
 	$(SRC_DIR)/tests/test1/CalcPascalApi.interface.pas \
 	$(SRC_DIR)/tests/test1/CalcPascalApi.implementation.pas
-	$(BIN_DIR)/cloop $(SRC_DIR)/tests/test1/Interface.idl pascal $@ CalcPascalApi \
+	$(BIN_DIR)/cloop$(EXE_EXT) $(SRC_DIR)/tests/test1/Interface.idl pascal $@ CalcPascalApi \
 		--uses "SysUtils" \
 		--interfaceFile $(SRC_DIR)/tests/test1/CalcPascalApi.interface.pas \
 		--implementationFile $(SRC_DIR)/tests/test1/CalcPascalApi.implementation.pas \
@@ -108,23 +108,23 @@
 	$(OBJ_DIR)/tests/test1/CalcCApi.o \
 	$(OBJ_DIR)/tests/test1/CTest.o \
 
-	$(LD) $^ -shared -ldl -o $@
+	$(LD) $^ -o $@
 
 $(BIN_DIR)/test1-c$(EXE_EXT): \
 	$(OBJ_DIR)/tests/test1/CalcCApi.o \
 	$(OBJ_DIR)/tests/test1/CTest.o \
 
-	$(LD) $^ -ldl -o $@
+	$(LD) $^ -o $@
 
 $(BIN_DIR)/test1-cpp$(SHRLIB_EXT): \
 	$(OBJ_DIR)/tests/test1/CppTest.o \
 
-	$(LD) $^ -shared -ldl -o $@
+	$(LD) $^ -o $@
 
 $(BIN_DIR)/test1-cpp$(EXE_EXT): \
 	$(OBJ_DIR)/tests/test1/CppTest.o \
 
-	$(LD) $^ -ldl -o $@
+	$(LD) $^ -o $@
 
 $(BIN_DIR)/test1-pascal$(SHRLIB_EXT): \
 	$(SRC_DIR)/tests/test1/PascalClasses.pas \
diff -ur src/common/classes/fb_string.cpp src/common/classes/fb_string.cpp
--- src/common/classes/fb_string.cpp	2016-07-07 13:55:56.064234711 +0200
+++ src/common/classes/fb_string.cpp	2016-07-07 14:59:01.516336083 +0200
@@ -32,6 +32,12 @@
 #include <ctype.h>
 #include <stdarg.h>
 
+#ifdef WIN_NT
+#pragma comment(lib, "User32.lib")
+#pragma comment(lib, "advapi32")
+#pragma comment(lib, "shell32.lib")
+#endif
+
 #ifdef HAVE_STRCASECMP
 #define STRNCASECMP strncasecmp
 #else
diff -ur src/misc/makeHeader.cpp src/misc/makeHeader.cpp
--- src/misc/makeHeader.cpp	2016-07-07 13:56:00.100234819 +0200
+++ src/misc/makeHeader.cpp	2016-07-07 15:00:14.780338045 +0200
@@ -1,9 +1,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-//#ifdef HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-//#endif
+#endif



--- builds/posix/Makefile.in.plugins_examples.orig	2020-11-13 18:07:52.515550600 +0100
+++ builds/posix/Makefile.in.plugins_examples	2020-11-13 18:08:33.218626500 +0100
@@ -28,7 +28,7 @@
 #  Adriano dos Santos Fernandes
 #
 
-ROOT=$(shell cd ..; pwd)
+ROOT=$(shell cygpath -m '$(shell cd ..; pwd)')
 
 ifeq ($(IsDeveloper), Y)
   DefaultTarget := Debug
--- examples/dbcrypt/CryptApplication.cpp.orig	2020-11-13 20:57:11.222938900 +0100
+++ examples/dbcrypt/CryptApplication.cpp	2020-11-13 21:01:19.332316100 +0100
@@ -27,6 +27,13 @@
 #include "../interfaces/ifaceExamples.h"
 #include <firebird/Message.h>
 
+#include "gen/autoconfig.h"
+
+#ifdef WIN_NT
+#include <windows.h>
+#include <winbase.h>
+#endif
+
 using namespace Firebird;
 
 class CryptKey : public ICryptKeyCallbackImpl<CryptKey, CheckStatusWrapper>
@@ -238,8 +238,15 @@
 		av++;
 	}
 
+#ifdef WIN_NT
+	if (!getenv("ISC_USER"))
+		SetEnvironmentVariable("ISC_USER", "sysdba");
+	if (!getenv("ISC_PASSWORD"))
+		SetEnvironmentVariable("ISC_PASSWORD", "masterkey");
+#else
 	setenv("ISC_USER", "sysdba", 0);
 	setenv("ISC_PASSWORD", "masterkey", 0);
+#endif
 
 	App app;
 	try