Commit 64f89090 authored by Peter Eisentraut's avatar Peter Eisentraut

Add pkg-config files for libpq and ecpg libraries

This will hopefully be easier to use than pg_config for users who are
already used to the pkg-config interface.  It also works better for
multi-arch installations.

reviewed by Tom Lane
parent 3780fc67
...@@ -22,6 +22,7 @@ lcov.info ...@@ -22,6 +22,7 @@ lcov.info
win32ver.rc win32ver.rc
*.exe *.exe
lib*dll.def lib*dll.def
lib*.pc
# Local excludes in root directory # Local excludes in root directory
/GNUmakefile /GNUmakefile
......
...@@ -5714,6 +5714,15 @@ cc -o myprog prog1.o prog2.o ... -lecpg ...@@ -5714,6 +5714,15 @@ cc -o myprog prog1.o prog2.o ... -lecpg
<literal>-L/usr/local/pgsql/lib</literal> to that command line. <literal>-L/usr/local/pgsql/lib</literal> to that command line.
</para> </para>
<para>
You can
use <command>pg_config</command><indexterm><primary>pg_config</primary><secondary sortas="ecpg">with
ecpg</secondary></indexterm>
or <command>pkg-config</command><indexterm><primary>pkg-config</primary><secondary sortas="ecpg">with
ecpg</secondary></indexterm> with package name <literal>libecpg</literal> to
get the paths for your installation.
</para>
<para> <para>
If you manage the build process of a larger project using If you manage the build process of a larger project using
<application>make</application>, it might be convenient to include <application>make</application>, it might be convenient to include
......
...@@ -7640,6 +7640,18 @@ CPPFLAGS += -I/usr/local/pgsql/include ...@@ -7640,6 +7640,18 @@ CPPFLAGS += -I/usr/local/pgsql/include
</screen> </screen>
</para> </para>
<para>
If you
have <command>pkg-config</command><indexterm><primary>pkg-config</primary><secondary sortas="libpq">with
libpq</secondary></indexterm> installed, you can run instead:
<screen>
<prompt>$</prompt> pkg-config --cflags libpq
<computeroutput>-I/usr/local/include</computeroutput>
</screen>
Note that this will already include the <option>-I</option> in front of
the path.
</para>
<para> <para>
Failure to specify the correct option to the compiler will Failure to specify the correct option to the compiler will
result in an error message such as: result in an error message such as:
...@@ -7674,6 +7686,15 @@ cc -o testprog testprog1.o testprog2.o -L/usr/local/pgsql/lib -lpq ...@@ -7674,6 +7686,15 @@ cc -o testprog testprog1.o testprog2.o -L/usr/local/pgsql/lib -lpq
</screen> </screen>
</para> </para>
<para>
Or again use <command>pkg-config</command>:
<screen>
<prompt>$</prompt> pkg-config --libs libpq
<computeroutput>-L/usr/local/pgsql/lib -lpq</computeroutput>
</screen>
Note again that this prints the full options, not only the path.
</para>
<para> <para>
Error messages that point to problems in this area could look like Error messages that point to problems in this area could look like
the following: the following:
......
...@@ -87,6 +87,7 @@ shlib_bare = lib$(NAME)$(DLSUFFIX) ...@@ -87,6 +87,7 @@ shlib_bare = lib$(NAME)$(DLSUFFIX)
# Testing the soname variable is a reliable way to determine whether a # Testing the soname variable is a reliable way to determine whether a
# linkable library is being built. # linkable library is being built.
soname = $(shlib_major) soname = $(shlib_major)
pkgconfigdir = $(libdir)/pkgconfig
else else
# Naming convention for dynamically loadable modules # Naming convention for dynamically loadable modules
shlib = $(NAME)$(DLSUFFIX) shlib = $(NAME)$(DLSUFFIX)
...@@ -305,6 +306,7 @@ all-lib: all-shared-lib ...@@ -305,6 +306,7 @@ all-lib: all-shared-lib
ifdef soname ifdef soname
# no static library when building a dynamically loadable module # no static library when building a dynamically loadable module
all-lib: all-static-lib all-lib: all-static-lib
all-lib: lib$(NAME).pc
endif endif
all-static-lib: $(stlib) all-static-lib: $(stlib)
...@@ -388,6 +390,23 @@ $(stlib): $(shlib) $(DLL_DEFFILE) | $(SHLIB_PREREQS) ...@@ -388,6 +390,23 @@ $(stlib): $(shlib) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
endif # PORTNAME == cygwin || PORTNAME == win32 endif # PORTNAME == cygwin || PORTNAME == win32
%.pc: $(MAKEFILE_LIST)
echo 'Name: lib$(NAME)' >$@
echo 'Description: PostgreSQL lib$(NAME) library' >>$@
echo 'Url: http://www.postgresql.org/' >>$@
echo 'Version: $(VERSION)' >>$@
echo 'Requires: ' >>$@
echo 'Requires.private: $(PKG_CONFIG_REQUIRES_PRIVATE)' >>$@
echo 'Cflags: -I$(includedir)' >>$@
echo 'Libs: -L$(libdir) -l$(NAME)' >>$@
# Record -L flags that the user might have passed in to the PostgreSQL
# build to locate third-party libraries (e.g., ldap, ssl). Filter out
# those that point inside the build or source tree. Use sort to
# remove duplicates. Also record the -l flags necessary for static
# linking, but not those already covered by Requires.private.
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)))' >>$@
# We need several not-quite-identical variants of .DEF files to build # We need several not-quite-identical variants of .DEF files to build
# DLLs for Windows. These are made from the single source file # DLLs for Windows. These are made from the single source file
# exports.txt. Since we can't assume that Windows boxes will have # exports.txt. Since we can't assume that Windows boxes will have
...@@ -430,8 +449,12 @@ endif # SHLIB_EXPORTS ...@@ -430,8 +449,12 @@ endif # SHLIB_EXPORTS
install-lib: install-lib-shared install-lib: install-lib-shared
ifdef soname ifdef soname
install-lib: install-lib-static install-lib: install-lib-static
install-lib: install-lib-pc
endif endif
install-lib-pc: lib$(NAME).pc installdirs-lib
$(INSTALL_DATA) $< '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
install-lib-static: $(stlib) installdirs-lib install-lib-static: $(stlib) installdirs-lib
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)' $(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
ifeq ($(PORTNAME), darwin) ifeq ($(PORTNAME), darwin)
...@@ -467,7 +490,7 @@ endif ...@@ -467,7 +490,7 @@ endif
installdirs-lib: installdirs-lib:
ifdef soname ifdef soname
$(MKDIR_P) '$(DESTDIR)$(libdir)' $(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)'
else else
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)' $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
endif endif
...@@ -483,7 +506,8 @@ ifdef soname ...@@ -483,7 +506,8 @@ ifdef soname
rm -f '$(DESTDIR)$(libdir)/$(stlib)' rm -f '$(DESTDIR)$(libdir)/$(stlib)'
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \ rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
'$(DESTDIR)$(libdir)/$(shlib_major)' \ '$(DESTDIR)$(libdir)/$(shlib_major)' \
'$(DESTDIR)$(libdir)/$(shlib)' '$(DESTDIR)$(libdir)/$(shlib)' \
'$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
else # no soname else # no soname
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)' rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
endif # no soname endif # no soname
...@@ -495,7 +519,7 @@ endif # no soname ...@@ -495,7 +519,7 @@ endif # no soname
.PHONY: clean-lib .PHONY: clean-lib
clean-lib: clean-lib:
rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file) rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file) lib$(NAME).pc
ifneq (,$(SHLIB_EXPORTS)) ifneq (,$(SHLIB_EXPORTS))
maintainer-clean-lib: maintainer-clean-lib:
......
...@@ -32,6 +32,8 @@ LIBS := $(filter-out -lpgport, $(LIBS)) ...@@ -32,6 +32,8 @@ LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= informix.o $(filter snprintf.o, $(LIBOBJS)) OBJS= informix.o $(filter snprintf.o, $(LIBOBJS))
PKG_CONFIG_REQUIRES_PRIVATE = libecpg libpgtypes
all: all-lib all: all-lib
.PHONY: submake-ecpglib submake-pgtypeslib .PHONY: submake-ecpglib submake-pgtypeslib
......
...@@ -43,6 +43,8 @@ ifeq ($(PORTNAME), win32) ...@@ -43,6 +43,8 @@ ifeq ($(PORTNAME), win32)
SHLIB_LINK += -lshfolder SHLIB_LINK += -lshfolder
endif endif
PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
all: all-lib all: all-lib
.PHONY: submake-pgtypeslib .PHONY: submake-pgtypeslib
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment