Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1d5d85

Browse files
committed
Refactor the code that creates the shared library export files to appear
only once in Makefile.shlib and not in four copies.
1 parentfd15dba commita1d5d85

File tree

5 files changed

+102
-239
lines changed

5 files changed

+102
-239
lines changed

‎src/Makefile.shlib

Lines changed: 77 additions & 6 deletions
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-
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.109 2007/02/20 22:45:57 momjian Exp $
9+
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.110 2008/02/26 06:41:23 petere Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -24,15 +24,15 @@
2424
# OBJS List of object files to include in library
2525
# SHLIB_LINK If shared library relies on other libraries,
2626
# additional stuff to put in its link command
27+
# SHLIB_EXPORTS (optional) Name of file containing list of symbols to
28+
# export
2729
# (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., "6.2".)
2830
#
2931
# Optional flags when building DLL's (only applicable to win32 and cygwin
3032
# platforms).
3133
# DLLTOOL_DEFFLAGS Additional flags when creating the dll .def file
3234
# DLLTOOL_LIBFLAGS Additional flags when creating the lib<module>.a file
3335
# DLLWRAP_FLAGS Additional flags to dllwrap
34-
# DLL_DEFFILE Use pre-existing .def file instead of auto-generating
35-
# one with all exports in it (win32 only).
3636
#
3737
# The module Makefile must also include
3838
# $(top_builddir)/src/Makefile.global before including this file.
@@ -44,6 +44,7 @@
4444
# install-lib install the libraries into $(libdir)
4545
# uninstall-lib remove the libraries from $(libdir)
4646
# clean-lib delete the static and shared libraries from the build dir
47+
# maintainer-clean-lib delete .def files built for win32
4748
#
4849
# Since `all-lib' is the first rule in this file you probably want to
4950
# have the `all' target before including this file. In the most simple
@@ -115,6 +116,10 @@ ifeq ($(PORTNAME), darwin)
115116
endif
116117
shlib= lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
117118
shlib_major= lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
119+
BUILD.exports= $(AWK) '/^[^#]/ {printf "_%s\n",$$1}' $< >$@
120+
ifneq (,$(SHLIB_EXPORTS))
121+
exported_symbols_list = -exported_symbols_list $(SHLIB_EXPORTS:%.txt=%.list)
122+
endif
118123
endif
119124

120125
ifeq ($(PORTNAME), openbsd)
@@ -186,7 +191,11 @@ ifeq ($(PORTNAME), irix)
186191
endif
187192

188193
ifeq ($(PORTNAME), linux)
189-
LINK.shared= $(COMPILER) -shared -Wl,-soname,$(soname) $(exported_symbols_list)
194+
LINK.shared= $(COMPILER) -shared -Wl,-soname,$(soname)
195+
BUILD.exports= ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
196+
ifneq (,$(SHLIB_EXPORTS))
197+
LINK.shared+= -Wl,--version-script=$(SHLIB_EXPORTS:%.txt=%.list)
198+
endif
190199
endif
191200

192201
ifeq ($(PORTNAME), solaris)
@@ -293,6 +302,19 @@ ifneq ($(shlib), $(shlib_bare))
293302
$(LN_S) $(shlib) $(shlib_bare)
294303
endif
295304

305+
# Where possible, restrict the symbols exported by the library to just the
306+
# official list, so as to avoid unintentional ABI changes. On recent Darwin
307+
# this also quiets multiply-defined-symbol warnings in programs that use
308+
# libpgport along with libpq.
309+
ifneq (,$(SHLIB_EXPORTS))
310+
ifdef BUILD.exports
311+
$(shlib): $(SHLIB_EXPORTS:%.txt=%.list)
312+
313+
$(SHLIB_EXPORTS:%.txt=%.list): %.list: %.txt
314+
$(BUILD.exports)
315+
endif
316+
endif
317+
296318
else # PORTNAME == aix
297319

