diff options
Diffstat (limited to 'build-aux/prefix-gnulib-mk')
-rwxr-xr-x | build-aux/prefix-gnulib-mk | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk index 544654f..674615a 100755 --- a/build-aux/prefix-gnulib-mk +++ b/build-aux/prefix-gnulib-mk @@ -1,13 +1,51 @@ -eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"' - & eval 'exec perl -wS "$0" $argv:q' - if 0; +#!/bin/sh +#! -*-perl-*- + +# Rewrite a gnulib.mk, adding prefixes to work with automake's subdir-objects. + +# Copyright (C) 2012-2020 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# Written by Jim Meyering + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx "$0" "$@"' + if 0; + +my $VERSION = '2012-01-21 17:13'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. use strict; use IO::File; use Getopt::Long; use File::Basename; # for dirname -my $VERSION = '2012-01-21 17:13'; # UTC (my $ME = $0) =~ s|.*/||; my $prefix; @@ -87,7 +125,6 @@ sub prefix_words ($) sub prefix_assignment ($$) { my ($lhs_and_assign_op, $rhs) = @_; - my $res; # Some variables are initialized by gnulib.mk, and we don't want # that. Change '=' to '+='. @@ -95,21 +132,35 @@ sub prefix_assignment ($$) { # Do not change the RHS, which specifies the GPERF program. } + # Don't change variables such as HAVE_INCLUDE_NEXT. + elsif ($lhs_and_assign_op =~ /^HAVE_/) + { + } elsif ($lhs_and_assign_op =~ /^(SUBDIRS|EXTRA_DIST|BUILT_SOURCES|SUFFIXES|MOSTLYCLEANFILES - |CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES|AM_CFLAGS - |AM_CPPFLAGS|AM_GNU_GETTEXT)\ =/x) + |CLEANFILES|DISTCLEANFILES|MAINTAINERCLEANFILES + |AM_GNU_GETTEXT)\ =/x) { $lhs_and_assign_op =~ s/=/+=/; } + # We don't want things such as AM_CPPFLAGS += + # -DDEFAULT_TEXT_DOMAIN=\"bison-gnulib\" to apply to the whole + # Makefile.in: scope it to the library: libbison_a_CPPFLAGS = + # $(AM_CPPFLAGS) -DDEFAULT_TEXT_DOMAIN=\"bison-gnulib\". + elsif ($lhs_and_assign_op =~ + /^(AM_CFLAGS|AM_CPPFLAGS)\ \+?=/x) + { + $lhs_and_assign_op =~ s/^AM_(\w+)\ \+?=/${lib_name}_a_$1 =/; + $rhs = " \$(AM_$1)$rhs"; + } # We don't want to inherit gnulib's AUTOMAKE_OPTIONS, comment them. elsif ($lhs_and_assign_op =~ /^AUTOMAKE_OPTIONS =/) { $lhs_and_assign_op =~ s/^/# /; } + # Elide any SUFFIXES assignment or concatenation. elsif ($lhs_and_assign_op =~ /^SUFFIXES /) { - # Elide any SUFFIXES assignment or concatenation. $lhs_and_assign_op =~ s/^/# /; } # The words are (probably) paths to files in lib/: prefix them. @@ -118,11 +169,11 @@ sub prefix_assignment ($$) $rhs = prefix_words($rhs) } - # Variables which name depend on the location: libbison_a_SOURCES => + # Variables whose name depend on the location: libbison_a_SOURCES => # lib_libbison_a_SOURCES. $lhs_and_assign_op =~ s/($lib_name)/lib_$1/g; - return $lhs_and_assign_op . $rhs; + $lhs_and_assign_op . $rhs; } # prefix $CONTENTS @@ -222,6 +273,7 @@ sub process ($) ## cperl-merge-trailing-else: nil ## cperl-continued-statement-offset: 2 ## eval: (add-hook 'before-save-hook 'time-stamp) +## time-stamp-line-limit: 50 ## time-stamp-start: "my $VERSION = '" ## time-stamp-format: "%:y-%02m-%02d %02H:%02M" ## time-stamp-time-zone: "UTC0" |