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

Commit 6d98d37

Browse files
committed
Centralized shared-library build knowledge in a new file,
src/Makefile.shlib. Updated all the makefiles that try to build shlibs to include that file instead of having duplicate (and mostly incomplete) copies of shared-library options. It works on HPUX, a lot better than it did before in fact, but there's a chance I broke some other platforms. At least now you only have to fix one place not six...
1 parent 6e13e0c commit 6d98d37

File tree

9 files changed

+300
-625
lines changed

9 files changed

+300
-625
lines changed

src/Makefile.global.in

+8-1
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.51 1998/10/15 15:58:12 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.52 1998/10/19 00:00:40 tgl Exp $
1111
#
1212
# NOTES
1313
# Essentially all Postgres make files include this file and use the
@@ -206,6 +206,13 @@ LDFLAGS= @LDFLAGS@ @LIBS@
206206
DLSUFFIX= @DLSUFFIX@
207207
LN_S= @LN_S@
208208

209+
##############################################################################
210+
#
211+
# Additional platform-specific settings
212+
#
213+
214+
PORTNAME= @PORTNAME@
215+
209216
include $(SRCDIR)/Makefile.port
210217

211218
##############################################################################

src/Makefile.shlib

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile.shlib
4+
# Common rules for building shared libraries
5+
#
6+
# Copyright (c) 1998, Regents of the University of California
7+
#
8+
# IDENTIFICATION
9+
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.1 1998/10/19 00:00:40 tgl Exp $
10+
#
11+
#-------------------------------------------------------------------------
12+
13+
# This file should be included by any Postgres module Makefile that wants
14+
# to build a shared library (if possible for the current platform).
15+
# A static library is also built from the same object files.
16+
# RESTRICTION: only one library can be built per makefile...
17+
18+
# Before including this file, the module Makefile must define these variables:
19+
# NAME Name of library to build (no suffix nor "lib" prefix)
20+
# SO_MAJOR_VERSION Major version number to use for shared library
21+
# SO_MINOR_VERSION Minor version number to use for shared library
22+
# OBJS List of object files to include in library
23+
# SHLIB_LINK If shared library relies on other libraries, additional
24+
# stuff to put in its link command
25+
# (If you want a patchlevel, include it in SO_MINOR_VERSION, eg, "6.2".)
26+
#
27+
# The module Makefile must also include $(SRCDIR)/Makefile.global before
28+
# including this file (Makefile.global sets PORTNAME and other needed symbols).
29+
#
30+
# The first rule in this file is a rule for "all", which causes both the
31+
# static and shared libraries to be built (as well as all the object files).
32+
# If you have other files that need to be made before building object files
33+
# and libraries, put another rule for "all" before you include this file.
34+
#
35+
# Your install rule should look like
36+
#
37+
# install: install-headers install-lib $(install-shlib-dep)
38+
#
39+
# where install-headers is only needed if you have header files to install
40+
# (and, of course, it has to be provided by your makefile). The rules
41+
# install-lib and install-shlib are provided by this makefile --- they
42+
# automatically install the plain and shared libraries into $(LIBDIR).
43+
# install-shlib-dep is a variable that expands to install-shlib if the
44+
# shared library needs to be installed, empty if not.
45+
#
46+
# Got that? Look at src/interfaces/libpq/Makefile.in for an example.
47+
48+
49+
# shlib and install-shlib-dep default to empty, and stay that way if we're
50+
# on a platform where we don't know how to build a shared library.
51+
shlib :=
52+
install-shlib-dep :=
53+
54+
# For each platform we support shlibs on, set shlib and install-shlib-dep,
55+
# and update flags as needed to build a shared lib. Note we depend on
56+
# Makefile.global (or really Makefile.port) to supply DLSUFFIX and other
57+
# symbols.
58+
59+
ifeq ($(PORTNAME), bsd)
60+
ifdef BSD_SHLIB
61+
install-shlib-dep := install-shlib
62+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
63+
LDFLAGS_SL := -x -Bshareable -Bforcearchive
64+
CFLAGS += $(CFLAGS_SL)
65+
endif
66+
endif
67+
68+
ifeq ($(PORTNAME), bsdi)
69+
ifdef BSD_SHLIB
70+
ifeq ($(DLSUFFIX), .so)
71+
install-shlib-dep := install-shlib
72+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
73+
LDFLAGS_SL += -shared
74+
CFLAGS += $(CFLAGS_SL)
75+
endif
76+
ifeq ($(DLSUFFIX), .o)
77+
install-shlib-dep := install-shlib
78+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
79+
LD := shlicc
80+
LDFLAGS_SL += -O -r
81+
CFLAGS += $(CFLAGS_SL)
82+
endif
83+
endif
84+
endif
85+
86+
ifeq ($(PORTNAME), hpux)
87+
install-shlib-dep := install-shlib
88+
# HPUX doesn't believe in version numbers for shlibs
89+
shlib := lib$(NAME)$(DLSUFFIX)
90+
LDFLAGS_SL := -b
91+
CFLAGS += $(CFLAGS_SL)
92+
endif
93+
94+
ifeq ($(PORTNAME), linux)
95+
install-shlib-dep := install-shlib
96+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
97+
LDFLAGS_SL := -shared -soname $(shlib)
98+
CFLAGS += $(CFLAGS_SL)
99+
endif
100+
101+
ifeq ($(PORTNAME), solaris_i386)
102+
install-shlib-dep := install-shlib
103+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
104+
LDFLAGS_SL := -G
105+
CFLAGS += $(CFLAGS_SL)
106+
endif
107+
108+
ifeq ($(PORTNAME), solaris_sparc)
109+
install-shlib-dep := install-shlib
110+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
111+
LDFLAGS_SL := -G
112+
CFLAGS += $(CFLAGS_SL)
113+
endif
114+
115+
ifeq ($(PORTNAME), svr4)
116+
install-shlib-dep := install-shlib
117+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
118+
LDFLAGS_SL := -G
119+
CFLAGS += $(CFLAGS_SL)
120+
endif
121+
122+
ifeq ($(PORTNAME), univel)
123+
install-shlib-dep := install-shlib
124+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
125+
LDFLAGS_SL := -G -z text
126+
CFLAGS += $(CFLAGS_SL)
127+
ifeq ($(CXX), CC)
128+
CXXFLAGS += -Xw
129+
COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
130+
endif
131+
endif
132+
133+
ifeq ($(PORTNAME), unixware)
134+
install-shlib-dep := install-shlib
135+
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
136+
LDFLAGS_SL := -G -z text
137+
CFLAGS += $(CFLAGS_SL)
138+
ifeq ($(CXX), CC)
139+
CXXFLAGS += -Xw
140+
COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
141+
endif
142+
endif
143+
144+
145+
# Default target definition. Note shlib is empty if not building a shlib.
146+
147+
all: lib$(NAME).a $(shlib)
148+
149+
# Rules to build regular and shared libraries
150+
151+
lib$(NAME).a: $(OBJS)
152+
ifdef MK_NO_LORDER
153+
$(AR) $(AROPT) $@ $(OBJS)
154+
else
155+
$(AR) $(AROPT) $@ `lorder $(OBJS) | tsort`
156+
endif
157+
$(RANLIB) $@
158+
159+
$(shlib): $(OBJS)
160+
$(LD) $(LDFLAGS_SL) -o $@ $(OBJS) $(SHLIB_LINK)
161+
162+
# Rules to install regular and shared libraries
163+
164+
.PHONY: all install-lib install-shlib
165+
166+
install-lib: lib$(NAME).a
167+
$(INSTALL) $(INSTL_LIB_OPTS) lib$(NAME).a $(LIBDIR)/lib$(NAME).a
168+
169+
install-shlib: $(shlib)
170+
$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
171+
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
172+
cd $(LIBDIR); \
173+
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
174+
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
175+
fi
176+
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
177+
cd $(LIBDIR); \
178+
rm -f lib$(NAME)$(DLSUFFIX); \
179+
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
180+
fi

