Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f43ec05

Browse files
committed
I've made a diff against the 7.0beta1 tree that accomplishes several things:
1) adds NetBSD shared lib support on both ELF and a.out platforms 2) replaces "-L$(LIBPQDIR) -lpq" with "$(LIBPQ)" defined in Makefile.global. This makes it much easier to build stuff in the source tree after you've already installed the libraries. 3) adds TEMPLATEDIR in Makefile.global that indicates where the database templates are stored. This separates the template files from real libraries that are installed in $(LIBDIR). 4) changes include order of <readline/readline.h> and <readline.h>. The latest GNU readline installs its headers under a readline subdirectory. In addition to applying the patch below the following files need to be copied: backend/port/dynloader: bsd.h -> netbsd.h bsd.c -> netbsd.c include/port: bsd.h -> netbsd.h makefiles: Makefile.bsd -> Makefile.netbsd It would be great to see this incorporated into the source tree before the 7.0 release is cut. Thanks! -- Johnny C. Lam <lamj@stat.cmu.edu>
1 parent 26c953e commit f43ec05

File tree

21 files changed

+297
-62
lines changed

21 files changed

+297
-62
lines changed

src/Makefile.global.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.66 2000/02/10 19:11:17 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.67 2000/03/08 01:58:15 momjian Exp $
1111
#
1212
# NOTES
1313
# Essentially all Postgres make files include this file and use the
@@ -54,6 +54,10 @@ BSD_SHLIB= true
5454
ELF_SYSTEM= @ELF_SYS@
5555

5656
LIBPQDIR:= $(SRCDIR)/interfaces/libpq
57+
LIBPGTCLDIR:= $(SRCDIR)/interfaces/libpgtcl
58+
59+
LIBPQ:= -L$(LIBPQDIR) -lpq
60+
LIBPGTCL:= -L$(LIBPGTCLDIR) -lpgtcl
5761

5862
# For convenience, POSTGRESDIR is where BINDIR, and LIBDIR
5963
# and other target destinations are rooted. Of course, each of these is
@@ -70,6 +74,10 @@ BINDIR= $(POSTGRESDIR)/bin
7074
# command line.
7175
LIBDIR= $(POSTGRESDIR)/lib
7276

77+
# Where the database templates are stored
78+
#
79+
TEMPLATEDIR= $(POSTGRESDIR)/lib
80+
7381
# This is the directory where IPC utilities ipcs and ipcrm are located
7482
#
7583
IPCS=@ipcs@

src/Makefile.shlib

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1998, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.17 1999/12/09 19:14:22 momjian Exp $
9+
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.18 2000/03/08 01:58:15 momjian Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -109,6 +109,24 @@ ifeq ($(PORTNAME), freebsd)
109109
endif
110110
endif
111111

112+
ifeq ($(PORTNAME), netbsd)
113+
ifdef BSD_SHLIB
114+
install-shlib-dep := install-shlib
115+
soname := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
116+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
117+
ifdef ELF_SYSTEM
118+
LD := $(CC)
119+
LDFLAGS_SL := -shared -Wl,-soname -Wl,$(soname)
120+
ifneq ($(SHLIB_LINK),)
121+
LDFLAGS_SL += -Wl,-R$(LIBDIR)
122+
endif
123+
else
124+
LDFLAGS_SL := -x -Bshareable -Bforcearchive
125+
endif
126+
CFLAGS += $(CFLAGS_SL)
127+
endif
128+
endif
129+
112130
ifeq ($(PORTNAME), hpux)
113131
install-shlib-dep := install-shlib
114132
# HPUX doesn't believe in version numbers for shlibs

src/backend/Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#
3535
#
3636
# IDENTIFICATION
37-
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.43 2000/02/27 01:26:12 tgl Exp $
37+
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.44 2000/03/08 01:58:16 momjian Exp $
3838
#
3939
#-------------------------------------------------------------------------
4040

@@ -165,10 +165,11 @@ endif
165165
# and (2) the parameters of a database system should be set at initdb time,
166166
# not at postgres build time.
167167

168-
.PHONY: install install-bin install-lib install-headers
168+
.PHONY: install install-bin install-templates install-headers
169169

170-
install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) \
171-
install-bin install-lib install-headers
170+
install: $(LIBDIR) $(BINDIR) $(HEADERDIR) $(TEMPLATEDIR) \
171+
postgres $(POSTGRES_IMP) \
172+
install-bin install-templates install-headers
172173

173174
install-bin: $(BINDIR) postgres$(X) $(POSTGRES_IMP)
174175
$(INSTALL) $(INSTL_EXE_OPTS) postgres$(X) $(BINDIR)/postgres$(X)
@@ -184,22 +185,22 @@ ifeq ($(MAKE_DLL), true)
184185
endif
185186
endif
186187

