Subject: [PATCH]: Building PostgreSQL 7.0.2 on Cygwin 1.1.4
From: Jason Tishler <[email-masked]>
To: Cygwin <[email-masked]>, [email-masked]
Date: Tue, 26 Sep 2000 12:59:11 -0400

From my experience building PostgreSQL 7.0.2 on Cygwin 1.1.4, I have
produced a patch that enables PostgreSQL to build OOTB.

See attached for ChangeLog, Instructions, and patch.diff.

Hopefully this will prove useful to other Cygwin PostgreSQL users.

Thanks to everyone who offered their assistance.

Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation         Fax:   +1 (732) 264-8798
82 Bethany Road, Suite 7             Email: [email-masked]
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
diff -upr postgresql-7.0.2.orig/src/backend/Makefile postgresql-7.0.2/src/backend/Makefile
--- postgresql-7.0.2.orig/src/backend/Makefile	Tue May 30 12:36:34 2000
+++ postgresql-7.0.2/src/backend/Makefile	Wed Sep 20 17:00:14 2000
@@ -66,7 +66,7 @@ endif
 
 ifeq ($(MAKE_DLL), true)
 DLLOBJS= $(OBJS) $(VERSIONOBJ)
-DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
+DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32 -lmsvcrt40
 
 postgres.def: $(DLLOBJS)
 	$(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
diff -upr postgresql-7.0.2.orig/src/backend/utils/Gen_fmgrtab.sh.in postgresql-7.0.2/src/backend/utils/Gen_fmgrtab.sh.in
--- postgresql-7.0.2.orig/src/backend/utils/Gen_fmgrtab.sh.in	Sun May 21 22:34:21 2000
+++ postgresql-7.0.2/src/backend/utils/Gen_fmgrtab.sh.in	Mon Sep 25 11:37:51 2000
@@ -136,7 +136,12 @@ extern void load_file(char *filename);
  */
 
 /* We don't make this static so fmgr_faddr() macros can access it */
-extern FmgrInfo        *fmgr_pl_finfo;
+#ifdef BUILDING_DLL
+#define DLL_INTERFACE __declspec(dllexport)
+#else
+#define DLL_INTERFACE __declspec(dllimport)
+#endif
+extern DLL_INTERFACE FmgrInfo *fmgr_pl_finfo;
 
 #define fmgr_faddr(finfo) \
 ( \
diff -upr postgresql-7.0.2.orig/src/bin/psql/help.c postgresql-7.0.2/src/bin/psql/help.c
--- postgresql-7.0.2.orig/src/bin/psql/help.c	Fri May 26 11:47:18 2000
+++ postgresql-7.0.2/src/bin/psql/help.c	Fri Sep 22 12:50:16 2000
@@ -138,7 +138,7 @@ usage(void)
 	puts("available at <http://www.postgresql.org>.");
 	puts("Report bugs to <[email-masked]>.");
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__CYGWIN__)
 	if (pw)
 		free(pw);
 #endif
diff -upr postgresql-7.0.2.orig/src/makefiles/Makefile.win postgresql-7.0.2/src/makefiles/Makefile.win
--- postgresql-7.0.2.orig/src/makefiles/Makefile.win	Tue Mar  9 08:39:15 1999
+++ postgresql-7.0.2/src/makefiles/Makefile.win	Tue Sep 26 10:07:23 2000
@@ -9,6 +9,9 @@ MAKE_DLL=true
 #MAKE_DLL=false
 SHLIB_LINK=$(DLLLIBS)
 
+CYGWIN_LIBS = -lm -lc
+LIBS:=$(filter-out $(CYGWIN_LIBS), $(LIBS))
+
 %.dll: %.o
 	$(DLLTOOL) --export-all --output-def $*.def $<
 	$(DLLWRAP) -o $@ --def $*.def $< $(SRCDIR)/utils/dllinit.o $(DLLLIBS)
diff -upr postgresql-7.0.2.orig/src/utils/dllinit.c postgresql-7.0.2/src/utils/dllinit.c
--- postgresql-7.0.2.orig/src/utils/dllinit.c	Tue May 25 12:15:32 1999
+++ postgresql-7.0.2/src/utils/dllinit.c	Mon Sep 25 12:18:01 2000
@@ -40,21 +40,19 @@
 #undef WIN32_LEAN_AND_MEAN
 #include <stdio.h>
 
-BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
-		LPVOID reserved /* Not used. */ );
 
 #ifdef __CYGWIN32__
 
 #include <cygwin/cygwin_dll.h>
 DECLARE_CYGWIN_DLL(DllMain);
 /* save hInstance from DllMain */
-HINSTANCE	__hDllInstance_base;
+HANDLE	__hDllInstance_base;
 
 #endif	 /* __CYGWIN32__ */
 
 struct _reent *_impure_ptr;
 
-extern struct _reent *__imp_reent_data;
+extern __declspec(dllimport) struct _reent reent_data;
 
 /*
  *----------------------------------------------------------------------
@@ -84,7 +82,7 @@ DllMain(
 	__hDllInstance_base = hInst;
 #endif	 /* __CYGWIN32__ */
 
-	_impure_ptr = __imp_reent_data;
+	_impure_ptr = &reent_data;
 
 	switch (reason)
 	{
diff -upr postgresql-7.0.2.orig/src/win32/README postgresql-7.0.2/src/win32/README
--- postgresql-7.0.2.orig/src/win32/README	Sun Jan 17 01:27:05 1999
+++ postgresql-7.0.2/src/win32/README	Tue Sep 26 10:45:12 2000
@@ -1,3 +1,7 @@
-Add the included headers endian.h into Cygwin's include/, tcp.h into
-include/netinet, and un.h into include/sys.
+Copy the following headers to Cygwin's include directories:
 
+    $ cp endian.h /usr/include
+    $ cp tcp.h /usr/include/netinet
+
+Note that un.h is already included in Cygwin's Net Release so it no longer
+needs to be manually copied and can be removed from this directory.

--
Want to unsubscribe from this list?
Send a message to [email-masked]