Skip to content

Commit d49c7d0

Browse files
nobuk0kubun
authored andcommitted
[Backport #21546] Make the generated pc file relocatable
1 parent b97a159 commit d49c7d0

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
@@ -135,6 +135,11 @@ jobs:
135135
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}
136136
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
137137

138+
- name: test-pc
139+
run: |
140+
DESTDIR=${RUNNER_TEMP-${TMPDIR-/tmp}}/installed
141+
$SETARCH make test-pc "DESTDIR=$DESTDIR"
142+
138143
- uses: ./.github/actions/slack
139144
with:
140145
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
@@ -342,13 +342,40 @@ $(LIBRUBY_$(LIBRUBY_WITH_EXT)): $(LIBRUBY_SO_UPDATE)
342342
PKG_CONFIG = @PKG_CONFIG@
343343
ruby_pc = @ruby_pc@
344344
$(ruby_pc): config.status Makefile
345-
$(Q)./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
345+
$(Q) \
346+
pkg="$(@libdirname@)/pkgconfig" prefix="$(prefix)"; \
347+
if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
348+
case "$$pkg" in "$$prefix"/?*) \
349+
pkg="$${pkg#$$prefix/}"; \
350+
prefix='$${pcfiledir}'`echo "/$${pkg}" | sed -e 's|/[^/][^/]*|/..|g'`; \
351+
esac; \
352+
fi; \
353+
./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
346354
sed -e 's/\$$(\([A-Za-z_][A-Za-z0-9_]*\))/$${\1}/g' \
347-
-e 's|^prefix=.*|prefix=$(prefix)|' \
355+
-e "s|^prefix=.*|prefix=$$prefix|" \
348356
> ruby.tmp.pc
349357
$(Q)pkg_config=${PKG_CONFIG} && PKG_CONFIG_PATH=. $${pkg_config:-:} --print-errors ruby.tmp
350358
$(Q)$(MV) -f ruby.tmp.pc $(ruby_pc)
351359

360+
test-pc: install-data
361+
set -ex; \
362+
[ -z "$${pkg_config=$(PKG_CONFIG)}" ] && exit; \
363+
export PKG_CONFIG_PATH=$(DESTDIR)/$(libdir)/pkgconfig$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}; \
364+
$${pkg_config} --exists $(ruby_pc:.pc=); \
365+
path=`$${pkg_config} --variable=prefix $(ruby_pc:.pc=)`; \
366+
if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
367+
test "$$path" -ef "$(DESTDIR)$(prefix)"; \
368+
else \
369+
test "$$path" = "$(prefix)"; \
370+
fi
371+
372+
install-data: pkgconfig-data pre-install-data do-install-data post-install-data
373+
pre-install-data:: install-prereq
374+
do-install-data: $(PREP) pre-install-data
375+
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=data
376+
post-install-data::
377+
@$(NULLCMD)
378+
352379
modular-gc-precheck:
353380
$(Q) if test -z $(modular_gc_dir); then \
354381
echo "You must configure with --with-modular-gc to use modular GC"; \

0 commit comments

Comments
 (0)