@@ -203,6 +203,112 @@ pg_test_mod_args = pg_mod_args + {
203
203
204
204
205
205
206
+ ###############################################################
207
+ # Define a .pc file that can be used to build server extensions
208
+ ###############################################################
209
+
210
+ pg_ext_vars = []
211
+ pg_ext_vars_inst = []
212
+ pg_ext_vars_uninst = []
213
+
214
+ pg_ext_cflags = pg_mod_c_args + cppflags
215
+ pg_ext_libs = [backend_mod_deps, thread_dep, ldflags, ldflags_mod]
216
+ pg_ext_subdirs = ['' ]
217
+
218
+ # Compute directories to add include directories to the .pc files for.
219
+ # This is a bit more complicated due to port/win32 etc.
220
+ i = 0
221
+ foreach incdir : postgres_inc_d
222
+ if fs.is_absolute(incdir)
223
+ # an absolute path from -Dextra_include_dirs
224
+ pg_ext_cflags += ' -I@0@' .format(incdir)
225
+ continue
226
+ elif incdir.startswith(' src/include' )
227
+ subincdir = dir_include_pkg_rel / ' server' / incdir.split(' src/include/' ).get(1 , '' )
228
+ else
229
+ subincdir = ''
230
+ endif
231
+ pg_ext_subdirs += subincdir
232
+
233
+ # Add directories in source / build dir containing headers to cflags for the
234
+ # -uninstalled.pc. Older versions of pkg-config complain if a referenced
235
+ # variable is not defined, so we emit an empty one for the installed .pc
236
+ # file.
237
+ pg_ext_vars += [
238
+ ' build_inc@0@=""' .format(i),
239
+ ' src_inc@0@=""' .format(i),
240
+ ]
241
+ pg_ext_vars_uninst += [
242
+ ' build_inc@0@=-I${prefix}/@1@' .format(i, incdir),
243
+ ' src_inc@0@=-I${srcdir}/@1@' .format(i, incdir),
244
+ ]
245
+ pg_ext_cflags += [
246
+ ' ${build_inc@0@}' .format(i),
247
+ ' ${src_inc@0@}' .format(i)
248
+ ]
249
+
250
+ i += 1
251
+ endforeach
252
+
253
+
254
+ # Extension modules should likely also use -fwrapv etc. But it it's a bit odd
255
+ # to expose it to a .pc file?
256
+ pg_ext_cflags += cflags
257
+
258
+ # Directories for extensions to install into
259
+ # XXX: more needed
260
+ pg_ext_vars += ' pkglibdir=${prefix}/@0@' .format(dir_lib_pkg)
261
+ pg_ext_vars += ' dir_mod=${pkglibdir}'
262
+ pg_ext_vars += ' dir_data=${prefix}/@0@' .format(dir_data_extension)
263
+ # referenced on some platforms, via mod_link_with_dir
264
+ pg_ext_vars += ' bindir=${prefix}/@0@' .format(dir_bin)
265
+
266
+ # XXX: Define variables making it easy to define tests, too
267
+
268
+ # Some platforms need linker flags to link with binary, they are the same
269
+ # between building with meson and .pc file, except that we have have to
270
+ # reference a variable to make it work for both normal and -uninstalled .pc
271
+ # files.
272
+ if mod_link_args_fmt.length() != 0
273
+ assert (link_with_inst != '' )
274
+ assert (link_with_uninst != '' )
275
+
276
+ pg_ext_vars_inst += ' mod_link_with=@0@' .format(link_with_inst)
277
+ pg_ext_vars_uninst += ' mod_link_with=@0@' .format(link_with_uninst)
278
+
279
+ foreach el : mod_link_args_fmt
280
+ pg_ext_libs += el.format(' ${mod_link_with}' )
281
+ endforeach
282
+ endif
283
+
284
+ # main .pc to build extensions
285
+ pkgconfig.generate(
286
+ name : ' postgresql-extension' ,
287
+ description : ' PostgreSQL Extension Support' ,
288
+ url : pg_url,
289
+
290
+ subdirs : pg_ext_subdirs,
291
+ libraries : pg_ext_libs,
292
+ extra_cflags : pg_ext_cflags,
293
+
294
+ variables : pg_ext_vars + pg_ext_vars_inst,
295
+ uninstalled_variables : pg_ext_vars + pg_ext_vars_uninst,
296
+ )
297
+
298
+ # a .pc depending on the above, but with all our warnings enabled
299
+ pkgconfig.generate(
300
+ name : <
8670
span class="pl-s">' postgresql-extension-warnings' ,
301
+ description : ' PostgreSQL Extension Support - Compiler Warnings' ,
302
+ requires : ' postgresql-extension' ,
303
+ url : pg_url,
304
+ extra_cflags : cflags_warn,
305
+
306
+ variables : pg_ext_vars + pg_ext_vars_inst,
307
+ uninstalled_variables : pg_ext_vars + pg_ext_vars_uninst,
308
+ )
309
+
310
+
311
+
206
312
# Shared modules that, on some system, link against the server binary. Only
207
313
# enter these after we defined the server build.
208
314
0 commit comments