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

Commit bdaf90b

Browse files
committed
Reorganize some of the exports list generation code. It seems that this
has been reinvented about four different times throughout history (aix, cygwin, win32, darwin/linux) and a lot of the concepts are actually shared, which the code now shows better.
1 parent 734a56c commit bdaf90b

File tree

2 files changed

+32
-54
lines changed

2 files changed

+32
-54
lines changed

src/Makefile.shlib

+27-46
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.111 2008/02/26 10:30:06 petere Exp $
9+
# $PostgreSQL: pgsql/src/Makefile.shlib,v 1.112 2008/02/26 10:45:24 petere Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -99,6 +99,7 @@ soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
9999
ifeq ($(PORTNAME), aix)
100100
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
101101
haslibarule = yes
102+
exports_file = lib$(NAME).exp
102103
endif
103104

104105
ifeq ($(PORTNAME), darwin)
@@ -117,8 +118,9 @@ ifeq ($(PORTNAME), darwin)
117118
shlib = lib$(NAME).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)$(DLSUFFIX)
118119
shlib_major = lib$(NAME).$(SO_MAJOR_VERSION)$(DLSUFFIX)
119120
BUILD.exports = $(AWK) '/^[^\#]/ {printf "_%s\n",$$1}' $< >$@
120-
ifneq (,$(SHLIB_EXPORTS))
121-
exported_symbols_list = -exported_symbols_list $(SHLIB_EXPORTS:%.txt=%.list)
121+
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
122+
ifneq (,$(exports_file))
123+
exported_symbols_list = -exported_symbols_list $(exports_file)
122124
endif
123125
endif
124126

@@ -193,8 +195,9 @@ endif
193195
ifeq ($(PORTNAME), linux)
194196
LINK.shared = $(COMPILER) -shared -Wl,-soname,$(soname)
195197
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+
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
199+
ifneq (,$(exports_file))
200+
LINK.shared += -Wl,--version-script=$(exports_file)
198201
endif
199202
endif
200203

@@ -284,8 +287,7 @@ endif #haslibarule
284287

285288
ifeq ($(enable_shared), yes)
286289

287-
ifneq ($(PORTNAME), win32)
288-
ifneq ($(PORTNAME), cygwin)
290+
ifeq (,$(filter cygwin win32,$(PORTNAME)))
289291
ifneq ($(PORTNAME), aix)
290292

291293
# Normal case
@@ -321,46 +323,35 @@ else # PORTNAME == aix
321323
$(shlib) lib$(NAME).a: $(OBJS)
322324
$(LINK.static) lib$(NAME).a $^
323325
$(RANLIB) lib$(NAME).a
324-
$(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF)
325-
$(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:lib$(NAME)$(EXPSUFF) $(SHLIB_LINK)
326+
$(MKLDEXPORT) lib$(NAME).a >$(exports_file)
327+
$(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $(shlib) lib$(NAME).a -Wl,-bE:$(exports_file) $(SHLIB_LINK)
326328
rm -f lib$(NAME).a
327329
$(AR) $(AROPT) lib$(NAME).a $(shlib)
328330

329331
endif # PORTNAME == aix
330332

331-
else # PORTNAME == cygwin
333+
else # PORTNAME == cygwin || PORTNAME == win32
332334

333-
# Cygwin case
334-
$(shlib) lib$(NAME).a: $(OBJS)
335-
ifndef DLL_DEFFILE
336-
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
337-
$(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
338-
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
339-
else
340-
$(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
341-
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
342-
endif
335+
# Cygwin or Win32 case
343336

344-
endif # PORTNAME == cygwin
337+
DLL_DEFFILE = lib$(NAME)dll.def
345338

346-
else # PORTNAME == win32
339+
# If SHLIB_EXPORTS is set, the rules below will build a .def file from
340+
# that. Else we build a temporary one here.
341+
ifeq (,$(SHLIB_EXPORTS))
342+
exports_file = $(DLL_DEFFILE)
347343

348-
ifneq (,$(SHLIB_EXPORTS))
349-
DLL_DEFFILE = lib$(NAME)dll.def
344+
$(exports_file): $(OBJS)
345+
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $@ $^
350346
endif
351347

352-
# win32 case
353-
$(shlib) lib$(NAME).a: $(OBJS)
354-
ifndef DLL_DEFFILE
355-
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $(NAME).def $(OBJS)
356-
$(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(NAME).def $(OBJS) $(SHLIB_LINK)
357-
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(NAME).def --output-lib lib$(NAME).a
358-
else
359-
$(DLLWRAP) $(LDFLAGS_SL) -o $(shlib) --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
360-
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib lib$(NAME).a
361-
endif
348+
$(shlib): $(OBJS) $(DLL_DEFFILE)
349+
$(DLLWRAP) $(LDFLAGS_SL) -o $@ --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(SHLIB_LINK)
350+
351+
lib$(NAME).a: $(shlib) $(DLL_DEFFILE)
352+
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib $@
362353

363-
endif # PORTNAME == win32
354+
endif # PORTNAME == cygwin || PORTNAME == win32
364355

365356
endif # enable_shared
366357

@@ -464,17 +455,7 @@ endif # enable_shared
464455
clean-lib:
465456
rm -f lib$(NAME).a
466457
ifeq ($(enable_shared), yes)
467-
rm -f $(shlib_bare) $(shlib_major) $(shlib) $(SHLIB_EXPORTS:%.txt=%.list)
468-
ifdef EXPSUFF
469-
rm -f lib$(NAME)$(EXPSUFF)
470-
endif
471-
endif
472-
ifeq ($(PORTNAME), cygwin)
473-
rm -f $(NAME).dll $(NAME).def
474-
endif
475-
476-
ifeq ($(PORTNAME), win32)
477-
rm -f $(NAME).dll $(NAME).def
458+
rm -f $(shlib_bare) $(shlib_major) $(shlib) $(exports_file)
478459
endif
479460

480461
ifneq (,$(SHLIB_EXPORTS))

src/makefiles/Makefile.aix

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ else
2424
endif
2525

2626

27-
EXPSUFF= .exp
28-
IMPSUFF= .imp
29-
30-
POSTGRES_IMP= postgres$(IMPSUFF)
27+
POSTGRES_IMP= postgres.imp
3128

3229
ifdef PGXS
3330
BE_DLLLIBS= -Wl,-bI:$(bindir)/postgres/$(POSTGRES_IMP)
@@ -37,10 +34,10 @@ endif
3734

3835
MKLDEXPORT=$(top_srcdir)/src/backend/port/aix/mkldexport.sh
3936

40-
%$(EXPSUFF): %.o
41-
$(MKLDEXPORT) $*.o > $*$(EXPSUFF)
37+
%.exp: %.o
38+
$(MKLDEXPORT) $^ >$@
4239

43-
%$(DLSUFFIX): %.o %$(EXPSUFF)
44-
$(CC) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $*.o -Wl,-bE:$*$(EXPSUFF) $(SHLIB_LINK)
40+
%$(DLSUFFIX): %.o %.exp
41+
$(CC) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $*.o -Wl,-bE:$*.exp $(SHLIB_LINK)
4542

4643
sqlmansect = 7

0 commit comments

Comments
 (0)