1 #-------------------------------------------------------------------------
3 # Makefile for src/interfaces/libpq library
5 # Portions Copyright (c) 1996-2011, 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 pqsignal.o fe-secure.o \
37 # libpgport C files we always use
38 OBJS += inet_net_ntop.o noblock.o pgstrcasecmp.o thread.o
39 # libpgport C files that are needed if identified by configure
40 OBJS += $(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o, $(LIBOBJS))
44 OBJS += encnames.o wchar.o
46 ifeq ($(PORTNAME), cygwin)
47 override shlib = cyg$(NAME)$(DLSUFFIX)
50 ifeq ($(PORTNAME), win32)
51 # pgsleep.o is from libpgport
52 OBJS += pgsleep.o win32.o libpqrc.o
55 $(WINDRES) -i $< -o $@
57 ifeq ($(enable_thread_safety), yes)
58 OBJS += pthread-win32.o
63 # Add libraries that libpq depends (or might depend) on into the
64 # shared library link. (The order in which you list them here doesn't
66 ifneq ($(PORTNAME), win32)
67 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)
69 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
71 ifeq ($(PORTNAME), win32)
72 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
75 SHLIB_EXPORTS = exports.txt
79 # Shared library stuff
80 include $(top_srcdir)/src/Makefile.shlib
81 backend_src = $(top_srcdir)/src/backend
84 # We use several backend modules verbatim, but since we need to
85 # compile with appropriate options to build a shared lib, we can't
86 # necessarily use the same object files as the backend uses. Instead,
87 # symlink the source files in here and build our own object file.
88 # For some libpgport modules, this only happens if configure decides
89 # the module is needed (see filter hack in OBJS, above).
91 crypt.c getaddrinfo.c inet_aton.c inet_net_ntop.c noblock.c open.c pgsleep.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c win32error.c: % : $(top_srcdir)/src/port/%
92 rm -f $@ && $(LN_S) $< .
94 ip.c md5.c: % : $(backend_src)/libpq/%
95 rm -f $@ && $(LN_S) $< .
97 encnames.c wchar.c: % : $(backend_src)/utils/mb/%
98 rm -f $@ && $(LN_S) $< .
101 distprep: libpq-dist.rc
103 libpq.rc libpq-dist.rc: libpq.rc.in
104 sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
106 # Depend on Makefile.global to force rebuild on re-run of configure.
107 # (But libpq-dist.rc is shipped in the distribution for shell-less
108 # installations and is only updated by distprep.)
109 libpq.rc: $(top_builddir)/src/Makefile.global
111 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
113 $(top_builddir)/src/port/pg_config_paths.h:
114 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
116 install: all installdirs install-lib
117 $(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
118 $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
119 $(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
120 $(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
121 $(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
123 installdirs: installdirs-lib
124 $(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)'
126 uninstall: uninstall-lib
127 rm -f '$(DESTDIR)$(includedir)/libpq-fe.h'
128 rm -f '$(DESTDIR)$(includedir)/libpq-events.h'
129 rm -f '$(DESTDIR)$(includedir_internal)/libpq-int.h'
130 rm -f '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h'
131 rm -f '$(DESTDIR)$(datadir)/pg_service.conf.sample'
133 clean distclean: clean-lib
134 rm -f $(OBJS) pthread.h libpq.rc
135 # Might be left over from a Win32 client-only build
136 rm -f pg_config_paths.h
137 rm -f inet_net_ntop.c noblock.c pgstrcasecmp.c thread.c
138 rm -f crypt.c getaddrinfo.c inet_aton.c open.c snprintf.c strerror.c strlcpy.c win32error.c
141 rm -f encnames.c wchar.c
143 maintainer-clean: distclean maintainer-clean-lib