298320
# AIX case
@@ -303,7 +325,7 @@ $(shlib) lib$(NAME).a: $(OBJS)
303325
$(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:lib$(NAME)$(EXPSUFF) $(SHLIB_LINK)
304326
rm -f lib$(NAME).a
305327
$(AR) $(AROPT) lib$(NAME).a $(shlib)
306-
328+
307329
endif # PORTNAME == aix
308330

309331
else # PORTNAME == cygwin
@@ -323,6 +345,10 @@ endif # PORTNAME == cygwin
323345

324346
else # PORTNAME == win32
325347

348+
ifneq (,$(SHLIB_EXPORTS))
349+
DLL_DEFFILE = lib$(NAME)dll.def
350+
endif
351+
326352
# win32 case
327353
$(shlib) lib$(NAME).a: $(OBJS)
328354
ifndef DLL_DEFFILE
@@ -339,6 +365,46 @@ endif # PORTNAME == win32
339365
endif # enable_shared
340366

341367

368+
# We need several not-quite-identical variants of .DEF files to build
369+
# DLLs for Windows. These are made from the single source file
370+
# exports.txt. Since we can't assume that Windows boxes will have
371+
# sed, the .DEF files are always built and included in distribution
372+
# tarballs.
373+
374+
ifneq (,$(SHLIB_EXPORTS))
375+
all: def-files
376+
377+
distprep: def-files
378+
379+
.PHONY: def-files
380+
381+
def-files: $(srcdir)/lib$(NAME)dll.def $(srcdir)/lib$(NAME)ddll.def $(srcdir)/blib$(NAME)dll.def
382+
383+
UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
384+
385+
$(srcdir)/lib$(NAME)dll.def: $(SHLIB_EXPORTS)
386+
echo '; DEF file for MS VC++' >$@
387+
echo 'LIBRARY LIB$(UC_NAME)' >>$@
388+
echo 'EXPORTS' >>$@
389+
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
390+
391+
$(srcdir)/lib$(NAME)ddll.def: $(SHLIB_EXPORTS)
392+
echo '; DEF file for MS VC++' >$@
393+
echo 'LIBRARY LIB$(UC_NAME)D' >>$@
394+
echo 'EXPORTS' >>$@
395+
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
396+
397+
$(srcdir)/blib$(NAME)dll.def: $(SHLIB_EXPORTS)
398+
echo '; DEF file for Borland C++ Builder' >$@
399+
echo 'LIBRARY BLIB$(UC_NAME)' >>$@
400+
echo 'EXPORTS' >>$@
401+
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/' $< >>$@
402+
echo >>$@
403+
echo '; Aliases for MS compatible names' >> $@
404+
sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' $< | sed 's/ *$$//' >>$@
405+
endif # SHLIB_EXPORTS
406+
407+
342408
##
343409
## INSTALL
344410
##
@@ -398,7 +464,7 @@ endif # enable_shared
398464
clean-lib:
399465
rm -f lib$(NAME).a
400466
ifeq ($(enable_shared), yes)
401-
rm -f $(shlib_bare) $(shlib_major) $(shlib)
467+
rm -f $(shlib_bare) $(shlib_major) $(shlib) $(SHLIB_EXPORTS:%.txt=%.list)
402468
ifdef EXPSUFF
403469
rm -f lib$(NAME)$(EXPSUFF)
404470
endif
@@ -410,3 +476,8 @@ endif
410476
ifeq ($(PORTNAME), win32)
411477
rm -f $(NAME).dll $(NAME).def
412478
endif
479+
480+
ifneq (,$(SHLIB_EXPORTS))
481+
maintainer-clean-lib:
482+
rm -f $(srcdir)/lib$(NAME)dll.def $(srcdir)/lib$(NAME)ddll.def $(srcdir)/blib$(NAME)dll.def
483+
endif

‎src/interfaces/ecpg/compatlib/Makefile

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.38 2008/02/13 18:14:46 momjian Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.39 2008/02/26 06:41:23 petere Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -25,72 +25,21 @@ override CFLAGS += $(PTHREAD_CFLAGS)
2525
SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes$(libpq) -lm\
2626
$(PTHREAD_LIBS)
2727

28+
SHLIB_EXPORTS = exports.txt
29+
2830
# Need to recompile any libpgport object files
2931
LIBS :=$(filter-out -lpgport,$(LIBS))
3032

3133
OBJS= informix.o$(filter snprintf.o,$(LIBOBJS))
3234

33-
ifeq ($(PORTNAME), win32)
34-
DLL_DEFFILE=libecpg_compatdll.def
35-
endif
36-
37-
all: def-files all-lib
35+
all: all-lib
3836

3937
# Shared library stuff
4038
include$(top_srcdir)/src/Makefile.shlib
4139

4240
snprintf.c:% :$(top_srcdir)/src/port/%
4341
rm -f$@&&$(LN_S)$<.
4442

45-
# We need several not-quite-identical variants of .DEF files to build libecpg
46-
# DLLs for Windows. These are made from the single source file exports.txt.
47-
# Since we can't assume that Windows boxes will have sed, the .DEF files are
48-
# always built and included in distribution tarballs.
49-
50-
distprep: def-files
51-
52-
.PHONY: def-files
53-
54-
def-files:$(srcdir)/libecpg_compatdll.def$(srcdir)/blibecpg_compatdll.def
55-
56-
$(srcdir)/libecpg_compatdll.def: exports.txt
57-
echo'; DEF file for MS VC++'>$@
58-
echo'LIBRARY LIBECPG_COMPAT'>>$@
59-
echo'EXPORTS'>>$@
60-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/'<$<>>$@
61-
62-
$(srcdir)/blibecpg_compatdll.def: exports.txt
63-
echo'; DEF file for Borland C++ Builder'>$@
64-
echo'LIBRARY BLIBECPG_COMPAT'>>$@
65-
echo'EXPORTS'>>$@
66-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/'<$<>>$@
67-
echo''>>$@
68-
echo'; Aliases for MS compatible names'>>$@
69-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/'<$<| sed's/ *$$//'>>$@
70-
71-
# Where possible, restrict the symbols exported by the library to just the
72-
# official list, so as to avoid unintentional ABI changes.
73-
74-
ifeq ($(PORTNAME), darwin)
75-
$(shlib): exports.list
76-
77-
exports.list: exports.txt
78-
$(AWK)'/^[^#]/ {printf "_%s\n",$$1}'$<>$@
79-
80-
exported_symbols_list = -exported_symbols_list exports.list
81-
endif
82-
83-
ifeq ($(PORTNAME), linux)
84-
$(shlib): exports.list
85-
86-
exports.list: exports.txt
87-
echo'{ global:'>$@
88-
$(AWK)'/^[^#]/ {printf "%s;\n",$$1}'$<>>$@
89-
echo' local: *; };'>>$@
90-
91-
exported_symbols_list = -Wl,--version-script=exports.list
92-
endif
93-
9443
install: all installdirs install-lib
9544

9645
installdirs:
@@ -99,7 +48,6 @@ installdirs:
9948
uninstall: uninstall-lib
10049

10150
cleandistclean: clean-lib
102-
rm -f$(OBJS) snprintf.c exports.list
51+
rm -f$(OBJS) snprintf.c
10352

104-
maintainer-clean: distclean
105-
rm -f$(srcdir)/libecpg_compatdll.def$(srcdir)/blibecpg_compatdll.def
53+
maintainer-clean: distclean maintainer-clean-lib

‎src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.55 2008/02/13 18:14:46 momjian Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.56 2008/02/26 06:41:24 petere Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -36,13 +36,14 @@ endif
3636

3737
SHLIB_LINK = -L../pgtypeslib -lpgtypes$(libpq) -lm$(PTHREAD_LIBS)
3838

39+
SHLIB_EXPORTS = exports.txt
40+
3941
ifeq ($(PORTNAME), win32)
4042
# Link to shfolder.dll instead of shell32.dll
4143
SHLIB_LINK += -lshfolder
42-
DLL_DEFFILE=libecpgdll.def
4344
endif
4445

45-
all:def-filesall-lib
46+
all: all-lib
4647

4748
# Shared library stuff
4849
include$(top_srcdir)/src/Makefile.shlib
@@ -60,55 +61,6 @@ path.o: path.c $(top_builddir)/src/port/pg_config_paths.h
6061
$(top_builddir)/src/port/pg_config_paths.h:
6162
$(MAKE) -C$(top_builddir)/src/port pg_config_paths.h
6263

63-
# We need several not-quite-identical variants of .DEF files to build libecpg
64-
# DLLs for Windows. These are made from the single source file exports.txt.
65-
# Since we can't assume that Windows boxes will have sed, the .DEF files are
66-
# always built and included in distribution tarballs.
67-
68-
distprep: def-files
69-
70-
.PHONY: def-files
71-
72-
def-files:$(srcdir)/libecpgdll.def$(srcdir)/blibecpgdll.def
73-
74-
$(srcdir)/libecpgdll.def: exports.txt
75-
echo'; DEF file for MS VC++'>$@
76-
echo'LIBRARY LIBECPG'>>$@
77-
echo'EXPORTS'>>$@
78-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/'<$<>>$@
79-
80-
$(srcdir)/blibecpgdll.def: exports.txt
81-
echo'; DEF file for Borland C++ Builder'>$@
82-
echo'LIBRARY BLIBECPG'>>$@
83-
echo'EXPORTS'>>$@
84-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/'<$<>>$@
85-
echo''>>$@
86-
echo'; Aliases for MS compatible names'>>$@
87-
sed -e'/^#/d' -e's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/'<$<| sed's/ *$$//'>>$@
88-
89-
# Where possible, restrict the symbols exported by the library to just the
90-
# official list, so as to avoid unintentional ABI changes.
91-
92-
ifeq ($(PORTNAME), darwin)
93-
$(shlib): exports.list
94-
95-
exports.list: exports.txt
96-
$(AWK)'/^[^#]/ {printf "_%s\n",$$1}'$<>$@
97-
98-
exported_symbols_list = -exported_symbols_list exports.list
99-
endif
100-
101-
ifeq ($(PORTNAME), linux)
102-
$(shlib): exports.list
103-
104-
exports.list: exports.txt
105-
echo'{ global:'>$@
106-
$(AWK)'/^[^#]/ {printf "%s;\n",$$1}'$<>>$@
107-
echo' local: *; };'>>$@
108-
109-
exported_symbols_list = -Wl,--version-script=exports.list
110-
endif
111-
11264
install: all installdirs install-lib
11365

11466
installdirs:
@@ -118,7 +70,6 @@ uninstall: uninstall-lib
11870

11971
cleandistclean: clean-lib
12072
rm -f$(OBJS)
121-
rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c exports.list
73+
rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c thread.c
12274

123-
maintainer-clean: distclean
124-
rm -f$(srcdir)/libecpgdll.def$(srcdir)/blibecpgdll.def
75+
maintainer-clean: distclean maintainer-clean-lib

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp