1 #-------------------------------------------------------------------------
3 # Makefile for src/interfaces/libpq library
5 # Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.140 2005/12/09 21:19:36 petere Exp $
10 #-------------------------------------------------------------------------
12 subdir = src/interfaces/libpq
13 top_builddir = ../../..
14 include $(top_builddir)/src/Makefile.global
17 # shared library parameters
23 override CPPFLAGS := -DFRONTEND -I$(srcdir) $(CPPFLAGS) -I$(top_builddir)/src/port
24 ifneq ($(PORTNAME), win32)
25 override CFLAGS += $(PTHREAD_CFLAGS)
28 # Need to recomple any libpgport object files
29 LIBS := $(patsubst -lpgport,, $(LIBS))
31 OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
32 fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
33 md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
34 $(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o, $(LIBOBJS))
36 ifeq ($(PORTNAME), cygwin)
37 override shlib = cyg$(NAME)$(DLSUFFIX)
40 ifeq ($(PORTNAME), win32)
41 OBJS += win32.o libpqrc.o
42 DLL_DEFFILE=libpqdll.def
45 windres -i libpq.rc -o libpqrc.o
47 ifeq ($(enable_thread_safety), yes)
48 OBJS += pthread-win32.o
53 # Add libraries that libpq depends (or might depend) on into the
54 # shared library link. (The order in which you list them here doesn't
56 ifneq ($(PORTNAME), win32)
57 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(PTHREAD_LIBS)
59 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS))
61 ifeq ($(PORTNAME), win32)
62 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
66 all: def-files $(srcdir)/libpq.rc all-lib
68 # Shared library stuff
69 include $(top_srcdir)/src/Makefile.shlib
70 backend_src = $(top_srcdir)/src/backend
73 # We use several backend modules verbatim, but since we need to
74 # compile with appropriate options to build a shared lib, we can't
75 # necessarily use the same object files as the backend uses. Instead,
76 # symlink the source files in here and build our own object file.
77 # For port modules, this only happens if configure decides the module
78 # is needed (see filter hack in OBJS, above).
80 crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c: % : $(top_srcdir)/src/port/%
81 rm -f $@ && $(LN_S) $< .
83 md5.c ip.c: % : $(backend_src)/libpq/%
84 rm -f $@ && $(LN_S) $< .
86 encnames.c wchar.c : % : $(backend_src)/utils/mb/%
87 rm -f $@ && $(LN_S) $< .
90 # We need several not-quite-identical variants of .DEF files to build libpq
91 # DLLs for Windows. These are made from the single source file exports.txt.
92 # Since we can't assume that Windows boxes will have sed, the .DEF files are
93 # always built and included in distribution tarballs.
95 distprep: def-files $(srcdir)/libpq.rc
99 def-files: $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def
101 $(srcdir)/libpqdll.def: exports.txt
102 echo '; DEF file for MS VC++' > $@
103 echo 'LIBRARY LIBPQ' >> $@
104 echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
106 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' < $< >> $@
108 $(srcdir)/libpqddll.def: exports.txt
109 echo '; DEF file for MS VC++' > $@
110 echo 'LIBRARY LIBPQD' >> $@
111 echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
113 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1@ \2/' < $< >> $@
115 $(srcdir)/blibpqdll.def: exports.txt
116 echo '; DEF file for Borland C++ Builder' > $@
117 echo 'LIBRARY BLIBPQ' >> $@
118 echo 'DESCRIPTION "PostgreSQL Client Library"' >> $@
120 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ _\1@ \2/' < $< >> $@
122 echo '; Aliases for MS compatible names' >> $@
123 sed -e '/^#/d' -e 's/^\(.* \)\([0-9][0-9]*\)/ \1= _\1/' < $< | sed 's/ *$$//' >> $@
125 # depend on Makefile.global to force rebuild on re-run of configure
126 $(srcdir)/libpq.rc: libpq.rc.in $(top_builddir)/src/Makefile.global
127 sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' < $< > $@
129 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
131 $(top_builddir)/src/port/pg_config_paths.h:
132 $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
134 install: all installdirs install-lib
135 $(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
136 $(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
137 $(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
138 $(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
141 $(mkinstalldirs) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)'
143 uninstall: uninstall-lib
144 rm -f '$(DESTDIR)$(includedir)/libpq-fe.h' '$(DESTDIR)$(includedir_internal)/libpq-int.h' '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h' '$(DESTDIR)$(datadir)/pg_service.conf.sample'
146 clean distclean: clean-lib
147 rm -f $(OBJS) pg_config_paths.h crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c md5.c ip.c encnames.c wchar.c pthread.h
148 rm -f pg_config_paths.h # Might be left over from a Win32 client-only build
150 maintainer-clean: distclean
151 rm -f $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def $(srcdir)/libpq.rc