66# Copyright (c) 1998, Regents of the University of California
77#
88# IDENTIFICATION
9- # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.76 2004/05/19 21:37:43 momjian Exp $
9+ # $PostgreSQL: pgsql/src/Makefile.shlib,v 1.77 2004/07/13 00:06:46 tgl Exp $
1010#
1111#-------------------------------------------------------------------------
1212
@@ -71,8 +71,14 @@ LINK.static = $(AR) $(AROPT)
7171
7272ifeq ($(enable_shared), yes)
7373
74+ # Default shlib naming convention used by the majority of platforms
75+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
76+ shlib_major = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
77+ shlib_bare = lib$(NAME)$(DLSUFFIX)
78+
7479# For each platform we support shared libraries on, set shlib to the
75- # name of the library, LINK.shared to the command to link the library,
80+ # name of the library (if default above is not right), set
81+ # LINK.shared to the command to link the library,
7682# and adjust SHLIB_LINK if necessary.
7783
7884# Try to keep the sections in some kind of order, folks...
@@ -82,17 +88,28 @@ override CFLAGS += $(CFLAGS_SL)
8288soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
8389
8490ifeq ($(PORTNAME), aix)
85- shlib : = lib$(NAME)$(DLSUFFIX)
91+ shlib = lib$(NAME)$(DLSUFFIX)
8692# SHLIB_LINK += -lc
8793endif
8894
8995ifeq ($(PORTNAME), darwin)
90- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
91- LINK.shared = $(COMPILER) -bundle
96+ ifneq ($(SO_MAJOR_VERSION), 0)
97+ version_link := -compatibility_version $(SO_MAJOR_VERSION) -current_version $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
98+ endif
99+ ifeq ($(DLTYPE), library)
100+ # linkable library
101+ DLSUFFIX := .dylib
102+ LINK.shared = $(COMPILER) -dynamiclib -install_name $(libdir)/lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX) $(version_link) -multiply_defined suppress
103+ else
104+ # loadable module (default case)
105+ DLSUFFIX := .so
106+ LINK.shared = $(COMPILER) -bundle
107+ endif
108+ shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
109+ shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
92110endif
93111
94112ifeq ($(PORTNAME), openbsd)
95- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
96113 ifdef ELF_SYSTEM
97114 LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
98115 SHLIB_LINK += -lc
@@ -102,7 +119,6 @@ ifeq ($(PORTNAME), openbsd)
102119endif
103120
104121ifeq ($(PORTNAME), bsdi)
105- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
106122 ifeq ($(DLSUFFIX), .so)
107123 LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
108124 SHLIB_LINK += -lc
@@ -114,16 +130,15 @@ endif
114130
115131ifeq ($(PORTNAME), freebsd)
116132 ifdef ELF_SYSTEM
117- shlib : = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
133+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
118134 LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
119135 else
120- shlib : = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
136+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
121137 LINK.shared = $(LD) -x -Bshareable -Bforcearchive
122138 endif
123139endif
124140
125141ifeq ($(PORTNAME), netbsd)
126- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
127142 ifdef ELF_SYSTEM
128143 LINK.shared = $(COMPILER) -shared -Wl,-x,-soname,$(soname)
129144 else
@@ -132,25 +147,23 @@ ifeq ($(PORTNAME), netbsd)
132147endif
133148
134149ifeq ($(PORTNAME), hpux)
135- shlib : = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
150+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
136151 LINK.shared = $(LD) +h $(soname) -b +b $(libdir)
137152 ifeq ($(GCC), yes)
138153 SHLIB_LINK += `$(CC) -print-libgcc-file-name`
139154 endif
140155endif
141156
142157ifeq ($(PORTNAME), irix)
143- shlib : = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
158+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
144159 LINK.shared = $(COMPILER) -shared -Wl,-set_version,sgi$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
145160endif
146161
147162ifeq ($(PORTNAME), linux)
148- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
149163 LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname)
150164endif
151165
152166ifeq ($(PORTNAME), solaris)
153- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
154167 ifeq ($(GCC), yes)
155168 LINK.shared = $(CC) -shared
156169 else
@@ -164,17 +177,14 @@ ifeq ($(PORTNAME), solaris)
164177endif
165178
166179ifeq ($(PORTNAME), sunos4)
167- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
168180 LINK.shared = $(LD) -assert pure-text -Bdynamic
169181endif
170182
171183ifeq ($(PORTNAME), osf)
172- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
173184 LINK.shared = $(LD) -shared -expect_unresolved '*'
174185endif
175186
176187ifeq ($(PORTNAME), sco)
177- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
178188 ifeq ($(GCC), yes)
179189 LINK.shared = $(CC) -shared
180190 else
@@ -184,17 +194,14 @@ ifeq ($(PORTNAME), sco)
184194endif
185195
186196ifeq ($(PORTNAME), svr4)
187- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
188197 LINK.shared = $(LD) -G
189198endif
190199
191200ifeq ($(PORTNAME), univel)
192- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
193201 LINK.shared = $(LD) -G -z text
194202endif
195203
196204ifeq ($(PORTNAME), unixware)
197- shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
198205 ifeq ($(GCC), yes)
199206 LINK.shared = $(CC) -shared
200207 else
@@ -204,15 +211,15 @@ ifeq ($(PORTNAME), unixware)
204211endif
205212
206213ifeq ($(PORTNAME), cygwin)
207- shlib : = $(NAME)$(DLSUFFIX)
214+ shlib = $(NAME)$(DLSUFFIX)
208215endif
209216
210217ifeq ($(PORTNAME), win32)
211- shlib : = lib$(NAME)$(DLSUFFIX)
218+ shlib = lib$(NAME)$(DLSUFFIX)
212219endif
213220
214221ifeq ($(PORTNAME), beos)
215- shlib : = lib$(NAME)$(DLSUFFIX)
222+ shlib = lib$(NAME)$(DLSUFFIX)
216223 LINK.shared = $(LD) -nostart
217224 SHLIB_LINK += -ltermcap -lstdc++.r4 -lbind -lsocket -L/boot/develop/lib/x86
218225endif
@@ -258,23 +265,23 @@ endif # not cygwin
258265
259266ifeq ($(enable_shared), yes)
260267
261- ifneq ($(PORTNAME), beos)
262- ifneq ($(PORTNAME), cygwin)
263268ifneq ($(PORTNAME), win32)
269+ ifneq ($(PORTNAME), cygwin)
270+ ifneq ($(PORTNAME), beos)
264271ifneq ($(PORTNAME), aix)
265272
266273# Normal case
267274$(shlib): $(OBJS)
268275 $(LINK.shared) $(OBJS) $(SHLIB_LINK) -o $@
269276# If we're using major and minor versions, then make a symlink to major-version-only.
270- ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION ))
271- rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION )
272- $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION )
277+ ifneq ($(shlib), $(shlib_major ))
278+ rm -f $(shlib_major )
279+ $(LN_S) $(shlib) $(shlib_major )
273280endif
274281# Make sure we have a link to a name without any version numbers
275- ifneq ($(shlib), lib$(NAME)$(DLSUFFIX ))
276- rm -f lib$(NAME)$(DLSUFFIX )
277- $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX )
282+ ifneq ($(shlib), $(shlib_bare ))
283+ rm -f $(shlib_bare )
284+ $(LN_S) $(shlib) $(shlib_bare )
278285endif
279286
280287else # PORTNAME == aix
@@ -286,15 +293,14 @@ $(shlib): lib$(NAME).a
286293
287294endif # PORTNAME == aix
288295
289- else # PORTNAME == win32
296+ else # PORTNAME == beos
290297
291- # win32 case
292- $(shlib) lib$(NAME).a: $(OBJS)
293- $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
294- $(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
295- $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
298+ # BEOS case
299+ $(shlib): $(OBJS)
300+ ln -fs $(top_srcdir)/src/backend/postgres _APP_
301+ $(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
296302
297- endif # PORTNAME == win32
303+ endif # PORTNAME == beos
298304
299305else # PORTNAME == cygwin
300306
@@ -309,14 +315,15 @@ $(DLLINIT): $(DLLINIT:%.o=%.c)
309315
310316endif # PORTNAME == cygwin
311317
312- else # PORTNAME == beos
318+ else # PORTNAME == win32
313319
314- # BEOS case
315- $(shlib): $(OBJS)
316- ln -fs $(top_srcdir)/src/backend/postgres _APP_
317- $(CC) -Xlinker -soname=$@ $(LDFLAGS_SL) -o $@ _APP_ $(OBJS) $(SHLIB_LINK)
320+ # win32 case
321+ $(shlib) lib$(NAME).a: $(OBJS)
322+ $(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
323+ $(DLLWRAP) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
324+ $(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
318325
319- endif # PORTNAME == beos
326+ endif # PORTNAME == win32
320327
321328endif # enable_shared
322329
@@ -340,17 +347,16 @@ install-lib-shared: $(shlib)
340347 $(INSTALL_SHLIB) $< $(DESTDIR)$(libdir)/$(shlib)
341348ifneq ($(PORTNAME), cygwin)
342349ifneq ($(PORTNAME), win32)
343- ifneq ($(shlib), lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION ))
350+ ifneq ($(shlib), $(shlib_major ))
344351 cd $(DESTDIR)$(libdir) && \
345- rm -f lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION ) && \
346- $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION )
352+ rm -f $(shlib_major ) && \
353+ $(LN_S) $(shlib) $(shlib_major )
347354endif
348- ifneq ($(shlib), lib$(NAME)$(DLSUFFIX ))
355+ ifneq ($(shlib), $(shlib_bare ))
349356 cd $(DESTDIR)$(libdir) && \
350- rm -f lib$(NAME)$(DLSUFFIX ) && \
351- $(LN_S) $(shlib) lib$(NAME)$(DLSUFFIX )
357+ rm -f $(shlib_bare ) && \
358+ $(LN_S) $(shlib) $(shlib_bare )
352359endif
353-
354360endif # not win32
355361endif # not cygwin
356362endif # enable_shared
@@ -364,9 +370,9 @@ endif # enable_shared
364370uninstall-lib:
365371 rm -f $(DESTDIR)$(libdir)/lib$(NAME).a
366372ifeq ($(enable_shared), yes)
367- rm -f $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX ) \
368- $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION ) \
369- $(DESTDIR)$(libdir)/lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION )
373+ rm -f $(DESTDIR)$(libdir)/$(shlib_bare ) \
374+ $(DESTDIR)$(libdir)/$(shlib_major ) \
375+ $(DESTDIR)$(libdir)/$(shlib )
370376endif # enable_shared
371377
372378
@@ -378,7 +384,7 @@ endif # enable_shared
378384clean-lib:
379385 rm -f lib$(NAME).a
380386ifeq ($(enable_shared), yes)
381- rm -f lib$(NAME)$(DLSUFFIX) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION) lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION )
387+ rm -f $(shlib_bare) $(shlib_major) $(shlib )
382388ifdef EXPSUFF
383389 rm -f lib$(NAME)$(EXPSUFF)
384390endif
0 commit comments