187-
install-lib: $(LIBDIR) \
188+
install-templates: $(TEMPLATEDIR) \
188189
global1.bki.source local1_template1.bki.source \
189190
global1.description local1_template1.description \
190191
libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
191192
$(INSTALL) $(INSTLOPTS) global1.bki.source \
192-
$(LIBDIR)/global1.bki.source
193+
$(TEMPLATEDIR)/global1.bki.source
193194
$(INSTALL) $(INSTLOPTS) global1.description \
194-
$(LIBDIR)/global1.description
195+
$(TEMPLATEDIR)/global1.description
195196
$(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
196-
$(LIBDIR)/local1_template1.bki.source
197+
$(TEMPLATEDIR)/local1_template1.bki.source
197198
$(INSTALL) $(INSTLOPTS) local1_template1.description \
198-
$(LIBDIR)/local1_template1.description
199+
$(TEMPLATEDIR)/local1_template1.description
199200
$(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
200-
$(LIBDIR)/pg_hba.conf.sample
201+
$(TEMPLATEDIR)/pg_hba.conf.sample
201202
$(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
202-
$(LIBDIR)/pg_geqo.sample
203+
$(TEMPLATEDIR)/pg_geqo.sample
203204

204205
install-headers: fmgr.h $(SRCDIR)/include/config.h
205206
-@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
@@ -263,6 +264,8 @@ $(LIBDIR):
263264
mkdir $@
264265
$(HEADERDIR):
265266
mkdir $@
267+
$(TEMPLATEDIR):
268+
mkdir $@
266269

267270
#############################################################################
268271
#

src/backend/port/dynloader/netbsd.c

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*-
2+
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
3+
* Portions Copyright (c) 1990 The Regents of the University of California.
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions
8+
* are met:
9+
* 1. Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
* 2. Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the distribution.
14+
* 3. All advertising materials mentioning features or use of this software
15+
* must display the following acknowledgement:
16+
* This product includes software developed by the University of
17+
* California, Berkeley and its contributors.
18+
* 4. Neither the name of the University nor the names of its contributors
19+
* may be used to endorse or promote products derived from this software
20+
* without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32+
* SUCH DAMAGE.
33+
*/
34+
35+
#if defined(LIBC_SCCS) && !defined(lint)
36+
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
37+
38+
#endif /* LIBC_SCCS and not lint */
39+
40+
#include <sys/types.h>
41+
#include <nlist.h>
42+
#include "link.h"
43+
#include <dlfcn.h>
44+
45+
#include <stdio.h>
46+
#include <stdlib.h>
47+
48+
#include "dynloader.h"
49+
50+
static char error_message[BUFSIZ];
51+
52+
char *
53+
BSD44_derived_dlerror(void)
54+
{
55+
static char ret[BUFSIZ];
56+
57+
strcpy(ret, error_message);
58+
error_message[0] = 0;
59+
return (ret[0] == 0) ? (char *) NULL : ret;
60+
}
61+
62+
void *
63+
BSD44_derived_dlopen(const char *file, int num)
64+
{
65+
#if defined(__mips__) || (defined(__NetBSD__) && defined(__vax__))
66+
sprintf(error_message, "dlopen (%s) not supported", file);
67+
return NULL;
68+
#else
69+
void *vp;
70+
71+
if ((vp = dlopen((char *) file, num)) == (void *) NULL)
72+
sprintf(error_message, "dlopen (%s) failed", file);
73+
return vp;
74+
#endif
75+
}
76+
77+
void *
78+
BSD44_derived_dlsym(void *handle, const char *name)
79+
{
80+
#if defined(__mips__) || (defined(__NetBSD__) && defined(__vax__))
81+
sprintf(error_message, "dlsym (%s) failed", name);
82+
return NULL;
83+
#elif defined(__ELF__)
84+
return dlsym(handle, name);
85+
#else
86+
void *vp;
87+
char buf[BUFSIZ];
88+
89+
if (*name != '_')
90+
{
91+
sprintf(buf, "_%s", name);
92+
name = buf;
93+
}
94+
if ((vp = dlsym(handle, (char *) name)) == (void *) NULL)
95+
sprintf(error_message, "dlsym (%s) failed", name);
96+
return vp;
97+
#endif
98+
}
99+
100+
void
101+
BSD44_derived_dlclose(void *handle)
102+
{
103+
#if defined(__mips__) || (defined(__NetBSD__) && defined(__vax__))
104+
#else
105+
dlclose(handle);
106+
#endif
107+
}

src/backend/port/dynloader/netbsd.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* port_protos.h
4+
* port-specific prototypes for NetBSD 1.0
5+
*
6+
*
7+
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8+
* Portions Copyright (c) 1994, Regents of the University of California
9+
*
10+
* $Id: netbsd.h,v 1.1 2000/03/08 01:58:17 momjian Exp $
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
#ifndef PORT_PROTOS_H
15+
#define PORT_PROTOS_H
16+
17+
#include <sys/types.h>
18+
#include <nlist.h>
19+
#include "link.h"
20+
21+
#include "postgres.h"
22+
23+
#include "fmgr.h"
24+
#include "utils/dynamic_loader.h"
25+
26+
/* dynloader.c */
27+
/*
28+
* Dynamic Loader on NetBSD 1.0.
29+
*
30+
* this dynamic loader uses the system dynamic loading interface for shared
31+
* libraries (ie. dlopen/dlsym/dlclose). The user must specify a shared
32+
* library as the file to be dynamically loaded.
33+
*
34+
* agc - I know this is all a bit crufty, but it does work, is fairly
35+
* portable, and works (the stipulation that the d.l. function must
36+
* begin with an underscore is fairly tricky, and some versions of
37+
* NetBSD (like 1.0, and 1.0A pre June 1995) have no dlerror.)
38+
*/
39+
#define pg_dlopen(f) BSD44_derived_dlopen(f, 1)
40+
#define pg_dlsym BSD44_derived_dlsym
41+
#define pg_dlclose BSD44_derived_dlclose
42+
#define pg_dlerror BSD44_derived_dlerror
43+
44+
char *BSD44_derived_dlerror(void);
45+
void *BSD44_derived_dlopen(const char *filename, int num);
46+
void *BSD44_derived_dlsym(void *handle, const char *name);
47+
void BSD44_derived_dlclose(void *handle);
48+
49+
#endif /* PORT_PROTOS_H */

src/bin/pg_ctl/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.3 1999/12/22 04:12:55 ishii Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_ctl/Makefile,v 1.4 2000/03/08 01:58:18 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -21,7 +21,7 @@ pg_ctl: pg_ctl.sh
2121

2222
install: pg_ctl
2323
$(INSTALL) $(INSTL_EXE_OPTS) $+ $(BINDIR)
24-
$(INSTALL) $(INSTLOPTS) postmaster.opts.default.sample $(LIBDIR)
24+
$(INSTALL) $(INSTLOPTS) postmaster.opts.default.sample $(TEMPLATEDIR)
2525

2626
clean:
2727
rm -f pg_ctl

src/bin/pg_dump/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.11 1999/01/17 06:19:05 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/Makefile.in,v 1.12 2000/03/08 01:58:19 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -29,7 +29,7 @@ endif
2929
all: submake pg_dump
3030

3131
pg_dump: $(OBJS) $(LIBPQDIR)/libpq.a
32-
$(CC) -o pg_dump -L$(LIBPQDIR) $(OBJS) -lpq $(LDFLAGS)
32+
$(CC) -o pg_dump $(OBJS) $(LIBPQ) $(LDFLAGS)
3333

3434
../../utils/strdup.o:
3535
$(MAKE) -C ../../utils strdup.o

src/bin/pg_encoding/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.4 2000/01/15 18:30:32 petere Exp $
9+
# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.5 2000/03/08 01:58:20 momjian Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -22,7 +22,7 @@ CFLAGS:= -I$(SRCDIR)/include $(CFLAGS)
2222
all: submake pg_encoding
2323

2424
pg_encoding: $(OBJS)
25-
$(CC) -o pg_encoding $(OBJS) -L$(LIBPQDIR) -lpq $(LDFLAGS) $(CFLAGS)
25+
$(CC) -o pg_encoding $(OBJS) $(LIBPQ) $(LDFLAGS) $(CFLAGS)
2626

2727
.PHONY: submake
2828

src/bin/pgtclsh/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/pgtclsh/Attic/Makefile,v 1.24 1998/10/27 21:51:54 tgl Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pgtclsh/Attic/Makefile,v 1.25 2000/03/08 01:58:21 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -22,16 +22,13 @@ ifeq ($(USE_TK), true)
2222
include Makefile.tkdefs
2323
endif
2424

25-
CFLAGS+= $(X_CFLAGS) -I$(SRCDIR)/interfaces/libpgtcl
25+
CFLAGS+= $(X_CFLAGS) -I$(LIBPGTCLDIR)
2626

2727
ifdef KRBVERS
2828
LDFLAGS+= $(KRBLIBS)
2929
CFLAGS+= $(KRBFLAGS)
3030
endif
3131

32-
LIBPGTCL= -L$(SRCDIR)/interfaces/libpgtcl -lpgtcl
33-
LIBPQ= -L$(LIBPQDIR) -lpq
34-
3532
# If we are here then TCL is available
3633
PGMS = pgtclsh
3734
INSTPGMS = install_tcl

src/bin/psql/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.20 2000/01/19 02:59:00 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.21 2000/03/08 01:58:22 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -56,7 +56,7 @@ endif
5656
# End of hacks for picking up backend 'port' modules
5757

5858
psql: $(OBJS) $(LIBPQDIR)/libpq.a
59-
$(CC) -o psql -L$(LIBPQDIR) $(OBJS) -lpq $(LDFLAGS)
59+
$(CC) -o psql $(OBJS) $(LIBPQ) $(LDFLAGS)
6060

6161
help.o: sql_help.h
6262

0 commit comments

Comments
 (0)