@@ -87,6 +87,7 @@ shlib_bare = lib$(NAME)$(DLSUFFIX)
87
87
# Testing the soname variable is a reliable way to determine whether a
88
88
# linkable library is being built.
89
89
soname = $(shlib_major)
90
+ pkgconfigdir = $(libdir)/pkgconfig
90
91
else
91
92
# Naming convention for dynamically loadable modules
92
93
shlib = $(NAME)$(DLSUFFIX)
@@ -305,6 +306,7 @@ all-lib: all-shared-lib
305
306
ifdef soname
306
307
# no static library when building a dynamically loadable module
307
308
all-lib: all-static-lib
309
+ all-lib: lib$(NAME).pc
308
310
endif
309
311
310
312
all-static-lib: $(stlib)
@@ -388,6 +390,23 @@ $(stlib): $(shlib) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
388
390
endif # PORTNAME == cygwin || PORTNAME == win32
389
391
390
392
393
+ %.pc: $(MAKEFILE_LIST)
394
+ echo 'Name: lib$(NAME)' >$@
395
+ echo 'Description: PostgreSQL lib$(NAME) library' >>$@
396
+ echo 'Url: http://www.postgresql.org/' >>$@
397
+ echo 'Version: $(VERSION)' >>$@
398
+ echo 'Requires: ' >>$@
399
+ echo 'Requires.private: $(PKG_CONFIG_REQUIRES_PRIVATE)' >>$@
400
+ echo 'Cflags: -I$(includedir)' >>$@
401
+ echo 'Libs: -L$(libdir) -l$(NAME)' >>$@
402
+ # Record -L flags that the user might have passed in to the PostgreSQL
403
+ # build to locate third-party libraries (e.g., ldap, ssl). Filter out
404
+ # those that point inside the build or source tree. Use sort to
405
+ # remove duplicates. Also record the -l flags necessary for static
406
+ # linking, but not those already covered by Requires.private.
407
+ echo 'Libs.private: $(sort $(filter-out -L.% -L$(top_srcdir)/%,$(filter -L%,$(LDFLAGS) $(SHLIB_LINK)))) $(filter-out $(PKG_CONFIG_REQUIRES_PRIVATE:lib%=-l%),$(filter -l%,$(SHLIB_LINK)))' >>$@
408
+
409
+
391
410
# We need several not-quite-identical variants of .DEF files to build
392
411
# DLLs for Windows. These are made from the single source file
393
412
# exports.txt. Since we can't assume that Windows boxes will have
@@ -430,8 +449,12 @@ endif # SHLIB_EXPORTS
430
449
install-lib: install-lib-shared
431
450
ifdef soname
432
451
install-lib: install-lib-static
452
+ install-lib: install-lib-pc
433
453
endif
434
454
455
+ install-lib-pc: lib$(NAME).pc installdirs-lib
456
+ $(INSTALL_DATA) $< '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
457
+
435
458
install-lib-static: $(stlib) installdirs-lib
436
459
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
437
460
ifeq ($(PORTNAME), darwin)
@@ -467,7 +490,7 @@ endif
467
490
468
491
installdirs-lib:
469
492
ifdef soname
470
- $(MKDIR_P) '$(DESTDIR)$(libdir)'
493
+ $(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)'
471
494
else
472
495
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
473
496
endif
@@ -483,7 +506,8 @@ ifdef soname
483
506
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
484
507
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
485
508
'$(DESTDIR)$(libdir)/$(shlib_major)' \
486
- '$(DESTDIR)$(libdir)/$(shlib)'
509
+ '$(DESTDIR)$(libdir)/$(shlib)' \
510
+ '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
487
511
else # no soname
488
512
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
489
513
endif # no soname
@@ -495,7 +519,7 @@ endif # no soname
495
519
496
520
.PHONY: clean-lib
497
521
clean-lib:
498
- rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file)
522
+ rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file) lib$(NAME).pc
499
523
500
524
ifneq (,$(SHLIB_EXPORTS))
501
525
maintainer-clean-lib:
0 commit comments