summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2003-03-21 17:18:34 +0000
committerPeter Eisentraut2003-03-21 17:18:34 +0000
commit2e5e1631623bba55d9798091d83da8ac3419dd99 (patch)
tree7c5fb2d6c746f40bf62922029300923029d20f24
parenta6bea86c5cc3248b2ce3970b6a3d7f87581182f1 (diff)
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.
-rwxr-xr-xconfigure3
-rw-r--r--configure.in3
-rw-r--r--src/Makefile.shlib20
-rw-r--r--src/backend/Makefile14
-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/GNUmakefile2
-rw-r--r--src/makefiles/Makefile.cygwin37
-rw-r--r--src/makefiles/Makefile.win8
-rw-r--r--src/template/cygwin2
-rw-r--r--src/template/win5
-rw-r--r--src/test/regress/GNUmakefile2
16 files changed, 160 insertions, 101 deletions
diff --git a/configure b/configure
index 4c1b6b1782..2c673fc1a8 100755
--- 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 ;;
diff --git a/configure.in b/configure.in
index b21aa50160..377efb6c4e 100644
--- a/configure.in
+++ b/configure.in
@@ -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 ;;
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 766e82ac0b..4f41ce10da 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -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 8419bf5efa..264ff68120 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -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 [email protected] --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 0000000000..9a1436fa4a
--- /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 0000000000..0a7f2ccde1
--- /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$
+ *
+ *-------------------------------------------------------------------------
+ */
+#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 62469cbb71..562e69dcc8 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$ */
+
+#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 2969c8e823..e08113a79c 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 0000000000..86ae760b50
--- /dev/null
+++ b/src/include/port/cygwin.h
@@ -0,0 +1,26 @@
+/* $Header$ */
+
+#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 08b0890425..d60cfff1e7 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$ */
-#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 5067eb7ac6..bba8e02b76 100644
--- a/src/interfaces/python/GNUmakefile
+++ b/src/interfaces/python/GNUmakefile
@@ -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 0000000000..6966393bc5
--- /dev/null
+++ b/src/makefiles/Makefile.cygwin
@@ -0,0 +1,37 @@
+# $Header$
+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 6966393bc5..a214b6d002 100644
--- a/src/makefiles/Makefile.win
+++ b/src/makefiles/Makefile.win
@@ -4,10 +4,6 @@ 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 0000000000..e6c4ac67e1
--- /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 e6c4ac67e1..c5366cf493 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 436040d969..2459fee33e 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -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