441
#
442
# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
443
# which the built Git will run (for instance "x86_64").
444
+#
445
+# Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and
446
+# support files relative to the location of the runtime binary, rather than
447
+# hard-coding them into the binary. Git installations built with RUNTIME_PREFIX
448
+# can be moved to arbitrary filesystem locations. RUNTIME_PREFIX also causes
449
+# Perl scripts to use a modified entry point header allowing them to resolve
450
+# support files at runtime.
451
452
GIT-VERSION-FILE: FORCE
453
@$(SHELL_PATH) ./GIT-VERSION-GEN
485
# mandir
486
# infodir
487
# htmldir
488
+# localedir
489
+# perllibdir
490
# This can help installing the suite in a relocatable way.
491
492
prefix = $(HOME)
511
mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
512
infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
513
gitexecdir_relative = $(patsubst $(prefix)/%,%,$(gitexecdir))
514
+localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))
515
htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
516
+perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir))
517
518
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
519
1762
infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
1763
perllibdir_SQ = $(subst ','\'',$(perllibdir))
1764
localedir_SQ = $(subst ','\'',$(localedir))
1765
+localedir_relative_SQ = $(subst ','\'',$(localedir_relative))
1766
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1767
gitexecdir_relative_SQ = $(subst ','\'',$(gitexecdir_relative))
1768
template_dir_SQ = $(subst ','\'',$(template_dir))
1769
htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
1770
prefix_SQ = $(subst ','\'',$(prefix))
1771
+perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative))
1772
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
1773
1774
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1779
DIFF_SQ = $(subst ','\'',$(DIFF))
1780
PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
1781
1782
+# RUNTIME_PREFIX's resolution logic requires resource paths to be expressed
1783
+# relative to each other and share an installation path.
1784
+#
1785
+# This is a dependency in:
1786
+# - Git's binary RUNTIME_PREFIX logic in (see "exec_cmd.c").
1787
+# - The runtime prefix Perl header (see
1788
+# "perl/header_templates/runtime_prefix.template.pl").
1789
+ifdef RUNTIME_PREFIX
1790
+
1791
+ifneq ($(filter /%,$(firstword $(gitexecdir_relative))),)
1792
+$(error RUNTIME_PREFIX requires a relative gitexecdir, not: $(gitexecdir))
1793
+endif
1794
+
1795
+ifneq ($(filter /%,$(firstword $(localedir_relative))),)
1796
+$(error RUNTIME_PREFIX requires a relative localedir, not: $(localedir))
1797
+endif
1798
+
1799
+ifndef NO_PERL
1800
+ifneq ($(filter /%,$(firstword $(perllibdir_relative))),)
1801
+$(error RUNTIME_PREFIX requires a relative perllibdir, not: $(perllibdir))
1802
+endif
1803
+endif
1804
+
1805
+endif
1806
+
1807
# We must filter out any object files from $(GITLIBS),
1808
# as it is typically used like:
1809
#
2024
# This makes sure we depend on the NO_PERL setting itself.
2025
$(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS
2026
2027
+# Used for substitution in Perl modules. Disabled when using RUNTIME_PREFIX
2028
+# since the locale directory is injected.
2029
+perl_localedir_SQ = $(localedir_SQ)
2030
+
2031
ifndef NO_PERL
2032
PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
2033
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ)
2034
2035
+PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ) $(perllibdir_SQ)
2036
+PERL_DEFINES += $(RUNTIME_PREFIX)
2037
+
2038
+# Support Perl runtime prefix. In this mode, a different header is installed
2039
+# into Perl scripts.
2040
+ifdef RUNTIME_PREFIX
2041
+
2042
+PERL_HEADER_TEMPLATE = perl/header_templates/runtime_prefix.template.pl
2043
+
2044
+# Don't export a fixed $(localedir) path; it will be resolved by the Perl header
2045
+# at runtime.
2046
+perl_localedir_SQ =
2047
+
2048
+endif
2049
+
2050
+PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)
2051
+
2052
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
2053
$(QUIET_GEN)$(RM) $@ $@+ && \
2054
sed -e '1{' \
2061
chmod +x $@+ && \
2062
mv $@+ $@
2063
2064
+PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))
2065
GIT-PERL-DEFINES: FORCE
2066
@FLAGS='$(PERL_DEFINES)'; \
2067
if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \
2077
sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
2078
-e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \
2079
-e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \
2080
+ -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
2081
+ -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
2082
+ -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
2083
$< >$@+ && \
2084
mv $@+ $@
2085
2403
2404
perl/build/lib/%.pm: perl/%.pm
2405
$(QUIET_GEN)mkdir -p $(dir $@) && \
2343
- sed -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
2406
+ sed -e 's|@@LOCALEDIR@@|$(perl_localedir_SQ)|g' \
2407
-e 's|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
2408
< $< > $@
2409