]> granicus.if.org Git - postgresql/blob - src/interfaces/libpq/Makefile
Clean up MinGW def file generation
[postgresql] / src / interfaces / libpq / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for src/interfaces/libpq library
4 #
5 # Portions Copyright (c) 1996-2019, 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= $(MAJORVERSION)
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 # The MSVC build system scrapes OBJS from this file.  If you change any of
28 # the conditional additions of files to OBJS, update Mkvcbuild.pm to match.
29
30 OBJS=   fe-auth.o fe-auth-scram.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
31         fe-protocol2.o fe-protocol3.o pqexpbuffer.o fe-secure.o \
32         legacy-pqsignal.o libpq-events.o
33
34 # src/backend/utils/mb
35 OBJS += encnames.o wchar.o
36
37 ifeq ($(with_openssl),yes)
38 OBJS += fe-secure-openssl.o fe-secure-common.o
39 endif
40
41 ifeq ($(with_gssapi),yes)
42 OBJS += fe-gssapi-common.o fe-secure-gssapi.o
43 endif
44
45 ifeq ($(PORTNAME), cygwin)
46 override shlib = cyg$(NAME)$(DLSUFFIX)
47 endif
48
49 ifeq ($(PORTNAME), win32)
50 OBJS += win32.o libpqrc.o
51
52 libpqrc.o: libpq.rc
53         $(WINDRES) -i $< -o $@
54
55 ifeq ($(enable_thread_safety), yes)
56 OBJS += pthread-win32.o
57 endif
58 endif
59
60
61 # Add libraries that libpq depends (or might depend) on into the
62 # shared library link.  (The order in which you list them here doesn't
63 # matter.)  Note that we filter out -lpgcommon and -lpgport from LIBS and
64 # instead link with -lpgcommon_shlib and -lpgport_shlib, to get object files
65 # that are built correctly for use in a shlib.
66 SHLIB_LINK_INTERNAL = -lpgcommon_shlib -lpgport_shlib
67 ifneq ($(PORTNAME), win32)
68 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi_krb5 -lgss -lgssapi -lssl -lsocket -lnsl -lresolv -lintl -lm, $(LIBS)) $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
69 else
70 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl -lm $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
71 endif
72 ifeq ($(PORTNAME), win32)
73 SHLIB_LINK += -lshell32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
74 endif
75
76 SHLIB_EXPORTS = exports.txt
77
78 all: all-lib
79
80 all-lib: | submake-libpgport
81
82 # Shared library stuff
83 include $(top_srcdir)/src/Makefile.shlib
84 backend_src = $(top_srcdir)/src/backend
85
86
87 # We use a few backend modules verbatim, but since we need
88 # to compile with appropriate options to build a shared lib, we can't
89 # use the same object files built for the backend.
90 # Instead, symlink the source files in here and build our own object files.
91 # When you add a file here, remember to add it in the "clean" target below.
92
93 encnames.c wchar.c: % : $(backend_src)/utils/mb/%
94         rm -f $@ && $(LN_S) $< .
95
96
97 distprep: libpq-dist.rc
98
99 libpq.rc libpq-dist.rc: libpq.rc.in
100         sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
101
102 # Depend on Makefile.global to force rebuild on re-run of configure.
103 # (But libpq-dist.rc is shipped in the distribution for shell-less
104 # installations and is only updated by distprep.)
105 libpq.rc: $(top_builddir)/src/Makefile.global
106
107 # Make dependencies on pg_config_paths.h visible, too.
108 fe-connect.o: fe-connect.c $(top_builddir)/src/port/pg_config_paths.h
109 fe-misc.o: fe-misc.c $(top_builddir)/src/port/pg_config_paths.h
110
111 $(top_builddir)/src/port/pg_config_paths.h:
112         $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
113
114 install: all installdirs install-lib
115         $(INSTALL_DATA) $(srcdir)/libpq-fe.h '$(DESTDIR)$(includedir)'
116         $(INSTALL_DATA) $(srcdir)/libpq-events.h '$(DESTDIR)$(includedir)'
117         $(INSTALL_DATA) $(srcdir)/libpq-int.h '$(DESTDIR)$(includedir_internal)'
118         $(INSTALL_DATA) $(srcdir)/pqexpbuffer.h '$(DESTDIR)$(includedir_internal)'
119         $(INSTALL_DATA) $(srcdir)/pg_service.conf.sample '$(DESTDIR)$(datadir)/pg_service.conf.sample'
120
121 installcheck:
122         $(MAKE) -C test $@
123
124 installdirs: installdirs-lib
125         $(MKDIR_P) '$(DESTDIR)$(includedir)' '$(DESTDIR)$(includedir_internal)' '$(DESTDIR)$(datadir)'
126
127 uninstall: uninstall-lib
128         rm -f '$(DESTDIR)$(includedir)/libpq-fe.h'
129         rm -f '$(DESTDIR)$(includedir)/libpq-events.h'
130         rm -f '$(DESTDIR)$(includedir_internal)/libpq-int.h'
131         rm -f '$(DESTDIR)$(includedir_internal)/pqexpbuffer.h'
132         rm -f '$(DESTDIR)$(datadir)/pg_service.conf.sample'
133
134 clean distclean: clean-lib
135         $(MAKE) -C test $@
136         rm -f $(OBJS) pthread.h libpq.rc
137 # Might be left over from a Win32 client-only build
138         rm -f pg_config_paths.h
139 # Remove files we (may have) symlinked in from other places
140         rm -f encnames.c wchar.c
141
142 maintainer-clean: distclean
143         $(MAKE) -C test $@
144         rm -f libpq-dist.rc