1 #-------------------------------------------------------------------------
3 # Makefile for src/interfaces/libpq library
5 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.170 2008/12/02 10:39:30 mha Exp $
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
23 ifneq ($(PORTNAME), win32)
24 override CFLAGS += $(PTHREAD_CFLAGS)
27 # 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
31 LIBS := $(LIBS:-lpgport=)
33 OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
34 fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
36 md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
37 $(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o strlcpy.o win32error.o, $(LIBOBJS))
39 ifeq ($(PORTNAME), cygwin)
40 override shlib = cyg$(NAME)$(DLSUFFIX)
43 ifeq ($(PORTNAME), win32)
44 OBJS += win32.o pgsleep.o libpqrc.o
49 ifeq ($(enable_thread_safety), yes)
50 OBJS += pthread-win32.o
55 # Add libraries that libpq depends (or might depend) on into the
56 # shared library link. (The order in which you list them here doesn't
58 ifneq ($(PORTNAME), win32)
59 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)
61 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
63 ifeq ($(PORTNAME), win32)
64 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
67 SHLIB_EXPORTS = exports.txt
71 # Shared library stuff
72 include $(top_srcdir)/src/Makefile.shlib
73 backend_src = $(top_srcdir)/src/backend
76 # We use several backend modules verbatim, but since we need to
77 # compile with appropriate options to build a shared lib, we can't
78 # necessarily use the same object files as the backend uses. Instead,
79 # symlink the source files in here and build our own object file.
80 # For port modules, this only happens if configure decides the module
81 # is needed (see filter hack in OBJS, above).
83 crypt.c getaddrinfo.c inet_aton.c noblock.c open.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c thread.c win32error.c pgsleep.c: % : $(top_srcdir)/src/port/%
84 rm -f $@ && $(LN_S) $< .
86 md5.c ip.c: % : $(backend_src)/libpq/%
87 rm -f $@ && $(LN_S) $< .
89 encnames.c wchar.c : % : $(backend_src)/utils/mb/%
90 rm -f $@ && $(LN_S) $< .
93 distprep: $(srcdir)/libpq-dist.rc
95 libpq.rc $(srcdir)/libpq-dist.rc: libpq.rc.in
96 sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
98 # Depend on Makefile.global to force rebuild on re-run of configure.
99 # (But libpq-dist.rc is shipped in the distribution for shell-less
100 # installations and is only updated by distprep.)
101 libpq.rc: $(top_builddir)/src/Makefile.global
103 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
105 $(top_builddir)/src/port/pg_config_paths.h:
106 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
108 install: all installdirs install-lib
109 $(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
110 $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
111 $(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
112 $(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
113 $(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
115 installdirs: installdirs-lib
116 $(mkinstalldirs) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)'
118 uninstall: uninstall-lib
119 rm -f '$(DESTDIR)$(includedir)/libpq-fe.h'
120 rm -f '$(DESTDIR)$(includedir)/libpq-events.h'
121 rm -f '$(DESTDIR)$(includedir_internal)/libpq-int.h'
122 rm -f '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h'
123 rm -f '$(DESTDIR)$(datadir)/pg_service.conf.sample'
125 clean distclean: clean-lib
126 rm -f $(OBJS) pg_config_paths.h crypt.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
127 # Might be left over from a Win32 client-only build
128 rm -f pg_config_paths.h
130 maintainer-clean: distclean maintainer-clean-lib
131 rm -f $(srcdir)/libpq-dist.rc