aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2003-03-21 17:18:34 +0000
committerPeter Eisentraut <peter_e@gmx.net>2003-03-21 17:18:34 +0000
commit1a7f4ed5252dd08d9bbf26a67ddf22c38528c636 (patch)
tree4daa4d5d3dcc8d050bf8d8afbe2d4fc568455a3c /src
parent93331d8318325305cad9c5224eb4b86663214846 (diff)
downloadpostgresql-1a7f4ed5252dd08d9bbf26a67ddf22c38528c636.tar.gz
postgresql-1a7f4ed5252dd08d9bbf26a67ddf22c38528c636.zip
Make "win" a separate port from "cygwin". This means you can now
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.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.shlib22
-rw-r--r--src/backend/Makefile16
-rw-r--r--src/backend/port/dynloader/cygwin.c1
-rw-r--r--src/backend/port/dynloader/cygwin.h36
-rw-r--r--src/backend/port/dynloader/win.c31
-rw-r--r--src/backend/port/dynloader/win.h37
-rw-r--r--src/include/port/cygwin.h26
-rw-r--r--src/include/port/win.h34
-rw-r--r--src/interfaces/python/GNUmakefile4
-rw-r--r--src/makefiles/Makefile.cygwin37
-rw-r--r--src/makefiles/Makefile.win10
-rw-r--r--src/template/cygwin2
-rw-r--r--src/template/win5
-rw-r--r--src/test/regress/GNUmakefile4
14 files changed, 161 insertions, 104 deletions
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 5e1f0aa2584..2b07f2abaac 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -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
diff --git a/src/backend/Makefile b/src/backend/Makefile
index e6499106b78..82cdd0f568e 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -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
index 00000000000..9a1436fa4a3
--- /dev/null
+++ b/src/backend/port/dynloader/cygwin.c
@@ -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
index 00000000000..ef476ff1402
--- /dev/null
+++ b/src/backend/port/dynloader/cygwin.h
@@ -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 */
diff --git a/src/backend/port/dynloader/win.c b/src/backend/port/dynloader/win.c
index 62469cbb71c..005ac40e75a 100644
--- a/src/backend/port/dynloader/win.c
+++ b/src/backend/port/dynloader/win.c
@@ -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);
+}
diff --git a/src/backend/port/dynloader/win.h b/src/backend/port/dynloader/win.h
index 2969c8e8234..e08113a79cb 100644
--- a/src/backend/port/dynloader/win.h
+++ b/src/backend/port/dynloader/win.h
@@ -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
index 00000000000..cb6d6ecc080
--- /dev/null
+++ b/src/include/port/cygwin.h
@@ -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
diff --git a/src/include/port/win.h b/src/include/port/win.h
index 08b08904255..79fb93950a0 100644
--- a/src/include/port/win.h
+++ b/src/include/port/win.h
@@ -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
diff --git a/src/interfaces/python/GNUmakefile b/src/interfaces/python/GNUmakefile
index 7576372c602..a4162d472ab 100644
--- a/src/interfaces/python/GNUmakefile
+++ b/src/interfaces/python/GNUmakefile
@@ -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
index 00000000000..d5bcf9f7d89
--- /dev/null
+++ b/src/makefiles/Makefile.cygwin
@@ -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
diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win
index 9bbabdecc78..d16afb1757e 100644
--- a/src/makefiles/Makefile.win
+++ b/src/makefiles/Makefile.win
@@ -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
index 00000000000..e6c4ac67e18
--- /dev/null
+++ b/src/template/cygwin
@@ -0,0 +1,2 @@
+CFLAGS=-O2
+SRCH_LIB=/usr/local/lib
diff --git a/src/template/win b/src/template/win
index e6c4ac67e18..c5366cf4935 100644
--- a/src/template/win
+++ b/src/template/win
@@ -1,2 +1,3 @@
-CFLAGS=-O2
-SRCH_LIB=/usr/local/lib
+if test "$GCC" = yes; then
+ CFLAGS=-O2
+fi
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index ebf14e54bf9..5279204b3b6 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -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