Skip to content

Commit 7c28fb2

Browse files
committed
[Bug #21546] Make the generated pc file relocatable
1 parent ad04745 commit 7c28fb2

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

.github/workflows/ubuntu.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ jobs:
191191
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
192192
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
193193

194+
- name: test-pc
195+
run: |
196+
DESTDIR=${RUNNER_TEMP-${TMPDIR-/tmp}}/installed
197+
$SETARCH make test-pc "DESTDIR=$DESTDIR"
198+
194199
- uses: ./.github/actions/slack
195200
with:
196201
label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}

template/Makefile.in

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,40 @@ $(LIBRUBY_$(LIBRUBY_WITH_EXT)): $(LIBRUBY_SO_UPDATE)
350350
PKG_CONFIG = @PKG_CONFIG@
351351
ruby_pc = @ruby_pc@
352352
$(ruby_pc): config.status Makefile
353-
$(Q)./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
353+
$(Q) \
354+
pkg="$(@libdirname@)/pkgconfig" prefix="$(prefix)"; \
355+
if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
356+
case "$$pkg" in "$$prefix"/?*) \
357+
pkg="$${pkg#$$prefix/}"; \
358+
prefix='$${pcfiledir}'`echo "/$${pkg}" | sed -e 's|/[^/][^/]*|/..|g'`; \
359+
esac; \
360+
fi; \
361+
./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
354362
sed -e 's/\$$(\([A-Za-z_][A-Za-z0-9_]*\))/$${\1}/g' \
355-
-e 's|^prefix=.*|prefix=$(prefix)|' \
363+
-e "s|^prefix=.*|prefix=$$prefix|" \
356364
> ruby.tmp.pc
357365
$(Q)pkg_config=${PKG_CONFIG} && PKG_CONFIG_PATH=. $${pkg_config:-:} --print-errors ruby.tmp
358366
$(Q)$(MV) -f ruby.tmp.pc $(ruby_pc)
359367

368+
test-pc: install-data
369+
set -ex; \
370+
[ -z "$${pkg_config=$(PKG_CONFIG)}" ] && exit; \
371+
export PKG_CONFIG_PATH=$(DESTDIR)/$(libdir)/pkgconfig$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}; \
372+
$${pkg_config} --exists $(ruby_pc:.pc=); \
373+
path=`$${pkg_config} --variable=prefix $(ruby_pc:.pc=)`; \
374+
if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
375+
test "$$path" -ef "$(DESTDIR)$(prefix)"; \
376+
else \
377+
test "$$path" = "$(prefix)"; \
378+
fi
379+
380+
install-data: pkgconfig-data pre-install-data do-install-data post-install-data
381+
pre-install-data:: install-prereq
382+
do-install-data: $(PREP) pre-install-data
383+
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=data
384+
post-install-data::
385+
@$(NULLCMD)
386+
360387
modular-gc-precheck:
361388
$(Q) if test -z $(modular_gc_dir); then \
362389
echo "You must configure with --with-modular-gc to use modular GC"; \

0 commit comments

Comments
 (0)