1 #-------------------------------------------------------------------------
3 # Makefile for src/interfaces/libpq library
5 # Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # src/interfaces/libpq/Makefile
10 #-------------------------------------------------------------------------
12 subdir = src/interfaces/libpq
13 top_builddir = ../../..
14 include $(top_builddir)/src/Makefile.global
17 # shared library parameters
22 override CPPFLAGS := -DFRONTEND -DUNSAFE_STAT_OK -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port -I$(top_srcdir)/src/port
23 ifneq ($(PORTNAME), win32)
24 override CFLAGS += $(PTHREAD_CFLAGS)
27 # Need to recompile any external C files because we need
28 # all object files to use the same compile flags as libpq; some
29 # platforms require special flags.
30 LIBS := $(LIBS:-lpgport=)
32 # We can't use Makefile variables here because the MSVC build system scrapes
33 # OBJS from this file.
34 OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
35 fe-protocol2.o fe-protocol3.o pqexpbuffer.o fe-secure.o \
37 # libpgport C files we always use
38 OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o pqsignal.o \
40 # libpgport C files that are needed if identified by configure
41 OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o win32setlocale.o, $(LIBOBJS))
45 OBJS += encnames.o wchar.o
47 ifeq ($(PORTNAME), cygwin)
48 override shlib = cyg$(NAME)$(DLSUFFIX)
51 ifeq ($(PORTNAME), win32)
52 # pgsleep.o is from libpgport
53 OBJS += pgsleep.o win32.o libpqrc.o
56 $(WINDRES) -i $< -o $@
58 ifeq ($(enable_thread_safety), yes)
59 OBJS += pthread-win32.o
64 # Add libraries that libpq depends (or might depend) on into the
65 # shared library link. (The order in which you list them here doesn't
67 ifneq ($(PORTNAME), win32)
68 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi_krb5 -lgss -lgssapi -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
70 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
72 ifeq ($(PORTNAME), win32)
73 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
76 SHLIB_EXPORTS = exports.txt
80 # Shared library stuff
81 include $(top_srcdir)/src/Makefile.shlib
82 backend_src = $(top_srcdir)/src/backend
85 # We use several libpgport and backend modules verbatim, but since we need
86 # to compile with appropriate options to build a shared lib, we can't
87 # necessarily use the same object files built for libpgport and the backend.
88 # Instead, symlink the source files in here and build our own object files.
89 # For some libpgport modules, this only happens if configure decides
90 # the module is needed (see filter hack in OBJS, above).
92 chklocale.c crypt.c getaddrinfo.c getpeereid.c inet_aton.c inet_net_ntop.c noblock.c open.c pgsleep.c pgstrcasecmp.c pqsignal.c snprintf.c strerror.c strlcpy.c thread.c win32error.c win32setlocale.c: % : $(top_srcdir)/src/port/%
93 rm -f $@ && $(LN_S) $< .
95 ip.c md5.c: % : $(backend_src)/libpq/%
96 rm -f $@ && $(LN_S) $< .
98 encnames.c wchar.c: % : $(backend_src)/utils/mb/%
99 rm -f $@ && $(LN_S) $< .
102 distprep: libpq-dist.rc
104 libpq.rc libpq-dist.rc: libpq.rc.in
105 sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
107 # Depend on Makefile.global to force rebuild on re-run of configure.
108 # (But libpq-dist.rc is shipped in the distribution for shell-less
109 # installations and is only updated by distprep.)
110 libpq.rc: $(top_builddir)/src/Makefile.global
112 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
113 fe-misc.o: fe-misc.c $(top_builddir)/src/port/pg_config_paths.h
115 $(top_builddir)/src/port/pg_config_paths.h:
116 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
118 install: all installdirs install-lib
119 $(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
120 $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
121 $(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
122 $(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
123 $(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
128 installdirs: installdirs-lib
129 $(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)' '$(DESTDIR)$(datadir)'
131 uninstall: uninstall-lib
132 rm -f '$(DESTDIR)$(includedir)/libpq-fe.h'
133 rm -f '$(DESTDIR)$(includedir)/libpq-events.h'
134 rm -f '$(DESTDIR)$(includedir_internal)/libpq-int.h'
135 rm -f '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h'
136 rm -f '$(DESTDIR)$(datadir)/pg_service.conf.sample'
138 clean distclean: clean-lib
140 rm -f $(OBJS) pthread.h libpq.rc
141 # Might be left over from a Win32 client-only build
142 rm -f pg_config_paths.h
143 rm -f inet_net_ntop.c noblock.c pgstrcasecmp.c pqsignal.c thread.c
144 rm -f chklocale.c crypt.c getaddrinfo.c getpeereid.c inet_aton.c open.c snprintf.c strerror.c strlcpy.c win32error.c win32setlocale.c
147 rm -f encnames.c wchar.c
149 maintainer-clean: distclean maintainer-clean-lib