OSDN Git Service

Set psql client encoding from locale by default
[pg-rex/syncrep.git] / src / interfaces / libpq / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for src/interfaces/libpq library
4 #
5 # Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # src/interfaces/libpq/Makefile
9 #
10 #-------------------------------------------------------------------------
11
12 subdir = src/interfaces/libpq
13 top_builddir = ../../..
14 include $(top_builddir)/src/Makefile.global
15
16
17 # shared library parameters
18 NAME= pq
19 SO_MAJOR_VERSION= 5
20 SO_MINOR_VERSION= 4
21
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)
25 endif
26
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=)
31
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 \
36         libpq-events.o
37 # libpgport C files we always use
38 OBJS += chklocale.o 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))
41 # backend/libpq
42 OBJS += ip.o md5.o
43 # utils/mb
44 OBJS += encnames.o wchar.o
45
46 ifeq ($(PORTNAME), cygwin)
47 override shlib = cyg$(NAME)$(DLSUFFIX)
48 endif
49
50 ifeq ($(PORTNAME), win32)
51 # pgsleep.o is from libpgport
52 OBJS += pgsleep.o win32.o libpqrc.o
53
54 libpqrc.o: libpq.rc
55         $(WINDRES) -i $< -o $@
56
57 ifeq ($(enable_thread_safety), yes)
58 OBJS += pthread-win32.o
59 endif
60 endif
61
62
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
65 # matter.)
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)
68 else
69 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
70 endif
71 ifeq ($(PORTNAME), win32)
72 SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
73 endif
74
75 SHLIB_EXPORTS = exports.txt
76
77 all: all-lib
78
79 # Shared library stuff
80 include $(top_srcdir)/src/Makefile.shlib
81 backend_src = $(top_srcdir)/src/backend
82
83
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).
90
91 chklocale.c 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) $< .
93
94 ip.c md5.c: % : $(backend_src)/libpq/%
95         rm -f $@ && $(LN_S) $< .
96
97 encnames.c wchar.c: % : $(backend_src)/utils/mb/%
98         rm -f $@ && $(LN_S) $< .
99
100
101 distprep: libpq-dist.rc
102
103 libpq.rc libpq-dist.rc: libpq.rc.in
104         sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
105
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
110
111 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
112
113 $(top_builddir)/src/port/pg_config_paths.h:
114         $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
115
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'
122
123 installdirs: installdirs-lib
124         $(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)'
125
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'
132
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 chklocale.c crypt.c getaddrinfo.c inet_aton.c open.c snprintf.c strerror.c strlcpy.c win32error.c
139         rm -f pgsleep.c 
140         rm -f md5.c ip.c
141         rm -f encnames.c wchar.c
142
143 maintainer-clean: distclean maintainer-clean-lib
144         rm -f libpq-dist.rc