3
3
# Makefile
4
4
# Makefile for src/common
5
5
#
6
- # This makefile generates two outputs:
6
+ # These files are used by the Postgres backend, and also by frontend
7
+ # programs. These files provide common functionality that isn't directly
8
+ # concerned with portability and thus doesn't belong in src/port.
9
+ #
10
+ # This makefile generates three outputs:
7
11
#
8
12
# libpgcommon.a - contains object files with FRONTEND defined,
9
13
# for use by client applications
10
14
#
11
- # libpgcommon_srv.a - contains object files without FRONTEND defined,
12
- # for use only by the backend binaries
15
+ # libpgcommon_shlib.a - contains object files with FRONTEND defined,
16
+ # built suitably for use in shared libraries; for use
17
+ # by frontend libraries
13
18
#
14
- # You can also symlink/copy individual source files from this directory,
15
- # to compile with different options. (libpq does that, because it needs
16
- # to use -fPIC on some platforms.)
19
+ # libpgcommon_srv.a - contains object files without FRONTEND defined,
20
+ # for use only by the backend
17
21
#
18
22
# IDENTIFICATION
19
23
# src/common/Makefile
52
56
OBJS_COMMON += sha2.o
53
57
endif
54
58
59
+ # A few files are currently only built for frontend, not server
55
60
OBJS_FRONTEND = $(OBJS_COMMON ) fe_memutils.o file_utils.o restricted_token.o
56
61
62
+ # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
63
+ OBJS_SHLIB = $(OBJS_FRONTEND:%.o=%_shlib.o )
57
64
OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o )
58
65
59
- all : libpgcommon.a libpgcommon_srv.a
66
+ all : libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
60
67
61
68
# libpgcommon is needed by some contrib
62
69
install : all installdirs
63
70
$(INSTALL_STLIB ) libpgcommon.a ' $(DESTDIR)$(libdir)/libpgcommon.a'
71
+ $(INSTALL_STLIB ) libpgcommon_shlib.a ' $(DESTDIR)$(libdir)/libpgcommon_shlib.a'
64
72
65
73
installdirs :
66
74
$(MKDIR_P ) ' $(DESTDIR)$(libdir)'
67
75
68
76
uninstall :
69
77
rm -f ' $(DESTDIR)$(libdir)/libpgcommon.a'
78
+ rm -f ' $(DESTDIR)$(libdir)/libpgcommon_shlib.a'
70
79
71
80
libpgcommon.a : $(OBJS_FRONTEND )
72
81
rm -f $@
73
82
$(AR ) $(AROPT ) $@ $^
74
83
84
+ #
85
+ # Shared library versions of object files
86
+ #
87
+
88
+ libpgcommon_shlib.a : $(OBJS_SHLIB )
89
+ rm -f $@
90
+ $(AR ) $(AROPT ) $@ $^
91
+
92
+ # Because this uses its own compilation rule, it doesn't use the
93
+ # dependency tracking logic from Makefile.global. To make sure that
94
+ # dependency tracking works anyway for the *_shlib.o files, depend on
95
+ # their *.o siblings as well, which do have proper dependencies. It's
96
+ # a hack that might fail someday if there is a *_shlib.o without a
97
+ # corresponding *.o, but there seems little reason for that.
98
+ % _shlib.o : % .c % .o
99
+ $(CC ) $(CFLAGS ) $(CFLAGS_SL ) $(CPPFLAGS ) -c $< -o $@
100
+
75
101
#
76
102
# Server versions of object files
77
103
#
@@ -87,16 +113,18 @@ libpgcommon_srv.a: $(OBJS_SRV)
87
113
# a hack that might fail someday if there is a *_srv.o without a
88
114
# corresponding *.o, but it works for now.
89
115
% _srv.o : % .c % .o
90
- $(CC ) $(CFLAGS ) $(subst -DFRONTEND ,, $(CPPFLAGS ) ) -c $< -o $@
116
+ $(CC ) $(CFLAGS ) $(subst -DFRONTEND,, $(CPPFLAGS ) ) -c $< -o $@
91
117
92
118
# Dependencies of keywords.o need to be managed explicitly to make sure
93
119
# that you don't get broken parsing code, even in a non-enable-depend build.
94
- # Note that gram.h isn't required for the frontend version of keywords.o.
120
+ # Note that gram.h isn't required for the frontend versions of keywords.o.
95
121
$(top_builddir ) /src/include/parser/gram.h : $(top_srcdir ) /src/backend/parser/gram.y
96
122
$(MAKE ) -C $(top_builddir ) /src/backend $(top_builddir ) /src/include/parser/gram.h
97
123
98
124
keywords.o : $(top_srcdir ) /src/include/parser/kwlist.h
125
+ keywords_shlib.o : $(top_srcdir ) /src/include/parser/kwlist.h
99
126
keywords_srv.o : $(top_builddir ) /src/include/parser/gram.h $(top_srcdir ) /src/include/parser/kwlist.h
100
127
101
128
clean distclean maintainer-clean :
102
- rm -f libpgcommon.a libpgcommon_srv.a $(OBJS_FRONTEND ) $(OBJS_SRV )
129
+ rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
130
+ rm -f $(OBJS_FRONTEND ) $(OBJS_SHLIB ) $(OBJS_SRV )
0 commit comments