From 337da0678ab3b0fe7e339cd35c6c50ad5441a534 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 5 Sep 2002 18:28:46 +0000 Subject: [PATCH] Assorted fixes for Cygwin: Eliminate the mysterious games that the Cygwin build plays with the linker flag variables. DLLLIBS is gone, use SHLIB_LINK like everyone else. Detect cygipc in configure, after the linker flags are set up, otherwise configure might not work at all. Make sure everything is covered by make clean. Fix the build of the new conversion procedure modules. Add new DLLIMPORT markers where required. Finally, the compiler complains if we use an explicit -I/usr/local/include, so don't do that. Curiously, -L/usr/local/lib is still necessary. --- configure.in | 4 ++- contrib/contrib-global.mk | 6 ++--- contrib/rserv/Makefile | 2 +- src/Makefile | 4 ++- src/Makefile.shlib | 6 ++--- src/backend/Makefile | 27 +++++++------------ src/backend/utils/mb/conversion_procs/proc.mk | 3 +-- src/include/miscadmin.h | 6 ++--- src/makefiles/Makefile.win | 27 ++++++++----------- src/pl/plpgsql/src/Makefile | 4 +-- src/pl/plpython/Makefile | 5 ++-- src/template/win | 2 -- src/test/regress/GNUmakefile | 4 +-- src/tutorial/Makefile | 4 +-- 14 files changed, 46 insertions(+), 58 deletions(-) diff --git a/configure.in b/configure.in index 3729459d546..fbaae6a5411 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.205 2002/09/04 22:54:18 petere Exp $ +dnl $Header: /cvsroot/pgsql/configure.in,v 1.206 2002/09/05 18:28:45 petere Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -614,6 +614,8 @@ AC_SEARCH_LIBS(crypt, crypt) AC_CHECK_LIB(bind, __inet_ntoa) # Solaris: AC_SEARCH_LIBS(fdatasync, [rt posix4]) +# Cygwin: +AC_CHECK_LIB(cygipc, shmget) if test "$with_readline" = yes; then PGAC_CHECK_READLINE diff --git a/contrib/contrib-global.mk b/contrib/contrib-global.mk index 415cc273e77..61025aad428 100644 --- a/contrib/contrib-global.mk +++ b/contrib/contrib-global.mk @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/contrib/contrib-global.mk,v 1.2 2001/09/16 16:11:08 petere Exp $ +# $Header: /cvsroot/pgsql/contrib/contrib-global.mk,v 1.3 2002/09/05 18:28:45 petere Exp $ # This file contains generic rules to build many kinds of simple # contrib modules. You only need to set a few variables and include @@ -45,7 +45,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) ifdef MODULES override CFLAGS += $(CFLAGS_SL) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK += $(BE_DLLLIBS) endif ifdef PG_CPPFLAGS @@ -61,7 +61,7 @@ SO_MAJOR_VERSION= 0 SO_MINOR_VERSION= 0 rpath = -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK += $(BE_DLLLIBS) include $(top_srcdir)/src/Makefile.shlib diff --git a/contrib/rserv/Makefile b/contrib/rserv/Makefile index 27251197466..984a839415d 100644 --- a/contrib/rserv/Makefile +++ b/contrib/rserv/Makefile @@ -16,7 +16,7 @@ SCRIPTS = InitRservTest override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) override CFLAGS += $(CFLAGS_SL) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK = $(BE_DLLLIBS) all: $(SQLS) $(TCLS) $(PERLS) $(SCRIPTS) $(SONAME) diff --git a/src/Makefile b/src/Makefile index e0fef6aed7c..cd6e5e630dd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/Makefile,v 1.28 2002/09/04 15:45:50 tgl Exp $ +# $Header: /cvsroot/pgsql/src/Makefile,v 1.29 2002/09/05 18:28:45 petere Exp $ # #------------------------------------------------------------------------- @@ -34,6 +34,7 @@ clean: $(MAKE) -C pl $@ $(MAKE) -C test $@ $(MAKE) -C tutorial $@ + $(MAKE) -C utils $@ distclean maintainer-clean: -$(MAKE) -C port $@ @@ -44,4 +45,5 @@ distclean maintainer-clean: -$(MAKE) -C pl $@ -$(MAKE) -C test $@ -$(MAKE) -C tutorial $@ + -$(MAKE) -C utils $@ rm -f Makefile.port Makefile.global diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 7140b451d2c..bf746a46338 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.63 2002/09/04 22:54:18 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.64 2002/09/05 18:28:46 petere Exp $ # #------------------------------------------------------------------------- @@ -276,7 +276,7 @@ else # PORTNAME == win # WIN 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) $(DLLLIBS) $(SHLIB_LINK) + $(DLLWRAP) -o $(shlib) --dllname $(shlib) --def $(NAME).def $(OBJS) $(DLLINIT) $(SHLIB_LINK) $(DLLTOOL) --dllname $(shlib) --def $(NAME).def --output-lib lib$(NAME).a $(DLLINIT): $(DLLINIT:%.o=%.c) @@ -353,5 +353,5 @@ ifdef EXPSUFF endif endif ifeq ($(PORTNAME), win) - rm -rf $(NAME).def + rm -f $(NAME).dll $(NAME).def endif diff --git a/src/backend/Makefile b/src/backend/Makefile index 38198eb1a0b..df445615ae0 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.86 2002/09/04 15:45:50 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.87 2002/09/05 18:28:46 petere Exp $ # #------------------------------------------------------------------------- @@ -40,10 +40,16 @@ else # win postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def - $(CC) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS) $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def - $(CC) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(DLLLIBS) - rm $@.exp $@.base + $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS) + rm -f $@.exp $@.base + +postgres.def: $(OBJS) + $(DLLTOOL) --export-all --output-def $@ $^ + +libpostgres.a: postgres.def + $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ endif # win @@ -57,17 +63,6 @@ $(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir $(MAKE) -C $(subst -recursive,,$@) all -ifeq ($(MAKE_DLL), true) - -postgres.def: $(OBJS) - $(DLLTOOL) --export-all --output-def $@ $(OBJS) - -libpostgres.a: $(OBJS) $(DLLINIT) postgres.def - $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ - -endif # MAKE_DLL - - $(DLLINIT): $(DLLINIT:%.o=%.c) $(MAKE) -C $(@D) $(@F) @@ -169,9 +164,7 @@ clean: $(top_srcdir)/src/include/parser/parse.h \ $(top_builddir)/src/include/utils/fmgroids.h ifeq ($(PORTNAME), win) -ifeq ($(MAKE_DLL), true) rm -f postgres.dll postgres.def libpostgres.a -endif endif for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk index 8c9279e9aaf..76fb55688af 100644 --- a/src/backend/utils/mb/conversion_procs/proc.mk +++ b/src/backend/utils/mb/conversion_procs/proc.mk @@ -1,7 +1,6 @@ SRCS += $(NAME).c OBJS += $(NAME).o -PG_CPPFLAGS := SHLIB_LINK := $(BE_DLLLIBS) SO_MAJOR_VERSION := 0 @@ -18,4 +17,4 @@ install: all uninstall: uninstall-lib clean distclean maintainer-clean: clean-lib - $(RM) $(OBJS) + rm -f $(OBJS) diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index dbce60d81de..0402a690c5f 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.109 2002/09/04 20:31:36 momjian Exp $ + * $Id: miscadmin.h,v 1.110 2002/09/05 18:28:46 petere Exp $ * * NOTES * some of the information in this file should be moved to @@ -62,7 +62,7 @@ /* in globals.c */ /* these are marked volatile because they are set by signal handlers: */ -extern volatile bool InterruptPending; +extern DLLIMPORT volatile bool InterruptPending; extern volatile bool QueryCancelPending; extern volatile bool ProcDiePending; @@ -166,7 +166,7 @@ extern char DateFormat[]; extern bool enableFsync; extern bool allowSystemTableMods; -extern int SortMem; +extern DLLIMPORT int SortMem; extern int VacuumMem; /* diff --git a/src/makefiles/Makefile.win b/src/makefiles/Makefile.win index bcf1165f014..9bbabdecc78 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.17 2002/07/27 20:10:05 petere Exp $ -LDFLAGS+= -g +# $Header: /cvsroot/pgsql/src/makefiles/Attic/Makefile.win,v 1.18 2002/09/05 18:28:46 petere Exp $ DLLTOOL= dlltool DLLWRAP= dllwrap -DLLLIBS= -lcygipc -lcrypt BE_DLLLIBS= -L$(top_builddir)/src/backend -lpostgres DLLINIT = $(top_builddir)/src/utils/dllinit.o -MK_NO_LORDER=true -MAKE_DLL=true -#MAKE_DLL=false + # 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)) @@ -18,22 +14,21 @@ CFLAGS_SL = %.dll: %.o $(DLLTOOL) --export-all --output-def $*.def $< - $(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(DLLLIBS) + $(DLLWRAP) -o $@ --def $*.def $< $(DLLINIT) $(SHLIB_LINK) rm -f $*.def -ifeq ($(findstring backend,$(subdir)), backend) -override CPPFLAGS+= -DBUILDING_DLL=1 +ifneq (,$(findstring backend,$(subdir))) +ifeq (,$(findstring conversion_procs,$(subdir))) +override CPPFLAGS+= -DBUILDING_DLL +endif endif -ifeq ($(findstring ecpg/lib,$(subdir)), ecpg/lib) -override CPPFLAGS+= -DBUILDING_DLL=1 +ifneq (,$(findstring ecpg/lib,$(subdir))) +override CPPFLAGS+= -DBUILDING_DLL endif -ifeq ($(findstring interfaces/libpq++,$(subdir)), interfaces/libpq++) -override CPPFLAGS+= -DBUILDING_DLL=1 -endif - -ifeq ($(findstring src/pl/plpython,$(subdir)), src/pl/plpython) +# required by Python headers +ifneq (,$(findstring src/pl/plpython,$(subdir))) override CPPFLAGS+= -DUSE_DL_IMPORT endif diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile index cb5b6c21fa5..2ab565a806d 100644 --- a/src/pl/plpgsql/src/Makefile +++ b/src/pl/plpgsql/src/Makefile @@ -2,7 +2,7 @@ # # Makefile for the plpgsql shared object # -# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.21 2002/08/30 00:28:41 tgl Exp $ +# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.22 2002/09/05 18:28:46 petere Exp $ # #------------------------------------------------------------------------- @@ -20,7 +20,7 @@ SO_MAJOR_VERSION= 1 SO_MINOR_VERSION= 0 override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK = $(BE_DLLLIBS) rpath := OBJS = pl_gram.o pl_scan.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile index dd92986304e..f2830866d34 100644 --- a/src/pl/plpython/Makefile +++ b/src/pl/plpython/Makefile @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.10 2001/09/16 16:11:11 petere Exp $ +# $Header: /cvsroot/pgsql/src/pl/plpython/Makefile,v 1.11 2002/09/05 18:28:46 petere Exp $ subdir = src/pl/plpython top_builddir = ../../.. @@ -17,7 +17,6 @@ endif ifneq (,$(findstring yes, $(shared_libpython)$(allow_nonpic_in_shlib))) override CPPFLAGS := -I$(srcdir) $(python_includespec) $(CPPFLAGS) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) rpath := NAME = plpython @@ -25,7 +24,7 @@ SO_MAJOR_VERSION = 0 SO_MINOR_VERSION = 0 OBJS = plpython.o -SHLIB_LINK += $(python_libspec) +SHLIB_LINK = $(BE_DLLLIBS) $(python_libspec) include $(top_srcdir)/src/Makefile.shlib diff --git a/src/template/win b/src/template/win index fb2f10ea92f..e6c4ac67e18 100644 --- a/src/template/win +++ b/src/template/win @@ -1,4 +1,2 @@ CFLAGS=-O2 -SRCH_INC=/usr/local/include SRCH_LIB=/usr/local/lib -LIBS=-lcygipc diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 009fb35efa4..dc42e20ae83 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.39 2002/09/03 21:45:44 petere Exp $ +# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.40 2002/09/05 18:28:46 petere Exp $ # #------------------------------------------------------------------------- @@ -20,7 +20,7 @@ contribdir := $(top_builddir)/contrib override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS) override CFLAGS += $(CFLAGS_SL) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK = $(BE_DLLLIBS) # default encoding MULTIBYTE = SQL_ASCII diff --git a/src/tutorial/Makefile b/src/tutorial/Makefile index 2e85fbc38a3..0aa3cf6a497 100644 --- a/src/tutorial/Makefile +++ b/src/tutorial/Makefile @@ -4,7 +4,7 @@ # Makefile for tutorial # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.15 2002/07/30 17:47:58 tgl Exp $ +# $Header: /cvsroot/pgsql/src/tutorial/Makefile,v 1.16 2002/09/05 18:28:46 petere Exp $ # #------------------------------------------------------------------------- @@ -13,7 +13,7 @@ top_builddir = ../.. include $(top_builddir)/src/Makefile.global override CFLAGS+= $(CFLAGS_SL) -override DLLLIBS := $(BE_DLLLIBS) $(DLLLIBS) +SHLIB_LINK = $(BE_DLLLIBS) # # DLOBJS are the dynamically-loaded object files. The "funcs" queries