src/interfaces/ecpg/lib/Makefile.in

+30-102
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,52 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile
4+
# Makefile for ecpg library
5+
#
6+
# Copyright (c) 1994, Regents of the University of California
7+
#
8+
# IDENTIFICATION
9+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.38 1998/10/19 00:00:40 tgl Exp $
10+
#
11+
#-------------------------------------------------------------------------
12+
113
NAME= ecpg
214
SO_MAJOR_VERSION= 2
3-
SO_MINOR_VERSION= 6
4-
SO_PATCHLEVEL= 2
15+
SO_MINOR_VERSION= 6.2
516

617
SRCDIR= @top_srcdir@
7-
818
include $(SRCDIR)/Makefile.global
919

10-
PQ_INCLUDE=-I$(SRCDIR)/interfaces/libpq
11-
12-
PORTNAME=@PORTNAME@
20+
CFLAGS+= -I../include -I$(SRCDIR)/interfaces/libpq
1321

1422
ifdef KRBVERS
1523
CFLAGS+= $(KRBFLAGS)
1624
endif
1725

18-
# Shared library stuff
19-
shlib :=
20-
install-shlib-dep :=
26+
OBJS= ecpglib.o typename.o
2127

22-
ifeq ($(PORTNAME), linux)
23-
LINUX_ELF=@LINUX_ELF@
24-
ifdef LINUX_ELF
25-
install-shlib-dep := install-shlib
26-
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
27-
LDFLAGS_SL = -shared -soname lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
28-
endif
29-
endif
28+
SHLIB_LINK= -L../../libpq -lpq
3029

31-
ifeq ($(PORTNAME), bsd)
32-
ifdef BSD_SHLIB
33-
install-shlib-dep := install-shlib
34-
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
35-
LDFLAGS_SL = -x -Bshareable -Bforcearchive
36-
CFLAGS += $(CFLAGS_SL)
37-
endif
38-
endif
30+
# Shared library stuff, also default 'all' target
31+
include $(SRCDIR)/Makefile.shlib
3932

40-
ifeq ($(PORTNAME), solaris_sparc)
41-
install-shlib-dep := install-shlib
42-
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
43-
LDFLAGS_SL = -G
44-
CFLAGS += $(CFLAGS_SL)
45-
endif
4633

47-
ifeq ($(PORTNAME), solaris_i386)
48-
install-shlib-dep := install-shlib
49-
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
50-
LDFLAGS_SL = -G
51-
CFLAGS += $(CFLAGS_SL)
52-
endif
53-
54-
ifeq ($(PORTNAME), svr4)
55-
install-shlib-dep := install-shlib
56-
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_PATCHLEVEL)
57-
LDFLAGS_SL = -G
58-
CFLAGS += $(CFLAGS_SL)
59-
endif
60-
61-
ifeq ($(PORTNAME), univel)
62-
install-shlib-dep := install-shlib
63-
shlib := lib$(NAME)$(DLSUFFIX).1
64-
LDFLAGS_SL = -G -z text
65-
CFLAGS += $(CFLAGS_SL)
66-
endif
67-
68-
ifeq ($(PORTNAME), unixware)
69-
install-shlib-dep := install-shlib
70-
shlib := lib$(NAME)$(DLSUFFIX).1
71-
LDFLAGS_SL = -G -z text
72-
CFLAGS += $(CFLAGS_SL)
73-
endif
34+
.PHONY: install
7435

75-
ifeq ($(PORTNAME), hpux)
76-
install-shlib-dep := install-shlib
77-
shlib := lib$(NAME).sl
78-
LDFLAGS_SL := -b
79-
CFLAGS += $(CFLAGS_SL)
80-
endif
36+
install: install-lib $(install-shlib-dep)
8137

82-
all: lib$(NAME).a $(shlib)
38+
# Handmade dependencies in case make depend not done
39+
ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
40+
typename.o : typename.c ../include/ecpgtype.h
8341

84-
$(shlib): ecpglib.o typename.o
85-
$(LD) $(LDFLAGS_SL) -o $@ ecpglib.o typename.o
8642

43+
.PHONY: clean
8744
clean:
88-
rm -f *.o *.a core a.out *~ $(shlib) lib$(NAME)$(DLSUFFIX)
89-
90-
dep depend:
91-
92-
.PHONY: install install-libecpg install-shlib
93-
94-
install: install-libecpg $(install-shlib-dep)
95-
96-
install-libecpg: lib$(NAME).a
97-
$(INSTALL) $(INSTL_LIB_OPTS) lib$(NAME).a $(LIBDIR)/lib$(NAME).a
45+
rm -f lib$(NAME).a $(shlib) $(OBJS)
9846

99-
install-shlib: $(shlib)
100-
$(INSTALL) $(INSTL_SHLIB_OPTS) $(shlib) $(LIBDIR)/$(shlib)
101-
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)" ]; then \
102-
cd $(LIBDIR); \
103-
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
104-
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION); \
105-
fi
106-
if [ "$(shlib)" != "lib$(NAME)$(DLSUFFIX)" ]; then \
107-
cd $(LIBDIR); \
108-
rm -f lib$(NAME)$(DLSUFFIX); \
109-
$(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX); \
110-
fi
47+
depend dep:
48+
$(CC) -MM $(CFLAGS) *.c >depend
11149

112-
113-
uninstall::
114-
rm -f $(LIBDIR)/lib$(NAME).a $(LIBDIR)/$(shlib)
115-
rm -f $(LIBDIR)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
116-
rm -f $(LIBDIR)/lib$(NAME)$(DLSUFFIX)
117-
118-
# Rules that do something
119-
lib$(NAME).a : lib$(NAME).a(ecpglib.o) lib$(NAME).a(typename.o)
120-
121-
ecpglib.o : ecpglib.c ../include/ecpglib.h ../include/ecpgtype.h
122-
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
123-
typename.o : typename.c ../include/ecpgtype.h
124-
$(CC) $(CFLAGS) -I../include $(PQ_INCLUDE) -c $< -o $@
50+
ifeq (depend,$(wildcard depend))
51+
include depend
52+
endif

0 commit comments

Comments
 (0)