@@ -25,24 +25,33 @@ override CFLAGS += $(PTHREAD_CFLAGS)
2525endif
2626
2727# Need to recompile any libpgport object files because we need these
28- # object files to use the same compile flags as libpq. If we used
29- # the object files from libpgport, this would not be true on all
30- # platforms. We filter some object files so we only use object
31- # files configure says we need.
28+ # object files to use the same compile flags as libpq; some
29+ # platforms require special flags for all libpq object files.
3230LIBS :=$(LIBS:-lpgport= )
3331
32+ # external object files that are always used by libpq
33+ BACKEND_LIBPQ = md5 ip
34+ UTILS_MB = encnames wchar
35+ PERM_PGPORT = inet_net_ntop noblock pgstrcasecmp thread
36+ ifeq ($(PORTNAME ) , win32)
37+ PERM_PGPORT += pgsleep
38+ endif
39+
40+
41+ # pgport object files are used by libpq if identified by configure
42+ OPT_PGPORT =$(filter $(addsuffix .o, crypt getaddrinfo inet_aton open snprintf strerror strlcpy win32error) ,$(LIBOBJS ) )
43+
3444OBJS =fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o\
3545fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o\
3646libpq-events.o\
37- md5.o ip.o wchar.o encnames.o inet_net_ntop.o noblock.o pgstrcasecmp.o thread.o\
38- $(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o,$(LIBOBJS ) )
47+ $(addsuffix .o,$(PERM_PGPORT ) $(OPT_PGPORT ) $(BACKEND_LIBPQ ) $(UTILS_MB ) )
3948
4049ifeq ($(PORTNAME ) , cygwin)
4150override shlib = cyg$(NAME )$(DLSUFFIX )
4251endif
4352
4453ifeq ($(PORTNAME ) , win32)
45- OBJS += win32.opgsleep.o libpqrc.o
54+ OBJS += win32.o libpqrc.o
4655
4756libpqrc.o : libpq.rc
4857$(WINDRES ) -i$< -o$@
@@ -77,17 +86,15 @@ backend_src = $(top_srcdir)/src/backend
7786# We use several backend modules verbatim, but since we need to
7887# compile with appropriate options to build a shared lib, we can't
7988# necessarily use the same object files as the backend uses. Instead,
80- # symlink the source files in here and build our own object file.
81- # For port modules, this only happens if configure decides the module
82- # is needed (see filter hack in OBJS, above).
89+ # we symlink the source files in here and build our own object files.
8390
84- crypt.c getaddrinfo.c inet_aton.c inet_net_ntop.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c win32error.c pgsleep.c :% :$(top_srcdir ) /src/port/%
91+ $( addsuffix .c, $( PERM_PGPORT ) $( OPT_PGPORT ) ) :% :$(top_srcdir ) /src/port/%
8592rm -f$@ && $(LN_S ) $< .
8693
87- md5.c ip.c :% :$(backend_src ) /libpq/%
94+ $( addsuffix .c, $( BACKEND_LIBPQ ) ) :% :$(backend_src ) /libpq/%
8895rm -f$@ && $(LN_S ) $< .
8996
90- encnames.c wchar.c :% :$(backend_src ) /utils/mb/%
97+ $( addsuffix .c, $( UTILS_MB ) ) :% :$(backend_src ) /utils/mb/%
9198rm -f$@ && $(LN_S ) $< .
9299
93100
@@ -124,7 +131,7 @@ uninstall: uninstall-lib
124131rm -f' $(DESTDIR)$(datadir)/pg_service.conf.sample'
125132
126133clean distclean : clean-lib
127- rm -f$(OBJS ) pg_config_paths.hcrypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c md5.c ip.c encnames.c wchar.c win32error.c pgsleep.c pthread.h libpq.rc
134+ rm -f$(OBJS ) pg_config_paths.hpthread.h libpq.rc $( addsuffix .c, $( BACKEND_LIBPQ ) $( UTILS_MB ) $( PERM_PGPORT ) $( OPT_PGPORT ) )
128135# Might be left over from a Win32 client-only build
129136rm -f pg_config_paths.h
130137