Skip to content

Instantly share code, notes, and snippets.

@mattyclarkson
Created October 17, 2022 15:12
Show Gist options
  • Save mattyclarkson/c5cccc9da0a5fcf78cddd521f1e92864 to your computer and use it in GitHub Desktop.
Save mattyclarkson/c5cccc9da0a5fcf78cddd521f1e92864 to your computer and use it in GitHub Desktop.
A patch to make Automake 1.16.5 relocatable which is especially useful for Conan packaging.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Matthew Clarkson <redacted@noware.com>
Date: Wed, 1 Jan 3000 00:00:00 +0000
Subject: [PATCH] Make scripts relocatable
---
Makefile.in | 2 ++
bin/aclocal.in | 7 ++++---
bin/automake.in | 3 ++-
lib/Automake/Config.in | 3 ++-
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 18850e7..ac5d0e7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -566,6 +566,7 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
+bindir2datadir = $(shell $(PERL) -MFile::Spec::Functions=abs2rel -E 'say abs2rel(shift, shift)' $(datadir) $(bindir))
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
@@ -660,6 +661,7 @@ nodist_noinst_SCRIPTS = pre-inst-env bin/aclocal-$(APIVERSION) \
do_subst = ( sed \
-e "s,[@]configure_input[@],Generated from $$in; do not edit by hand.,g" \
-e 's,[@]datadir[@],$(datadir),g' \
+ -e 's,[@]bindir2datadir[@],$(bindir2datadir),g' \
-e 's,[@]amdir[@],$(amdir),g' \
-e 's,[@]bindir[@],$(bindir),g' \
-e 's,[@]docdir[@],$(docdir),g' \
diff --git a/bin/aclocal.in b/bin/aclocal.in
index f112447..590e849 100644
--- a/bin/aclocal.in
+++ b/bin/aclocal.in
@@ -22,10 +22,11 @@
use 5.006;
use strict;
use warnings FATAL => 'all';
+use FindBin;
BEGIN
{
- unshift (@INC, '@datadir@/@PACKAGE@-@APIVERSION@')
+ unshift (@INC, "$FindBin::Bin/@bindir2datadir@/@PACKAGE@-@APIVERSION@")
unless $ENV{AUTOMAKE_UNINSTALLED};
}
@@ -65,8 +66,8 @@ $perl_threads = 0;
# ACLOCAL_PATH environment variable, and reset with the '--system-acdir'
# option.
my @user_includes = ();
-my @automake_includes = ('@datadir@/aclocal-' . $APIVERSION);
-my @system_includes = ('@datadir@/aclocal');
+my @automake_includes = ("$FindBin::Bin/@bindir2datadir@/aclocal-" . $APIVERSION);
+my @system_includes = ("$FindBin::Bin/@bindir2datadir@/aclocal");
# Whether we should copy M4 file in $user_includes[0].
my $install = 0;
diff --git a/bin/automake.in b/bin/automake.in
index 30babd6..555ac65 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -25,10 +25,11 @@ package Automake;
use 5.006;
use strict;
use warnings FATAL => 'all';
+use FindBin;
BEGIN
{
- unshift (@INC, '@datadir@/@PACKAGE@-@APIVERSION@')
+ unshift (@INC, "$FindBin::Bin/@bindir2datadir@/@PACKAGE@-@APIVERSION@")
unless $ENV{AUTOMAKE_UNINSTALLED};
# Override SHELL. This is required on DJGPP so that system() uses
diff --git a/lib/Automake/Config.in b/lib/Automake/Config.in
index d529f1b..2c20c79 100644
--- a/lib/Automake/Config.in
+++ b/lib/Automake/Config.in
@@ -20,6 +20,7 @@ package Automake::Config;
use 5.006;
use strict;
use warnings FATAL => 'all';
+use FindBin;
use Exporter;
@@ -34,7 +35,7 @@ our $PACKAGE = '@PACKAGE@';
our $PACKAGE_BUGREPORT = '@PACKAGE_BUGREPORT@';
our $VERSION = '@VERSION@';
our $RELEASE_YEAR = '@RELEASE_YEAR@';
-our $libdir = $ENV{"AUTOMAKE_LIBDIR"} || '@datadir@/@PACKAGE@-@APIVERSION@';
+our $libdir = $ENV{"AUTOMAKE_LIBDIR"} || "$FindBin::Bin/@bindir2datadir@/@PACKAGE@-@APIVERSION@";
our $perl_threads = 0;
# We need at least this version for CLONE support.
--
2.37.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment