<literal>-L/usr/local/pgsql/lib</literal> to that command line.
</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>
If you manage the build process of a larger project using
<application>make</application>, it might be convenient to include
</screen>
</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>
Failure to specify the correct option to the compiler will
result in an error message such as:
</screen>
</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>
Error messages that point to problems in this area could look like
the following:
# Testing the soname variable is a reliable way to determine whether a
# linkable library is being built.
soname = $(shlib_major)
+pkgconfigdir = $(libdir)/pkgconfig
else
# Naming convention for dynamically loadable modules
shlib = $(NAME)$(DLSUFFIX)
ifdef soname
# no static library when building a dynamically loadable module
all-lib: all-static-lib
+all-lib: lib$(NAME).pc
endif
all-static-lib: $(stlib)
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
# DLLs for Windows. These are made from the single source file
# exports.txt. Since we can't assume that Windows boxes will have
install-lib: install-lib-shared
ifdef soname
install-lib: install-lib-static
+install-lib: install-lib-pc
endif
+install-lib-pc: lib$(NAME).pc installdirs-lib
+ $(INSTALL_DATA) $< '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
+
install-lib-static: $(stlib) installdirs-lib
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
ifeq ($(PORTNAME), darwin)
installdirs-lib:
ifdef soname
- $(MKDIR_P) '$(DESTDIR)$(libdir)'
+ $(MKDIR_P) '$(DESTDIR)$(libdir)' '$(DESTDIR)$(pkgconfigdir)'
else
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
endif
rm -f '$(DESTDIR)$(libdir)/$(stlib)'
rm -f '$(DESTDIR)$(libdir)/$(shlib_bare)' \
'$(DESTDIR)$(libdir)/$(shlib_major)' \
- '$(DESTDIR)$(libdir)/$(shlib)'
+ '$(DESTDIR)$(libdir)/$(shlib)' \
+ '$(DESTDIR)$(pkgconfigdir)/lib$(NAME).pc'
else # no soname
rm -f '$(DESTDIR)$(pkglibdir)/$(shlib)'
endif # no soname
.PHONY: 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))
maintainer-clean-lib: