From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 3BDDA20A40 for ; Wed, 29 Nov 2017 15:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933643AbdK2P4z (ORCPT ); Wed, 29 Nov 2017 10:56:55 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:37786 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933639AbdK2P4s (ORCPT ); Wed, 29 Nov 2017 10:56:48 -0500 Received: by mail-qk0-f195.google.com with SMTP id i130so4974560qke.4 for ; Wed, 29 Nov 2017 07:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s3xD/zpBezw36J9JKVjqDJm30N00Ell/FL0oIgEcb6w=; b=uCrplkmUzftRF2BEPRMZNru+s/8hZOtBHgnB0FXv1IfcXSOQjAyqf0TZkmPj8cFb7R uTdzYoQBD8UBrxgwfoYP0h7VP16d3LnrWFgz10ZsXesh/GeChebu13QgI97+yus9Lvt+ uNNIWbpHlHqSDAHRHGNvT414LHyZeRS34nVW6ZrBf7Bm8jc9wftvPUYw1aaASVHscIFC W8bDO8Xj8d8uVIIxvENRpgpok+Y45so6JJYZUd/qi5OkJkdoMv2hLZAQf/73uPGFTntu SagYgdAKZqiditbPbGh+7+JhAzeSMlFKwL6yCS5syTx+Yz7/bgd3Ltu7IwxjxhUE4fyV /Dbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s3xD/zpBezw36J9JKVjqDJm30N00Ell/FL0oIgEcb6w=; b=EFEP08legs3RRdF6xC3kO9CYxKq5mg7+vyW0mEMNFoGFOKJRIVhKqFgZG87JyQ6XTe irtVGYHBW1F5KiC3djQnF/tLjLVWCWfp5i6omserf5JIw7t2VUzuupOlvkzFsPN92LRu CsegljJ++GLxnM5/HhgaTwM3CuqBvKwXiATd92U0ex4T1M3CBFre93USShksFE33rsXK PM9EtZ3GjzitKRXQw15wSVEntyLivsyVIjfw71KLXcNdV9y/QxHVhzU24Z5MMcEo5tOZ 7dPCOTj5zW0A5xtigecP4ps+rZ5kQFUCfwdxG1cFP3JSaI/j0uRuY0K8thFRhFNmcUvj 7Ugw== X-Gm-Message-State: AJaThX5yTV6VTpH/1vHjlUY5gMTn20yInzhCjhu6/Vh4+2GbRqBZcDpS r5i90DEzgCWXBV9p061L3gK8iPurA6g= X-Google-Smtp-Source: AGs4zMZrokg+Z3UCFOrr30csfIo1BUYPAWy73HGx/TGmsAaDfarri1s/T4GXZNz0vC/Jrh0IAo7fww== X-Received: by 10.55.17.140 with SMTP id 12mr4982554qkr.229.1511971006585; Wed, 29 Nov 2017 07:56:46 -0800 (PST) Received: from dnj-macbookpro.roam.corp.google.com.com ([100.67.16.103]) by smtp.gmail.com with ESMTPSA id z126sm1390465qka.70.2017.11.29.07.56.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 29 Nov 2017 07:56:45 -0800 (PST) From: Dan Jacques To: git@vger.kernel.org, gitster@pobox.com Cc: Johannes.Schindelin@gmx.de, avarab@gmail.com, Dan Jacques Subject: [PATCH v4 3/4] Makefile: add Perl runtime prefix support Date: Wed, 29 Nov 2017 10:56:36 -0500 Message-Id: <20171129155637.89075-4-dnj@google.com> X-Mailer: git-send-email 2.15.0.chromium12 In-Reply-To: <20171129155637.89075-1-dnj@google.com> References: <20171129155637.89075-1-dnj@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a new Makefile flag, RUNTIME_PREFIX_PERL, which, when enabled, configures Perl scripts to locate the Git installation's Perl support libraries by resolving against the script's path, rather than hard-coding that path at build-time. Enabling RUNTIME_PREFIX_PERL overrides the system-specific Perl script installation path generated by MakeMaker to force installation into a platform-neutral location, "/share/perl5". This change enables Git's Perl scripts to work when their Git installation is relocated or moved to another system. Signed-off-by: Dan Jacques Thanks-to: Ævar Arnfjörð Bjarmason Thanks-to: Johannes Schindelin --- Makefile | 40 +++++++++++++++++++++++++++++++++- perl/header_runtime_prefix.pl.template | 24 ++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 perl/header_runtime_prefix.pl.template diff --git a/Makefile b/Makefile index 80904f8b0..741d1583f 100644 --- a/Makefile +++ b/Makefile @@ -425,6 +425,10 @@ all:: # # to say "export LESS=FRX (and LV=-c) if the environment variable # LESS (and LV) is not set, respectively". +# +# Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git +# support libraries relative to their filesystem path instead of hard-coding +# it. GIT-VERSION-FILE: FORCE @$(SHELL_PATH) ./GIT-VERSION-GEN @@ -485,6 +489,7 @@ pathsep = : mandir_relative = $(patsubst $(prefix)/%,%,$(mandir)) infodir_relative = $(patsubst $(prefix)/%,%,$(infodir)) +sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir)) htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir)) export prefix bindir sharedir sysconfdir gitwebdir localedir @@ -1967,7 +1972,38 @@ perl/PM.stamp: GIT-PERL-DEFINES FORCE PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ) -PERL_DEFINES += $(NO_PERL_MAKEMAKER) +PERL_DEFINES += $(NO_PERL_MAKEMAKER) $(RUNTIME_PREFIX_PERL) + +# Support Perl runtime prefix. In this mode, a different header is installed +# into Perl scripts. This header expects both the scripts and their support +# library to be installed relative to $(prefix), and resolves the path to +# the Perl libraries (perllibdir) from the executable's current path +# (gitexecdir). +# +# This configuration requires both $(perllibdir) and $(gitexecdir) to be +# relative paths, and will error if this is not the case. +ifdef RUNTIME_PREFIX_PERL + +PERL_HEADER_TEMPLATE = perl/header_runtime_prefix.pl.template +PERL_DEFINES += $(gitexecdir) + +# RUNTIME_PREFIX_PERL requires a $(perllibdir) value. +ifeq ($(perllibdir),) +perllibdir = $(sharedir_relative)/perl5 +endif + +ifneq ($(filter /%,$(firstword $(gitexecdir))),) +$(error RUNTIME_PREFIX_PERL requires a relative gitexecdir, not: $(gitexecdir)) +endif +gitexecdir_relative_SQ = $(gitexecdir_SQ) + +ifneq ($(filter /%,$(firstword $(perllibdir))),) +$(error RUNTIME_PREFIX_PERL requires a relative perllibdir, not: $(perllibdir)) +endif +perllibdir_relative_SQ = $(perllibdir_SQ) + +endif + PERL_DEFINES += $(perllibdir) perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL @@ -2001,6 +2037,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \ sed -e 's=@@PATHSEP@@=$(pathsep)=g' \ -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \ + -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \ + -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \ $< >$@+ && \ mv $@+ $@ diff --git a/perl/header_runtime_prefix.pl.template b/perl/header_runtime_prefix.pl.template new file mode 100644 index 000000000..fb9a9924d --- /dev/null +++ b/perl/header_runtime_prefix.pl.template @@ -0,0 +1,24 @@ +# BEGIN RUNTIME_PREFIX_PERL generated code. +# +# This finds our Git::* libraries relative to the script's runtime path. +BEGIN { + use lib split /@@PATHSEP@@/, + ( + $ENV{GITPERLLIB} + || + do { + require FindBin; + require File::Spec; + my $gitexecdir_relative = '@@GITEXECDIR@@'; + my $perllibdir_relative = '@@PERLLIBDIR@@'; + + ($FindBin::Bin =~ m=${gitexecdir_relative}$=) || + die('Unrecognized runtime path.'); + my $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative)); + my $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative); + (-e $perllibdir) || die("Invalid library path: $perllibdir"); + $perllibdir; + } + ); +} +# END RUNTIME_PREFIX_PERL generated code. -- 2.15.0.chromium12