jsonpath scanner: reentrant scanner
[pgsql.git] / src / common / Makefile
blob1e2b91c83c4c440f100daf6bc99e18d5a26beb0e
1 #-------------------------------------------------------------------------
3 # Makefile
4 # Makefile for src/common
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.
10 # This makefile generates three outputs:
12 # libpgcommon.a - contains object files with FRONTEND defined,
13 # for use by client applications
15 # libpgcommon_shlib.a - contains object files with FRONTEND defined,
16 # built suitably for use in shared libraries; for use
17 # by frontend libraries
19 # libpgcommon_srv.a - contains object files without FRONTEND defined,
20 # for use only by the backend
22 # IDENTIFICATION
23 # src/common/Makefile
25 #-------------------------------------------------------------------------
27 subdir = src/common
28 top_builddir = ../..
29 include $(top_builddir)/src/Makefile.global
31 # don't include subdirectory-path-dependent -I and -L switches
32 STD_CPPFLAGS := $(filter-out -I$(top_srcdir)/src/include -I$(top_builddir)/src/include,$(CPPFLAGS))
33 STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/common -L$(top_builddir)/src/port,$(LDFLAGS))
34 override CPPFLAGS += -DVAL_CC="\"$(CC)\""
35 override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
36 override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
37 override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
38 override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
39 override CPPFLAGS += -DVAL_LDFLAGS_EX="\"$(LDFLAGS_EX)\""
40 override CPPFLAGS += -DVAL_LDFLAGS_SL="\"$(LDFLAGS_SL)\""
41 override CPPFLAGS += -DVAL_LIBS="\"$(LIBS)\""
43 override CPPFLAGS := -DFRONTEND -I. -I$(top_srcdir)/src/common $(CPPFLAGS)
44 LIBS += $(PTHREAD_LIBS)
46 OBJS_COMMON = \
47 archive.o \
48 base64.o \
49 binaryheap.o \
50 blkreftable.o \
51 checksum_helper.o \
52 compression.o \
53 config_info.o \
54 controldata_utils.o \
55 d2s.o \
56 encnames.o \
57 exec.o \
58 f2s.o \
59 file_perm.o \
60 file_utils.o \
61 hashfn.o \
62 ip.o \
63 jsonapi.o \
64 keywords.o \
65 kwlookup.o \
66 link-canary.o \
67 md5_common.o \
68 parse_manifest.o \
69 percentrepl.o \
70 pg_get_line.o \
71 pg_lzcompress.o \
72 pg_prng.o \
73 pgfnames.o \
74 psprintf.o \
75 relpath.o \
76 rmtree.o \
77 saslprep.o \
78 scram-common.o \
79 string.o \
80 stringinfo.o \
81 unicode_case.o \
82 unicode_category.o \
83 unicode_norm.o \
84 username.o \
85 wait_error.o \
86 wchar.o
88 ifeq ($(with_ssl),openssl)
89 OBJS_COMMON += \
90 cryptohash_openssl.o \
91 hmac_openssl.o
92 else
93 OBJS_COMMON += \
94 cryptohash.o \
95 hmac.o \
96 md5.o \
97 sha1.o \
98 sha2.o
99 endif
101 # A few files are currently only built for frontend, not server.
102 # logging.c is excluded from OBJS_FRONTEND_SHLIB (shared library) as
103 # a matter of policy, because it is not appropriate for general purpose
104 # libraries such as libpq to report errors directly. fe_memutils.c is
105 # excluded because libpq must not exit() on allocation failure.
107 # The excluded files for _shlib builds are pulled into their own static
108 # library, for the benefit of test programs that need not follow the
109 # shlib rules.
110 OBJS_FRONTEND_SHLIB = \
111 $(OBJS_COMMON) \
112 restricted_token.o \
113 sprompt.o
114 OBJS_EXCLUDED_SHLIB = \
115 fe_memutils.o \
116 logging.o
117 OBJS_FRONTEND = \
118 $(OBJS_FRONTEND_SHLIB) \
119 $(OBJS_EXCLUDED_SHLIB)
121 # foo.o, foo_shlib.o, and foo_srv.o are all built from foo.c
122 OBJS_SHLIB = $(OBJS_FRONTEND_SHLIB:%.o=%_shlib.o)
123 OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
125 # where to find gen_keywordlist.pl and subsidiary files
126 TOOLSDIR = $(top_srcdir)/src/tools
127 GEN_KEYWORDLIST = $(PERL) -I $(TOOLSDIR) $(TOOLSDIR)/gen_keywordlist.pl
128 GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
130 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a libpgcommon_excluded_shlib.a
132 # libpgcommon is needed by some contrib
133 install: all installdirs
134 $(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
135 $(INSTALL_STLIB) libpgcommon_shlib.a '$(DESTDIR)$(libdir)/libpgcommon_shlib.a'
137 installdirs:
138 $(MKDIR_P) '$(DESTDIR)$(libdir)'
140 uninstall:
141 rm -f '$(DESTDIR)$(libdir)/libpgcommon.a'
142 rm -f '$(DESTDIR)$(libdir)/libpgcommon_shlib.a'
144 libpgcommon.a: $(OBJS_FRONTEND)
145 rm -f $@
146 $(AR) $(AROPT) $@ $^
149 # Files in libpgcommon.a should use/export the "xxx_private" versions
150 # of pg_char_to_encoding() and friends.
152 $(OBJS_FRONTEND): CPPFLAGS += -DUSE_PRIVATE_ENCODING_FUNCS
156 # Shared library versions of object files
159 libpgcommon_shlib.a: $(OBJS_SHLIB)
160 rm -f $@
161 $(AR) $(AROPT) $@ $^
163 # The JSON API normally exits on out-of-memory; disable that behavior for shared
164 # library builds. This requires libpq's pqexpbuffer.h.
165 jsonapi_shlib.o: override CPPFLAGS += -DJSONAPI_USE_PQEXPBUFFER
166 jsonapi_shlib.o: override CPPFLAGS += -I$(libpq_srcdir)
168 # Because this uses its own compilation rule, it doesn't use the
169 # dependency tracking logic from Makefile.global. To make sure that
170 # dependency tracking works anyway for the *_shlib.o files, depend on
171 # their *.o siblings as well, which do have proper dependencies. It's
172 # a hack that might fail someday if there is a *_shlib.o without a
173 # corresponding *.o, but there seems little reason for that.
174 %_shlib.o: %.c %.o
175 $(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) -c $< -o $@
177 libpgcommon_excluded_shlib.a: $(OBJS_EXCLUDED_SHLIB)
178 rm -f $@
179 $(AR) $(AROPT) $@ $^
182 # Server versions of object files
185 libpgcommon_srv.a: $(OBJS_SRV)
186 rm -f $@
187 $(AR) $(AROPT) $@ $^
189 # Because this uses its own compilation rule, it doesn't use the
190 # dependency tracking logic from Makefile.global. To make sure that
191 # dependency tracking works anyway for the *_srv.o files, depend on
192 # their *.o siblings as well, which do have proper dependencies. It's
193 # a hack that might fail someday if there is a *_srv.o without a
194 # corresponding *.o, but it works for now.
195 %_srv.o: %.c %.o
196 $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
198 # generate SQL keyword lookup table to be included into keywords*.o.
199 kwlist_d.h: $(top_srcdir)/src/include/parser/kwlist.h $(GEN_KEYWORDLIST_DEPS)
200 $(GEN_KEYWORDLIST) --extern $<
202 # Dependencies of keywords*.o need to be managed explicitly to make sure
203 # that you don't get broken parsing code, even in a non-enable-depend build.
204 keywords.o keywords_shlib.o keywords_srv.o: kwlist_d.h
206 # The code imported from Ryu gets a pass on declaration-after-statement,
207 # in order to keep it more closely aligned with its upstream.
208 RYU_FILES = d2s.o f2s.o
209 RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
211 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
213 clean distclean:
214 rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a libpgcommon_excluded_shlib.a
215 rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
216 rm -f kwlist_d.h