Created
October 14, 2022 16:46
-
-
Save mattyclarkson/e33494b890007a1a656dcf5c4efb1edc to your computer and use it in GitHub Desktop.
A patch for making autoconf 2.71 relocatable. It uses absolute paths in each of the binary scripts. This uses Perl `FindBin::Bin` to use relative paths.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | |
From: Matt Clarkson <[email protected]> | |
Date: Wed, 1 Jan 3000 00:00:00 +0000 | |
Subject: [PATCH] refactor: make binaries relocatable | |
Uses the binary locations and relative paths to the | |
package data directory to avoid having absolute paths | |
baked into the binary scripts. | |
--- | |
Makefile.in | 2 ++ | |
bin/autoconf.as | 4 ++-- | |
bin/autoheader.in | 5 +++-- | |
bin/autom4te.in | 7 ++++--- | |
bin/autoreconf.in | 9 +++++---- | |
bin/autoscan.in | 7 ++++--- | |
bin/autoupdate.in | 7 ++++--- | |
bin/ifnames.in | 3 ++- | |
lib/autom4te.in | 4 ---- | |
9 files changed, 26 insertions(+), 22 deletions(-) | |
diff --git a/Makefile.in b/Makefile.in | |
index 22a17b3..23dc7e6 100644 | |
--- a/Makefile.in | |
+++ b/Makefile.in | |
@@ -196,6 +196,7 @@ am__make_running_with_option = \ | |
am__make_dryrun = (target_option=n; $(am__make_running_with_option)) | |
am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) | |
pkgdatadir = $(datadir)/@PACKAGE@ | |
+bindir2pkgdatadir = $(shell $(PERL) -MFile::Spec::Functions=abs2rel -E 'say abs2rel(shift, shift)' $(pkgdatadir) $(bindir)) | |
pkgincludedir = $(includedir)/@PACKAGE@ | |
pkglibdir = $(libdir)/@PACKAGE@ | |
pkglibexecdir = $(libexecdir)/@PACKAGE@ | |
@@ -556,6 +557,7 @@ edit = sed \ | |
-e 's|@PERL_FLOCK[@]|$(PERL_FLOCK)|g' \ | |
-e 's|@bindir[@]|$(bindir)|g' \ | |
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ | |
+ -e 's|@bindir2pkgdatadir[@]|$(bindir2pkgdatadir)|g' \ | |
-e 's|@prefix[@]|$(prefix)|g' \ | |
-e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \ | |
-e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \ | |
diff --git a/bin/autoconf.as b/bin/autoconf.as | |
index 1407739..a8e1fcc 100644 | |
--- a/bin/autoconf.as | |
+++ b/bin/autoconf.as | |
@@ -89,8 +89,8 @@ exit_missing_arg=' | |
# restore font-lock: ' | |
# Variables. | |
-: ${AUTOM4TE='@bindir@/@autom4te-name@'} | |
-: ${trailer_m4='@pkgdatadir@/autoconf/trailer.m4'} | |
+: ${AUTOM4TE="${as_myself%/*}/@autom4te-name@"} | |
+: ${trailer_m4="${as_myself%/*}/@bindir2pkgdatadir@/autoconf/trailer.m4"} | |
autom4te_options= | |
outfile= | |
verbose=false | |
diff --git a/bin/autoheader.in b/bin/autoheader.in | |
index 1cbf509..24d67f1 100644 | |
--- a/bin/autoheader.in | |
+++ b/bin/autoheader.in | |
@@ -29,10 +29,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, "$pkgdatadir"; | |
# Override SHELL. On DJGPP SHELL may not be set to a shell | |
@@ -54,7 +55,7 @@ use Autom4te::XFile; | |
our ($config_h, %symbol, %verbatim); | |
# Lib files. | |
-my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@'; | |
+my $autom4te = $ENV{'AUTOM4TE'} || "$FindBin::Bin/@autom4te-name@"; | |
my $config_h_in; | |
my @prepend_include; | |
my @include; | |
diff --git a/bin/autom4te.in b/bin/autom4te.in | |
index 7ebe419..30be4bc 100644 | |
--- a/bin/autom4te.in | |
+++ b/bin/autom4te.in | |
@@ -25,10 +25,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, $pkgdatadir; | |
# Override SHELL. On DJGPP SHELL may not be set to a shell | |
@@ -48,7 +49,7 @@ use Autom4te::General; | |
use Autom4te::XFile; | |
# Data directory. | |
-my $pkgdatadir = $ENV{'AC_MACRODIR'} || '@pkgdatadir@'; | |
+my $pkgdatadir = $ENV{'AC_MACRODIR'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
# $LANGUAGE{LANGUAGE} -- Automatic options for LANGUAGE. | |
my %language; | |
@@ -85,7 +86,7 @@ my @preselect = ('include', | |
'_m4_warn'); | |
# M4 include path. | |
-my @include; | |
+my @include = ("$FindBin::Bin/@bindir2pkgdatadir@"); | |
# Do we freeze? | |
my $freeze = 0; | |
diff --git a/bin/autoreconf.in b/bin/autoreconf.in | |
index ec391a6..0b0af0a 100644 | |
--- a/bin/autoreconf.in | |
+++ b/bin/autoreconf.in | |
@@ -28,11 +28,12 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
my $buildauxdir; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, $pkgdatadir; | |
$buildauxdir = $ENV{'autom4te_buildauxdir'} || $pkgdatadir . '/build-aux'; | |
@@ -117,9 +118,9 @@ Written by David J. MacKenzie and Akim Demaille. | |
"; | |
# Lib files. | |
-my $autoconf = $ENV{'AUTOCONF'} || '@bindir@/@autoconf-name@'; | |
-my $autoheader = $ENV{'AUTOHEADER'} || '@bindir@/@autoheader-name@'; | |
-my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@'; | |
+my $autoconf = $ENV{'AUTOCONF'} || "$FindBin::Bin/@autoconf-name@"; | |
+my $autoheader = $ENV{'AUTOHEADER'} || "$FindBin::Bin/@autoheader-name@"; | |
+my $autom4te = $ENV{'AUTOM4TE'} || "$FindBin::Bin/@autom4te-name@"; | |
my $automake = $ENV{'AUTOMAKE'} || 'automake'; | |
my $aclocal = $ENV{'ACLOCAL'} || 'aclocal'; | |
my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize'; | |
diff --git a/bin/autoscan.in b/bin/autoscan.in | |
index b89fd1a..2535f66 100644 | |
--- a/bin/autoscan.in | |
+++ b/bin/autoscan.in | |
@@ -27,10 +27,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, $pkgdatadir; | |
# Override SHELL. On DJGPP SHELL may not be set to a shell | |
@@ -95,10 +96,10 @@ my %needed_macros = | |
my $log; | |
# Autoconf and lib files. | |
-my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@'; | |
+my $autom4te = $ENV{'AUTOM4TE'} || "$FindBin::Bin/@autom4te-name@"; | |
my $autoconf = "$autom4te --language=autoconf"; | |
my @prepend_include; | |
-my @include = ('@pkgdatadir@'); | |
+my @include = ("$FindBin::Bin/@bindir2pkgdatadir@"); | |
# $help | |
# ----- | |
diff --git a/bin/autoupdate.in b/bin/autoupdate.in | |
index c86203a..8f498f1 100644 | |
--- a/bin/autoupdate.in | |
+++ b/bin/autoupdate.in | |
@@ -28,10 +28,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, $pkgdatadir; | |
# Override SHELL. On DJGPP SHELL may not be set to a shell | |
@@ -51,11 +52,11 @@ use Autom4te::General; | |
use Autom4te::XFile; | |
# Lib files. | |
-my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@'; | |
+my $autom4te = $ENV{'AUTOM4TE'} || "$FindBin::Bin/@autom4te-name@"; | |
my $autoconf = "$autom4te --language=autoconf"; | |
# We need to find m4sugar. | |
my @prepend_include; | |
-my @include = ('@pkgdatadir@'); | |
+my @include = ("$FindBin::Bin/@bindir2pkgdatadir@"); | |
my $force = 0; | |
# m4. | |
my $m4 = $ENV{"M4"} || '@M4@'; | |
diff --git a/bin/ifnames.in b/bin/ifnames.in | |
index b04947f..2c76349 100644 | |
--- a/bin/ifnames.in | |
+++ b/bin/ifnames.in | |
@@ -32,10 +32,11 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' | |
use 5.006; | |
use strict; | |
use warnings FATAL => 'all'; | |
+use FindBin; | |
BEGIN | |
{ | |
- my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; | |
+ my $pkgdatadir = $ENV{'autom4te_perllibdir'} || "$FindBin::Bin/@bindir2pkgdatadir@"; | |
unshift @INC, $pkgdatadir; | |
# Override SHELL. On DJGPP SHELL may not be set to a shell | |
diff --git a/lib/autom4te.in b/lib/autom4te.in | |
index 9e86c9f..ce069a7 100644 | |
--- a/lib/autom4te.in | |
+++ b/lib/autom4te.in | |
@@ -115,7 +115,6 @@ end-language: "Autoreconf-preselections" | |
# This intermediate language is used by aclocal to build aclocal.m4. | |
begin-language: "Autoconf-without-aclocal-m4" | |
-args: --prepend-include '@pkgdatadir@' | |
args: --cache=autom4te.cache | |
args: autoconf/autoconf.m4f | |
args: acsite.m4? | |
@@ -142,7 +141,6 @@ end-language: "Autoconf" | |
## -------- ## | |
begin-language: "Autotest" | |
-args: --prepend-include '@pkgdatadir@' | |
args: autotest/autotest.m4f | |
args: package.m4? | |
args: local.at? | |
@@ -156,7 +154,6 @@ end-language: "Autotest" | |
## ---- ## | |
begin-language: "M4sh" | |
-args: --prepend-include '@pkgdatadir@' | |
args: m4sugar/m4sh.m4f | |
args: --mode 777 | |
args: --language M4sugar | |
@@ -168,6 +165,5 @@ end-language: "M4sh" | |
## ------- ## | |
begin-language: "M4sugar" | |
-args: --prepend-include '@pkgdatadir@' | |
args: m4sugar/m4sugar.m4f | |
end-language: "M4sugar" | |
-- | |
2.37.3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment