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 a79e0107e3..99a8d9d971 100644 --- a/configure.in +++ b/configure.in @@ -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 ;; diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 5e1f0aa258..2b07f2abaa 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 e6499106b7..82cdd0f568 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 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..ef476ff140 --- /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 +#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..005ac40e75 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 + +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 #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..cb6d6ecc08 --- /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 + +/* + * 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..79fb93950a 100644 --- a/src/include/port/win.h +++ b/src/include/port/win.h @@ -1,41 +1,15 @@ +/* $Header: /cvsroot/pgsql/src/include/port/Attic/win.h,v 1.15 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 - -/* - * 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 #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 7576372c60..a4162d472a 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 0000000000..d5bcf9f7d8 --- /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 9bbabdecc7..d16afb1757 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 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 ebf14e54bf..5279204b3b 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