Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit64f8909

Browse files
committed
Add pkg-config files for libpq and ecpg libraries
This will hopefully be easier to use than pg_config for users who arealready used to the pkg-config interface. It also works better formulti-arch installations.reviewed by Tom Lane
1 parent3780fc6 commit64f8909

File tree

6 files changed

+62
-3
lines changed

6 files changed

+62
-3
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ lcov.info
2222
win32ver.rc
2323
*.exe
2424
lib*dll.def
25+
lib*.pc
2526

2627
# Local excludes in root directory
2728
/GNUmakefile

‎doc/src/sgml/ecpg.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5714,6 +5714,15 @@ cc -o myprog prog1.o prog2.o ... -lecpg
57145714
<literal>-L/usr/local/pgsql/lib</literal> to that command line.
57155715
</para>
57165716

5717+
<para>
5718+
You can
5719+
use <command>pg_config</command><indexterm><primary>pg_config</primary><secondary sortas="ecpg">with
5720+
ecpg</secondary></indexterm>
5721+
or <command>pkg-config</command><indexterm><primary>pkg-config</primary><secondary sortas="ecpg">with
5722+
ecpg</secondary></indexterm> with package name <literal>libecpg</literal> to
5723+
get the paths for your installation.
5724+
</para>
5725+
57175726
<para>
57185727
If you manage the build process of a larger project using
57195728
<application>make</application>, it might be convenient to include

‎doc/src/sgml/libpq.sgml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7640,6 +7640,18 @@ CPPFLAGS += -I/usr/local/pgsql/include
76407640
</screen>
76417641
</para>
76427642

7643+
<para>
7644+
If you
7645+
have <command>pkg-config</command><indexterm><primary>pkg-config</primary><secondary sortas="libpq">with
7646+
libpq</secondary></indexterm> installed, you can run instead:
7647+
<screen>
7648+
<prompt>$</prompt> pkg-config --cflags libpq
7649+
<computeroutput>-I/usr/local/include</computeroutput>
7650+
</screen>
7651+
Note that this will already include the <option>-I</option> in front of
7652+
the path.
7653+
</para>
7654+
76437655
<para>
76447656
Failure to specify the correct option to the compiler will
76457657
result in an error message such as:
@@ -7674,6 +7686,15 @@ cc -o testprog testprog1.o testprog2.o -L/usr/local/pgsql/lib -lpq
76747686
</screen>
76757687
</para>
76767688

7689+
<para>
7690+
Or again use <command>pkg-config</command>:
7691+
<screen>
7692+
<prompt>$</prompt> pkg-config --libs libpq
7693+
<computeroutput>-L/usr/local/pgsql/lib -lpq</computeroutput>
7694+
</screen>
7695+
Note again that this prints the full options, not only the path.
7696+
</para>
7697+
76777698
<para>
76787699
Error messages that point to problems in this area could look like
76797700
the following:

‎src/Makefile.shlib

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ shlib_bare= lib$(NAME)$(DLSUFFIX)
8787
# Testing the soname variable is a reliable way to determine whether a
8888
# linkable library is being built.
8989
soname= $(shlib_major)
90+
pkgconfigdir = $(libdir)/pkgconfig
9091
else
9192
# Naming convention for dynamically loadable modules
9293
shlib= $(NAME)$(DLSUFFIX)
@@ -305,6 +306,7 @@ all-lib: all-shared-lib
305306
ifdef soname
306307
# no static library when building a dynamically loadable module
307308
all-lib: all-static-lib
309+
all-lib: lib$(NAME).pc
308310
endif
309311

310312
all-static-lib: $(stlib)
@@ -388,6 +390,23 @@ $(stlib): $(shlib) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
388390
endif # PORTNAME == cygwin || PORTNAME == win32
389391

390392

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+
391410
# We need several not-quite-identical variants of .DEF files to build
392411
# DLLs for Windows. These are made from the single source file
393412
# exports.txt. Since we can't assume that Windows boxes will have
@@ -430,8 +449,12 @@ endif # SHLIB_EXPORTS
430449
install-lib: install-lib-shared
431450
ifdef soname
432451
install-lib: install-lib-static
452+
install-lib: install-lib-pc
433453
endif
434454

455+
install-lib-pc: lib$(NAME).pc installdirs-lib
456+
$(INSTALL_DATA) $< '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
457+
435458
install-lib-static: $(stlib) installdirs-lib
436459
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
437460
ifeq ($(PORTNAME), darwin)
@@ -467,7 +490,7 @@ endif
467490

468491
installdirs-lib:
469492
ifdef soname
470-
$(MKDIR_P) '$(DESTDIR)$(libdir)'
493+
$(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)'
471494
else
472495
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
473496
endif
@@ -483,7 +506,8 @@ ifdef soname
483506
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
484507
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
485508
'$(DESTDIR)$(libdir)/$(shlib_major)' \
486-
'$(DESTDIR)$(libdir)/$(shlib)'
509+
'$(DESTDIR)$(libdir)/$(shlib)' \
510+
'$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
487511
else # no soname
488512
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
489513
endif # no soname
@@ -495,7 +519,7 @@ endif # no soname
495519

496520
.PHONY: clean-lib
497521
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
499523

500524
ifneq (,$(SHLIB_EXPORTS))
501525
maintainer-clean-lib:

‎src/interfaces/ecpg/compatlib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ LIBS := $(filter-out -lpgport, $(LIBS))
3232

3333
OBJS= informix.o$(filter snprintf.o,$(LIBOBJS))
3434

35+
PKG_CONFIG_REQUIRES_PRIVATE = libecpg libpgtypes
36+
3537
all: all-lib
3638

3739
.PHONY: submake-ecpglib submake-pgtypeslib

‎src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ ifeq ($(PORTNAME), win32)
4343
SHLIB_LINK += -lshfolder
4444
endif
4545

46+
PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
47+
4648
all: all-lib
4749

4850
.PHONY: submake-pgtypeslib

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp