Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23119d5

Browse files
committed
Refactor DLSUFFIX handling
Move DLSUFFIX from makefiles into header files for all platforms. Move the DLSUFFIX assignment from src/makefiles/ to src/templates/, have configure read it, and then substitute it into Makefile.global and pg_config.h. This avoids the need for all makefile rules that need it to locally set CPPFLAGS. It also resolves an inconsistent setup between the two Windows build systems. Reviewed-by: Andres Freund <[email protected]> Discussion: https://www.postgresql.org/message-id/[email protected]
1 parent 5656683 commit 23119d5

File tree

26 files changed

+42
-39
lines changed

26 files changed

+42
-39
lines changed

config/python.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ else
120120
found_shlib=0
121121
for d in "${python_libdir}" "${python_configdir}" /usr/lib64 /usr/lib
122122
do
123-
# We don't know the platform DLSUFFIX here, so check 'em all.
123+
# Note: DLSUFFIX is for loadable modules, not shared
124+
# libraries, so cannot be used here portably. Just
125+
# check all known possibilities.
124126
for e in .so .dll .dylib .sl; do
125127
if test -e "$d/lib${ldlibrary}$e"; then
126128
python_libdir="$d"

configure

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ autodepend
734734
PKG_CONFIG_LIBDIR
735735
PKG_CONFIG_PATH
736736
PKG_CONFIG
737+
DLSUFFIX
737738
TAS
738739
GCC
739740
CPP
@@ -3033,6 +3034,9 @@ PORTNAME=$template
30333034
need_tas=no
30343035
tas_file=dummy.s
30353036

3037+
# Default, works for most platforms, override in template file if needed
3038+
DLSUFFIX=".so"
3039+
30363040

30373041

30383042
##
@@ -7688,6 +7692,12 @@ else
76887692
fi
76897693

76907694

7695+
7696+
cat >>confdefs.h <<_ACEOF
7697+
#define DLSUFFIX "$DLSUFFIX"
7698+
_ACEOF
7699+
7700+
76917701
#
76927702
# Set up pkg_config in case we need it below
76937703
#
@@ -10560,7 +10570,9 @@ else
1056010570
found_shlib=0
1056110571
for d in "${python_libdir}" "${python_configdir}" /usr/lib64 /usr/lib
1056210572
do
10563-
# We don't know the platform DLSUFFIX here, so check 'em all.
10573+
# Note: DLSUFFIX is for loadable modules, not shared
10574+
# libraries, so cannot be used here portably. Just
10575+
# check all known possibilities.
1056410576
for e in .so .dll .dylib .sl; do
1056510577
if test -e "$d/lib${ldlibrary}$e"; then
1056610578
python_libdir="$d"

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ AC_SUBST(PORTNAME)
103103
need_tas=no
104104
tas_file=dummy.s
105105

106+
# Default, works for most platforms, override in template file if needed
107+
DLSUFFIX=".so"
108+
106109

107110

108111
##
@@ -721,6 +724,10 @@ else
721724
fi
722725
AC_SUBST(TAS)
723726

727+
AC_SUBST(DLSUFFIX)dnl
728+
AC_DEFINE_UNQUOTED([DLSUFFIX], ["$DLSUFFIX"],
729+
[Define to the file name extension of dynamically-loadable modules.])
730+
724731
#
725732
# Set up pkg_config in case we need it below
726733
#

src/Makefile.global.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ WIN32_STACK_RLIMIT=4194304
545545
# Set if we have a working win32 crashdump header
546546
have_win32_dbghelp = @have_win32_dbghelp@
547547

548+
DLSUFFIX = @DLSUFFIX@
549+
548550
# Pull in platform-specific magic
549551
include $(top_builddir)/src/Makefile.port
550552

src/backend/jit/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ subdir = src/backend/jit
1515
top_builddir = ../../..
1616
include $(top_builddir)/src/Makefile.global
1717

18-
override CPPFLAGS += -DDLSUFFIX=\"$(DLSUFFIX)\"
19-
2018
OBJS = \
2119
jit.o
2220

src/backend/utils/fmgr/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ OBJS = \
1717
fmgr.o \
1818
funcapi.o
1919

20-
override CPPFLAGS += -DDLSUFFIX=\"$(DLSUFFIX)\"
21-
2220
include $(top_srcdir)/src/backend/common.mk

src/backend/utils/fmgr/dfmgr.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,6 @@ file_exists(const char *name)
483483
}
484484

485485

486-
/* Example format: ".so" */
487-
#ifndef DLSUFFIX
488-
#error "DLSUFFIX must be defined to compile this file."
489-
#endif
490-
491486
/*
492487
* If name contains a slash, check if the file exists, if so return
493488
* the name. Else (no slash) try to expand using search path (see

src/bin/pg_upgrade/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ OBJS = \
2525
util.o \
2626
version.o
2727

28-
override CPPFLAGS := -DDLSUFFIX=\"$(DLSUFFIX)\" -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
28+
override CPPFLAGS := -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
2929
LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
3030

3131
all: pg_upgrade

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
/* Define to the default TCP port number as a string constant. */
4343
#undef DEF_PGPORT_STR
4444

45+
/* Define to the file name extension of dynamically-loadable modules. */
46+
#undef DLSUFFIX
47+
4548
/* Define to build with GSSAPI support. (--with-gssapi) */
4649
#undef ENABLE_GSS
4750

src/include/port/win32_port.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,6 @@ typedef unsigned short mode_t;
529529
#define W_OK 2
530530
#define R_OK 4
531531

532-
/* Pulled from Makefile.port in MinGW */
533-
#define DLSUFFIX ".dll"
534-
535532
#endif /* _MSC_VER */
536533

537534
#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || \

0 commit comments

Comments
 (0)