OSDN Git Service

Make "win" a separate port from "cygwin". This means you can now
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 21 Mar 2003 17:18:34 +0000 (17:18 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 21 Mar 2003 17:18:34 +0000 (17:18 +0000)
configure under native Windows (MinGW that is), but you won't get very far
compiling yet.  The dynaloader files are from Jan Wieck's patch set.

16 files changed:
configure
configure.in
src/Makefile.shlib
src/backend/Makefile
src/backend/port/dynloader/cygwin.c [new file with mode: 0644]
src/backend/port/dynloader/cygwin.h [new file with mode: 0644]
src/backend/port/dynloader/win.c
src/backend/port/dynloader/win.h
src/include/port/cygwin.h [new file with mode: 0644]
src/include/port/win.h
src/interfaces/python/GNUmakefile
src/makefiles/Makefile.cygwin [new file with mode: 0644]
src/makefiles/Makefile.win
src/template/cygwin [new file with mode: 0644]
src/template/win
src/test/regress/GNUmakefile

index 4c1b6b1..2c673fc 100755 (executable)
--- a/configure
+++ b/configure
@@ -1387,13 +1387,14 @@ case $host_os in
      aix*) template=aix ;;
     beos*) template=beos ;;
     bsdi*) template=bsdi ;;
-  cygwin*) template=win ;;
+  cygwin*) template=cygwin ;;
   darwin*) template=darwin ;;
     dgux*) template=dgux ;;
  freebsd*) template=freebsd ;;
     hpux*) template=hpux ;;
     irix*) template=irix5 ;;
    linux*) template=linux ;;
+   mingw*) template=win ;;
   netbsd*) template=netbsd ;;
 nextstep*) template=nextstep ;;
  openbsd*) template=openbsd ;;
index a79e010..99a8d9d 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.238 2003/03/06 03:16:55 tgl Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.239 2003/03/21 17:18:34 petere Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -58,13 +58,14 @@ case $host_os in
      aix*) template=aix ;;
     beos*) template=beos ;;
     bsdi*) template=bsdi ;;
-  cygwin*) template=win ;;
+  cygwin*) template=cygwin ;;
   darwin*) template=darwin ;;
     dgux*) template=dgux ;;
  freebsd*) template=freebsd ;;
     hpux*) template=hpux ;;
     irix*) template=irix5 ;;
    linux*) template=linux ;;
+   mingw*) template=win ;;
   netbsd*) template=netbsd ;;
 nextstep*) template=nextstep ;;
  openbsd*) template=openbsd ;;
index 5e1f0aa..2b07f2a 100644 (file)
@@ -6,7 +6,7 @@
 # Copyright (c) 1998, Regents of the University of California
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.66 2003/01/11 17:22:19 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.67 2003/03/21 17:18:34 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -194,7 +194,7 @@ ifeq ($(PORTNAME), unixware)
   LINK.shared          += -Wl,-z,text -Wl,-h,$(soname)
 endif
 
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
   shlib                        := $(NAME)$(DLSUFFIX)
 endif
 
@@ -225,7 +225,7 @@ all-static-lib: lib$(NAME).a
 
 all-shared-lib: $(shlib)
 
-ifneq ($(PORTNAME), win)
+ifneq ($(PORTNAME), cygwin)
 
 ifndef LORDER
 MK_NO_LORDER := true
@@ -239,12 +239,12 @@ else
 endif
        $(RANLIB) $@
 
-endif # not win
+endif # not cygwin
 
 ifeq ($(enable_shared), yes)
 
 ifneq ($(PORTNAME), beos)
-ifneq ($(PORTNAME), win)
+ifneq ($(PORTNAME), cygwin)
 ifneq ($(PORTNAME), aix)
 
 # Normal case
@@ -270,9 +270,9 @@ $(shlib): lib$(NAME).a
        
 endif # PORTNAME == aix
 
-else # PORTNAME == win
+else # PORTNAME == cygwin
 
-# WIN case
+# Cygwin case
 $(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT)
        $(DLLTOOL) --export-all --output-def $(NAME).def $(OBJS)
        $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(DLLINIT) $(SHLIB_LINK)
@@ -281,7 +281,7 @@ $(shlib) lib$(NAME).a: $(OBJS) $(DLLINIT)
 $(DLLINIT): $(DLLINIT:%.o=%.c)
        $(MAKE) -C $(@D) $(@F)
 
-endif # PORTNAME == win
+endif # PORTNAME == cygwin
 
 else # PORTNAME == beos
 
@@ -308,7 +308,7 @@ install-lib-static: lib$(NAME).a
 ifeq ($(enable_shared), yes)
 install-lib-shared: $(shlib)
        $(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
-ifneq ($(PORTNAME), win)
+ifneq ($(PORTNAME), cygwin)
 ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
        cd $(DESTDIR)$(libdir) && \
        rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) && \
@@ -320,7 +320,7 @@ ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
        $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX)
 endif
 
-endif # not win
+endif # not cygwin
 endif # enable_shared
 
 
@@ -351,6 +351,6 @@ ifdef EXPSUFF
        rm -f lib$(NAME)$(EXPSUFF)
 endif
 endif
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
        rm -f $(NAME).dll $(NAME).def
 endif
index e649910..82cdd0f 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.94 2003/02/03 14:24:07 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.95 2003/03/21 17:18:34 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -31,12 +31,12 @@ endif
 
 all: submake-libpgport postgres $(POSTGRES_IMP)
 
-ifneq ($(PORTNAME), win)
+ifneq ($(PORTNAME), cygwin)
 
 postgres: $(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
 
-else # win
+else # cygwin
 
 postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
        $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
@@ -51,7 +51,7 @@ postgres.def: $(OBJS)
 libpostgres.a: postgres.def
        $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
 
-endif # win
+endif # cygwin
 
 ifeq ($(PORTNAME), aix)
 
@@ -126,7 +126,7 @@ distprep:
 ##########################################################################
 
 install: all installdirs install-bin
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
 ifeq ($(MAKE_DLL), true)
        $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
 endif
@@ -148,7 +148,7 @@ endif
 
 installdirs:
        $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
 ifeq ($(MAKE_DLL), true)
        $(mkinstalldirs) $(DESTDIR)$(libdir)
 endif
@@ -165,7 +165,7 @@ uninstall:
 ifeq ($(MAKE_EXPORTS), true)
        rm -f $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
 endif
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
 ifeq ($(MAKE_DLL), true)
        rm -f $(DESTDIR)$(libdir)/libpostgres.a
 endif
@@ -183,7 +183,7 @@ clean:
        rm -f postgres$(X) $(POSTGRES_IMP) \
                $(top_srcdir)/src/include/parser/parse.h \
                $(top_builddir)/src/include/utils/fmgroids.h
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
        rm -f postgres.dll postgres.def libpostgres.a
 endif
        for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
diff --git a/src/backend/port/dynloader/cygwin.c b/src/backend/port/dynloader/cygwin.c
new file mode 100644 (file)
index 0000000..9a1436f
--- /dev/null
@@ -0,0 +1 @@
+/* Dummy file used for nothing at this point; see cygwin.h */
diff --git a/src/backend/port/dynloader/cygwin.h b/src/backend/port/dynloader/cygwin.h
new file mode 100644 (file)
index 0000000..ef476ff
--- /dev/null
@@ -0,0 +1,36 @@
+/*-------------------------------------------------------------------------
+ *
+ * Dynamic loader declarations for Cygwin
+ *
+ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $Header: /cvsroot/pgsql/src/backend/port/dynloader/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $
+ *
+ *-------------------------------------------------------------------------
+  */
+#ifndef PORT_PROTOS_H
+#define PORT_PROTOS_H
+
+#include <dlfcn.h>
+#include "utils/dynamic_loader.h"
+
+/*
+ * In some older systems, the RTLD_NOW flag isn't defined and the mode
+ * argument to dlopen must always be 1.  The RTLD_GLOBAL flag is wanted
+ * if available, but it doesn't exist everywhere.
+ * If it doesn't exist, set it to 0 so it has no effect.
+ */
+#ifndef RTLD_NOW
+#define RTLD_NOW 1
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+#define pg_dlopen(f)   dlopen((f), RTLD_NOW | RTLD_GLOBAL)
+#define pg_dlsym               dlsym
+#define pg_dlclose             dlclose
+#define pg_dlerror             dlerror
+
+#endif   /* PORT_PROTOS_H */
index 62469cb..005ac40 100644 (file)
@@ -1,4 +1,27 @@
-/* Dummy file used for nothing at this point
- *
- * see win.h
- */
+/* $Header: /cvsroot/pgsql/src/backend/port/dynloader/Attic/win.c,v 1.2 2003/03/21 17:18:34 petere Exp $ */
+
+#include <windows.h>
+
+char *
+dlerror(void)
+{
+       return "error";
+}
+
+int
+dlclose(void *handle)
+{
+       return FreeLibrary((HMODULE)handle) ? 0 : 1;
+}
+
+void *
+dlsym(void *handle, const char *symbol)
+{
+       return (void *)GetProcAddress((HMODULE)handle, symbol);
+}
+
+void *
+dlopen(const char *path, int mode)
+{
+       return (void *)LoadLibrary(path);
+}
index 2969c8e..e08113a 100644 (file)
@@ -1,44 +1,9 @@
-/*-------------------------------------------------------------------------
- *
- * win.h
- *       port-specific prototypes for Intel x86/Window NT
- *
- *
- * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * win.h,v 1.2 1995/03/17 06:40:18 andrew Exp
- *
- *-------------------------------------------------------------------------
-  */
 #ifndef PORT_PROTOS_H
 #define PORT_PROTOS_H
 
-#include <dlfcn.h>
 #include "utils/dynamic_loader.h"
 
-/*
- * Dynamic Loader on Intel x86/Windows NT
- *
- * this dynamic loader uses the system dynamic loading interface for shared
- * libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
- * library as the file to be dynamically loaded.
- */
-
-/*
- * In some older systems, the RTLD_NOW flag isn't defined and the mode
- * argument to dlopen must always be 1.  The RTLD_GLOBAL flag is wanted
- * if available, but it doesn't exist everywhere.
- * If it doesn't exist, set it to 0 so it has no effect.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#define pg_dlopen(f)   dlopen((f), RTLD_NOW | RTLD_GLOBAL)
+#define pg_dlopen(f)   dlopen((f), 1)
 #define pg_dlsym               dlsym
 #define pg_dlclose             dlclose
 #define pg_dlerror             dlerror
diff --git a/src/include/port/cygwin.h b/src/include/port/cygwin.h
new file mode 100644 (file)
index 0000000..cb6d6ec
--- /dev/null
@@ -0,0 +1,26 @@
+/* $Header: /cvsroot/pgsql/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */
+
+#define HAS_TEST_AND_SET
+typedef unsigned char slock_t;
+
+#define tzname _tzname                 /* should be in time.h? */
+#define HAVE_INT_TIMEZONE              /* has int _timezone */
+
+#include <cygwin/version.h>
+
+/*
+ * Check for b20.1 and disable AF_UNIX family socket support.
+ */
+#if CYGWIN_VERSION_DLL_MAJOR < 1001
+#undef HAVE_UNIX_SOCKETS
+#endif
+
+#if __GNUC__ && ! defined (__declspec)
+#error You need egcs 1.1 or newer for compiling!
+#endif
+
+#ifdef BUILDING_DLL
+#define DLLIMPORT __declspec (dllexport)
+#else
+#define DLLIMPORT __declspec (dllimport)
+#endif
index 08b0890..79fb939 100644 (file)
@@ -1,41 +1,15 @@
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-
-#define tzname _tzname                 /* should be in time.h? */
-#define HAVE_INT_TIMEZONE              /* has int _timezone */
+/* $Header: /cvsroot/pgsql/src/include/port/Attic/win.h,v 1.15 2003/03/21 17:18:34 petere Exp $ */
 
-#include <cygwin/version.h>
-
-/*
- * Check for b20.1 and disable AF_UNIX family socket support.
- */
-#if CYGWIN_VERSION_DLL_MAJOR < 1001
-#undef HAVE_UNIX_SOCKETS
-#endif
-
-/* defines for dynamic linking on Win32 platform */
-#ifdef __CYGWIN__
-
-#if __GNUC__ && ! defined (__declspec)
-#error You need egcs 1.1 or newer for compiling!
-#endif
+#define HAS_TEST_AND_SET
 
 #ifdef BUILDING_DLL
 #define DLLIMPORT __declspec (dllexport)
-#else                                                  /* not BUILDING_DLL */
+#else
 #define DLLIMPORT __declspec (dllimport)
 #endif
 
-#elif defined(WIN32) && defined(_MSC_VER)              /* not CYGWIN */
-
 #if defined(_DLL)
 #define DLLIMPORT __declspec (dllexport)
-#else                                                  /* not _DLL */
+#else
 #define DLLIMPORT __declspec (dllimport)
 #endif
-
-#else                                                  /* not CYGWIN, not MSVC */
-
-#define DLLIMPORT
-
-#endif
index 7576372..a4162d4 100644 (file)
@@ -1,4 +1,4 @@
-# $Header: /cvsroot/pgsql/src/interfaces/python/Attic/GNUmakefile,v 1.15 2002/12/11 04:07:39 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/python/Attic/GNUmakefile,v 1.16 2003/03/21 17:18:34 petere Exp $
 
 subdir = src/interfaces/python
 top_builddir = ../../..
@@ -9,7 +9,7 @@ SO_MAJOR_VERSION = 2
 SO_MINOR_VERSION = 4
 OBJS = pgmodule.o
 SHLIB_LINK = $(libpq)
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
 override CPPFLAGS += -DUSE_DL_IMPORT
 SHLIB_LINK += $(python_libspec)
 endif
diff --git a/src/makefiles/Makefile.cygwin b/src/makefiles/Makefile.cygwin
new file mode 100644 (file)
index 0000000..d5bcf9f
--- /dev/null
@@ -0,0 +1,37 @@
+# $Header: /cvsroot/pgsql/src/makefiles/Makefile.cygwin,v 1.1 2003/03/21 17:18:34 petere Exp $
+DLLTOOL= dlltool
+DLLWRAP= dllwrap
+BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
+DLLINIT = $(top_builddir)/src/utils/dllinit.o
+
+# linking with -lm or -lc causes program to crash
+# (see http://sources.redhat.com/cygwin/faq/faq.html#SEC110)
+LIBS:=$(filter-out -lm -lc, $(LIBS))
+
+AROPT = crs
+DLSUFFIX = .dll
+CFLAGS_SL =
+
+%.dll: %.o
+       $(DLLTOOL) --export-all --output-def $*.def $<
+       $(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(SHLIB_LINK)
+       rm -f $*.def
+
+ifneq (,$(findstring backend,$(subdir)))
+ifeq (,$(findstring conversion_procs,$(subdir)))
+override CPPFLAGS+= -DBUILDING_DLL
+endif
+endif
+
+ifneq (,$(findstring ecpg/lib,$(subdir)))
+override CPPFLAGS+= -DBUILDING_DLL
+endif
+
+# required by Python headers
+ifneq (,$(findstring src/pl/plpython,$(subdir)))
+override CPPFLAGS+= -DUSE_DL_IMPORT
+endif
+
+override javadir := '$(shell cygpath -w $(javadir))'
+
+sqlmansect = 7
index 9bbabde..d16afb1 100644 (file)
@@ -1,13 +1,9 @@
-# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.18 2002/09/05 18:28:46 petere Exp $
+# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.19 2003/03/21 17:18:34 petere Exp $
 DLLTOOL= dlltool
 DLLWRAP= dllwrap
 BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres
 DLLINIT = $(top_builddir)/src/utils/dllinit.o
 
-# linking with -lm or -lc causes program to crash
-# (see http://sources.redhat.com/cygwin/faq/faq.html#SEC110)
-LIBS:=$(filter-out -lm -lc, $(LIBS))
-
 AROPT = crs
 DLSUFFIX = .dll
 CFLAGS_SL =
@@ -31,7 +27,3 @@ endif
 ifneq (,$(findstring src/pl/plpython,$(subdir)))
 override CPPFLAGS+= -DUSE_DL_IMPORT
 endif
-
-override javadir := '$(shell cygpath -w $(javadir))'
-
-sqlmansect = 7
diff --git a/src/template/cygwin b/src/template/cygwin
new file mode 100644 (file)
index 0000000..e6c4ac6
--- /dev/null
@@ -0,0 +1,2 @@
+CFLAGS=-O2
+SRCH_LIB=/usr/local/lib
index e6c4ac6..c5366cf 100644 (file)
@@ -1,2 +1,3 @@
-CFLAGS=-O2
-SRCH_LIB=/usr/local/lib
+if test "$GCC" = yes; then
+  CFLAGS=-O2
+fi
index ebf14e5..5279204 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.41 2002/10/03 18:40:02 tgl Exp $
+#    $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.42 2003/03/21 17:18:34 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -142,7 +142,7 @@ clean distclean maintainer-clean:
 # things created by various check targets
        rm -rf results tmp_check log
        rm -f regression.diffs regression.out regress.out run_check.out
-ifeq ($(PORTNAME), win)
+ifeq ($(PORTNAME), cygwin)
        rm -f regress.def
 endif
 ifdef VPATH