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

Commit6588d84

Browse files
committed
Make pkg-config files cross-compile friendly
Currently the pc files use hard coded paths for "includedir" and"libdir."Example: Cflags: -I/usr/include Libs: -L/usr/lib -lpqThis is not very fortunate when cross compiling inside a buildroot,where the includes and libs are inside a staging directory, becausethis introduces host paths into the build: checking for pkg-config... /builder/shared-workdir/build/sdk/staging_dir/host/bin/pkg-config checking for PostgreSQL libraries via pkg_config... -L/usr/lib <----This commit addresses this by doing the following two things: 1. Instead of hard coding the paths in "Cflags" and "Libs" "${includedir}" and "${libdir}" are used. Note: these variables can be overriden on the pkg-config command line ("--define-variable=libdir=/some/path"). 2. Add the variables "prefix" and "exec_prefix". If "includedir" and/or "libdir" are using these then construct them accordingly. This is done because buildroots (for instance OpenWrt) tend to rename the real pkg-config and call it indirectly from a script that sets "prefix", "exec_prefix" and "bindir", like so: pkg-config.real --define-variable=prefix=${STAGING_PREFIX} \ --define-variable=exec_prefix=${STAGING_PREFIX} \ --define-variable=bindir=${STAGING_PREFIX}/bin $@Example#1: user calls ./configure with "--libdir=/some/lib" and"--includedir=/some/include": prefix=/usr/local/pgsql exec_prefix=${prefix} libdir=/some/lib includedir=/some/include Name: libpq Description: PostgreSQL libpq library Url:http://www.postgresql.org/ Version: 12.1 Requires: Requires.private: Cflags: -I${includedir} Libs: -L${libdir} -lpq Libs.private: -lcrypt -lmExample#2: user calls ./configure with no arguments: prefix=/usr/local/pgsql exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: libpq Description: PostgreSQL libpq library Url:http://www.postgresql.org/ Version: 12.1 Requires: Requires.private: Cflags: -I${includedir} Libs: -L${libdir} -lpq Libs.private: -lcrypt -lmLike this the paths can be forced into the staging directory whenusing a buildroot setup: checking for pkg-config... /home/sk/tmp/openwrt/staging_dir/host/bin/pkg-config checking for PostgreSQL libraries via pkg_config... -L/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/libAuthor: Sebastian Kemper <sebastian_ml@gmx.net>Co-authored-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>Discussion:https://www.postgresql.org/message-id/flat/20200305213827.GA25135%40darth.lan
1 parent4c2eab3 commit6588d84

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/Makefile.shlib

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,19 @@ endif # PORTNAME == cygwin || PORTNAME == win32
387387

388388

389389
%.pc: $(MAKEFILE_LIST)
390-
echo 'Name: lib$(NAME)' >$@
390+
echo 'prefix=$(prefix)' >$@
391+
echo 'exec_prefix=$(patsubst $(prefix),$${prefix},$(exec_prefix))' >>$@
392+
echo 'libdir=$(patsubst $(exec_prefix)/%,$${exec_prefix}/%,$(libdir))' >>$@
393+
echo 'includedir=$(patsubst $(prefix)/%,$${prefix}/%,$(includedir))' >>$@
394+
echo >>$@
395+
echo 'Name: lib$(NAME)' >>$@
391396
echo 'Description: PostgreSQL lib$(NAME) library' >>$@
392397
echo 'Url: $(PACKAGE_URL)' >>$@
393398
echo 'Version: $(VERSION)' >>$@
394399
echo 'Requires: ' >>$@
395400
echo 'Requires.private: $(PKG_CONFIG_REQUIRES_PRIVATE)' >>$@
396-
echo 'Cflags: -I$(includedir)' >>$@
397-
echo 'Libs: -L$(libdir) -l$(NAME)' >>$@
401+
echo 'Cflags: -I$${includedir}' >>$@
402+
echo 'Libs: -L$${libdir} -l$(NAME)' >>$@
398403
# Record -L flags that the user might have passed in to the PostgreSQL
399404
# build to locate third-party libraries (e.g., ldap, ssl). Filter out
400405
# those that point inside the build or source tree. Use sort to

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp