6
6
# Copyright (c) 1998, Regents of the University of California
7
7
#
8
8
# IDENTIFICATION
9
- # $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.26 2000/10/20 21:03:38 petere Exp $
9
+ # $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.27 2000/10/23 21:43:56 petere Exp $
10
10
#
11
11
#-------------------------------------------------------------------------
12
12
51
51
#
52
52
# Got that? Look at src/interfaces/libpq/Makefile for an example.
53
53
54
+ ifndef cplusplus
55
+ COMPILER = $(CC)
56
+ else
57
+ COMPILER = $(CXX)
58
+ endif
59
+
60
+
61
+ # First, a few hacks for building *static* libraries.
62
+
63
+ LINK.static = $(AR) $(AROPT)
64
+
65
+ ifdef cplusplus
54
66
55
- # shlib is empty by default. If we know how to build a shared library
56
- # it will contain the name of the file, otherwise it will remain
57
- # empty. Thus `ifdef shlib' could be used in the containing make file
58
- # to test whether shared libraries are available.
59
- shlib :=
67
+ ifeq ($(PORTNAME), irix5)
68
+ ifneq ($(GXX), yes)
69
+ LINK.static = $(CXX) -ar -o
70
+ endif
71
+ endif
60
72
61
- # For each platform we support shared libraries on, set shlib and
62
- # update flags as needed to build a shared lib. Note we depend on
63
- # Makefile.global (or really Makefile.port) to supply DLSUFFIX and
64
- # other symbols.
73
+ ifeq ($(PORTNAME), solaris)
74
+ ifneq ($(GXX), yes)
75
+ LINK.static = $(CXX) -xar -o
76
+ endif
77
+ endif
78
+
79
+ endif # cplusplus
80
+
81
+
82
+
83
+ ifeq ($(enable_shared), yes)
84
+
85
+ # For each platform we support shared libraries on, set shlib to the
86
+ # name of the library, LINK.shared to the command to link the library,
87
+ # and adjust SHLIB_LINK if necessary.
65
88
66
89
# Try to keep the sections in some kind of order, folks...
67
90
91
+ # XXX fix Makefile.aix
92
+ ifneq ($(PORTNAME), aix)
93
+ ifndef cplusplus
94
+ override CFLAGS += $(CFLAGS_SL)
95
+ else
96
+ override CXXFLAGS += $(CFLAGS_SL)
97
+ endif
98
+ endif
99
+
100
+
68
101
ifeq ($(PORTNAME), aix)
69
102
shlib := lib$(NAME)$(DLSUFFIX)
70
103
SHLIB_LINK += -lc
71
104
endif
72
105
73
106
ifeq ($(PORTNAME), openbsd)
74
- ifdef BSD_SHLIB
75
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
76
- ifdef ELF_SYSTEM
77
- LDFLAGS_SL := -x -Bshareable -soname $(shlib)
78
- else
79
- LDFLAGS_SL := -x -Bshareable -Bforcearchive
80
- endif
81
- override CFLAGS += $(CFLAGS_SL)
107
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
108
+ ifdef ELF_SYSTEM
109
+ LINK.shared = $(LD) -x -Bshareable -soname $(shlib)
110
+ else
111
+ LINK.shared = $(LD) -x -Bshareable -Bforcearchive
82
112
endif
83
113
endif
84
114
85
115
ifeq ($(PORTNAME), bsdi)
86
- ifdef BSD_SHLIB
87
- ifeq ($(DLSUFFIX), .so)
88
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
89
- LDFLAGS_SL += -shared -soname $(shlib)
90
- override CFLAGS += $(CFLAGS_SL)
91
- endif
92
- ifeq ($(DLSUFFIX), .o)
93
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
94
- LD := shlicc
95
- LDFLAGS_SL += -O $(LDREL)
96
- override CFLAGS += $(CFLAGS_SL)
97
- endif
116
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
117
+ ifeq ($(DLSUFFIX), .so)
118
+ LINK.shared = $(LD) -shared -soname $(shlib)
119
+ endif
120
+ ifeq ($(DLSUFFIX), .o)
121
+ LINK.shared = shlicc -O $(LDREL)
98
122
endif
99
123
endif
100
124
101
125
ifeq ($(PORTNAME), freebsd)
102
- ifdef BSD_SHLIB
103
- ifdef ELF_SYSTEM
104
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
105
- LDFLAGS_SL := -x -shared -soname $(shlib)
106
- else
107
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
108
- LDFLAGS_SL := -x -Bshareable -Bforcearchive
109
- endif
110
- override CFLAGS += $(CFLAGS_SL)
126
+ ifdef ELF_SYSTEM
127
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
128
+ LINK.shared = $(LD) -x -shared -soname $(shlib)
129
+ else
130
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
131
+ LINK.shared = $(LD) -x -Bshareable -Bforcearchive
111
132
endif
112
133
endif
113
134
114
135
ifeq ($(PORTNAME), netbsd)
115
- ifdef BSD_SHLIB
116
- soname := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
117
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
118
- ifdef ELF_SYSTEM
119
- LD := $(CC)
120
- LDFLAGS_SL := -shared -Wl,-soname -Wl,$(soname)
121
- ifneq ($(SHLIB_LINK),)
122
- LDFLAGS_SL += -Wl,-R$(libdir)
123
- endif
124
- else
125
- LDFLAGS_SL := -x -Bshareable -Bforcearchive
136
+ soname := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
137
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
138
+ ifdef ELF_SYSTEM
139
+ LINK.shared = $(COMPILER) -shared -Wl,-soname -Wl,$(soname)
140
+ ifneq ($(SHLIB_LINK),)
141
+ LINK.shared += -Wl,-R$(libdir)
126
142
endif
127
- override CFLAGS += $(CFLAGS_SL)
143
+ else
144
+ LINK.shared = $(LD) -x -Bshareable -Bforcearchive
128
145
endif
129
146
endif
130
147
131
148
ifeq ($(PORTNAME), hpux)
132
149
# HPUX doesn't believe in version numbers for shlibs
133
150
shlib := lib$(NAME)$(DLSUFFIX)
134
- LDFLAGS_SL := -b
135
- override CFLAGS += $(CFLAGS_SL)
151
+ LINK.shared = $(LD) -b
136
152
endif
137
153
138
154
ifeq ($(PORTNAME), irix5)
139
- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
140
- LDFLAGS_SL := -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
141
- override CFLAGS += $(CFLAGS_SL)
155
+ shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
156
+ LINK.shared := $(COMPILER) -shared -rpath $(libdir) -set_version sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
142
157
endif
143
158
144
159
ifeq ($(PORTNAME), linux)
145
160
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
146
- LD := $(CC)
147
- LDFLAGS_SL := -shared -Wl,-soname,$(shlib)
148
- LDFLAGS_ODBC := -lm
149
- override CFLAGS += $(CFLAGS_SL)
161
+ LINK.shared = $(COMPILER) -shared -Wl,-soname,$(shlib)
150
162
endif
151
163
152
164
ifeq ($(PORTNAME), solaris)
153
165
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
154
- LDFLAGS_SL := -G
166
+ LINK.shared = $(COMPILER) -G
155
167
SHLIB_LINK += -ldl -lsocket -lresolv -lnsl -lm -lc
156
- override CFLAGS += $(CFLAGS_SL)
157
168
endif
158
169
159
170
ifeq ($(PORTNAME), osf)
160
171
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
161
- LDFLAGS_SL += -shared -expect_unresolved '*'
172
+ LINK.shared = $(LD) -shared -expect_unresolved '*'
162
173
endif
163
174
164
175
ifeq ($(PORTNAME), svr4)
165
176
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
166
- LDFLAGS_SL := -G
167
- override CFLAGS += $(CFLAGS_SL)
177
+ LINK.shared = $(LD) -G
168
178
endif
169
179
170
180
ifeq ($(PORTNAME), univel)
171
181
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
172
- LDFLAGS_SL := -G -z text
173
- override CFLAGS += $(CFLAGS_SL)
174
- ifeq ($(CXX), CC)
175
- override CXXFLAGS += -Xw
176
- COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
177
- endif
182
+ LINK.shared = $(LD) -G -z text
178
183
endif
179
184
180
185
ifeq ($(PORTNAME), unixware)
181
186
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
182
- LDFLAGS_SL := -G -z text
183
- override CFLAGS += $(CFLAGS_SL)
184
- ifeq ($(CXX), CC)
185
- override CXXFLAGS += -Xw
186
- COMPILE.cc = $(CXX) $(CXXFLAGS:ll,alloca=ll) $(CPPFLAGS) $(TARGET_ARCH) -c
187
- endif
187
+ LINK.shared = $(LD) -G -z text
188
188
endif
189
189
190
190
ifeq ($(PORTNAME), win)
191
191
shlib := $(NAME)$(DLSUFFIX)
192
+ ifdef cplusplus
193
+ SHLIB_LINK += --driver-name g++
194
+ endif
192
195
endif
193
196
194
197
ifeq ($(PORTNAME), beos)
195
- install- shlib-dep := install-shlib
196
- shlib := lib$(NAME)$(DLSUFFIX)
197
- LDFLAGS_SL : = -nostart - ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
198
+ shlib := lib$(NAME)$(DLSUFFIX)
199
+ LINK.shared = $(LD) -nostart
200
+ SHLIB_LINK + = -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
198
201
endif
199
202
200
- # Note that in what follows, shlib is empty when not building a shared
201
- # library.
203
+ endif # enable_shared
204
+
202
205
203
206
204
207
##
@@ -208,8 +211,6 @@ endif
208
211
.PHONY: all-lib
209
212
all-lib: lib$(NAME).a $(shlib)
210
213
211
- # Rules to build regular and shared libraries
212
-
213
214
ifneq ($(PORTNAME), win)
214
215
215
216
ifndef LORDER
@@ -218,22 +219,23 @@ endif
218
219
219
220
lib$(NAME).a: $(OBJS)
220
221
ifdef MK_NO_LORDER
221
- $(AR) $(AROPT ) $@ $^
222
+ $(LINK.static ) $@ $^
222
223
else
223
- $(AR) $(AROPT ) $@ `$(LORDER) $^ | tsort`
224
+ $(LINK.static ) $@ `$(LORDER) $^ | tsort`
224
225
endif
225
226
$(RANLIB) $@
226
227
227
228
endif # not win
228
229
229
- ifdef shlib
230
+ ifeq ($(enable_shared), yes)
231
+
230
232
ifneq ($(PORTNAME), beos)
231
233
ifneq ($(PORTNAME), win)
232
234
ifneq ($(PORTNAME), aix)
233
235
234
236
# Normal case
235
237
$(shlib): $(OBJS)
236
- $(LD) $(LDFLAGS_SL ) -o $@ $(OBJS) $(SHLIB_LINK)
238
+ $(LINK.shared ) -o $@ $(OBJS) $(SHLIB_LINK)
237
239
# If we're using major and minor versions, then make a symlink to major-version-only.
238
240
ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION))
239
241
rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
@@ -275,7 +277,8 @@ $(shlib): $(OBJS)
275
277
$(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
276
278
277
279
endif # PORTNAME == beos
278
- endif # shlib
280
+
281
+ endif # enable_shared
279
282
280
283
281
284
##
@@ -288,7 +291,7 @@ install-lib: install-lib-static install-lib-shared
288
291
install-lib-static: lib$(NAME).a
289
292
$(INSTALL_DATA) $< $(DESTDIR)$(libdir)/lib$(NAME).a
290
293
291
- ifdef shlib
294
+ ifeq ($(enable_shared), yes)
292
295
install-lib-shared: $(shlib)
293
296
$(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
294
297
ifneq ($(PORTNAME), win)
@@ -304,7 +307,7 @@ ifneq ($(shlib), lib$(NAME)$(DLSUFFIX))
304
307
endif
305
308
306
309
endif # not win
307
- endif # shlib
310
+ endif # enable_shared
308
311
309
312
310
313
##
@@ -314,11 +317,11 @@ endif # shlib
314
317
.PHONY: uninstall-lib
315
318
uninstall-lib:
316
319
rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
317
- ifdef shlib
320
+ ifeq ($(enable_shared), yes)
318
321
rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX) \
319
322
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) \
320
323
$(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
321
- endif # shlib
324
+ endif # enable_shared
322
325
323
326
324
327
##
@@ -328,7 +331,9 @@ endif # shlib
328
331
.PHONY: clean-lib
329
332
clean-lib:
330
333
rm -f lib$(NAME).a
334
+ ifeq ($(enable_shared), yes)
331
335
rm -f $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX)
336
+ endif
332
337
ifeq ($(PORTNAME), win)
333
338
rm -rf $(NAME).def
334
339
endif
0 commit comments