@@ -441,6 +441,29 @@ all::
441
441
#
442
442
# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
443
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
+ # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform
453
+ # supports the KERN_PROC BSD sysctl function.
454
+ #
455
+ # When using RUNTIME_PREFIX, define PROCFS_EXECUTABLE_PATH if your platform
456
+ # mounts a "procfs" filesystem capable of resolving the path of the current
457
+ # executable. If defined, this must be the canonical path for the "procfs"
458
+ # current executable path.
459
+ #
460
+ # When using RUNTIME_PREFIX, define HAVE_NS_GET_EXECUTABLE_PATH if your platform
461
+ # supports calling _NSGetExecutablePath to retrieve the path of the running
462
+ # executable.
463
+ #
464
+ # When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers
465
+ # the global variable _wpgmptr containing the absolute path of the current
466
+ # executable (this is the case on Windows).
444
467
445
468
GIT-VERSION-FILE : FORCE
446
469
@$(SHELL_PATH ) ./GIT-VERSION-GEN
@@ -478,6 +501,8 @@ ARFLAGS = rcs
478
501
# mandir
479
502
# infodir
480
503
# htmldir
504
+ # localedir
505
+ # perllibdir
481
506
# This can help installing the suite in a relocatable way.
482
507
483
508
prefix = $(HOME )
@@ -502,7 +527,9 @@ bindir_relative = $(patsubst $(prefix)/%,%,$(bindir))
502
527
mandir_relative = $(patsubst $(prefix ) /% ,% ,$(mandir ) )
503
528
infodir_relative = $(patsubst $(prefix ) /% ,% ,$(infodir ) )
504
529
gitexecdir_relative = $(patsubst $(prefix ) /% ,% ,$(gitexecdir ) )
530
+ localedir_relative = $(patsubst $(prefix ) /% ,% ,$(localedir ) )
505
531
htmldir_relative = $(patsubst $(prefix ) /% ,% ,$(htmldir ) )
532
+ perllibdir_relative = $(patsubst $(prefix ) /% ,% ,$(perllibdir ) )
506
533
507
534
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
508
535
@@ -1670,10 +1697,27 @@ ifdef HAVE_BSD_SYSCTL
1670
1697
BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
1671
1698
endif
1672
1699
1700
+ ifdef HAVE_BSD_KERN_PROC_SYSCTL
1701
+ BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
1702
+ endif
1703
+
1673
1704
ifdef HAVE_GETDELIM
1674
1705
BASIC_CFLAGS += -DHAVE_GETDELIM
1675
1706
endif
1676
1707
1708
+ ifneq ($(PROCFS_EXECUTABLE_PATH ) ,)
1709
+ procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
1710
+ BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
1711
+ endif
1712
+
1713
+ ifdef HAVE_NS_GET_EXECUTABLE_PATH
1714
+ BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
1715
+ endif
1716
+
1717
+ ifdef HAVE_WPGMPTR
1718
+ BASIC_CFLAGS += -DHAVE_WPGMPTR
1719
+ endif
1720
+
1677
1721
ifeq ($(TCLTK_PATH ) ,)
1678
1722
NO_TCLTK = NoThanks
1679
1723
endif
@@ -1758,11 +1802,13 @@ mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
1758
1802
infodir_relative_SQ = $(subst ','\'',$(infodir_relative ) )
1759
1803
perllibdir_SQ = $(subst ','\'',$(perllibdir ) )
1760
1804
localedir_SQ = $(subst ','\'',$(localedir ) )
1805
+ localedir_relative_SQ = $(subst ','\'',$(localedir_relative ) )
1761
1806
gitexecdir_SQ = $(subst ','\'',$(gitexecdir ) )
1762
1807
gitexecdir_relative_SQ = $(subst ','\'',$(gitexecdir_relative ) )
1763
1808
template_dir_SQ = $(subst ','\'',$(template_dir ) )
1764
1809
htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative ) )
1765
1810
prefix_SQ = $(subst ','\'',$(prefix ) )
1811
+ perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative ) )
1766
1812
gitwebdir_SQ = $(subst ','\'',$(gitwebdir ) )
1767
1813
1768
1814
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH ) )
@@ -1773,6 +1819,31 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1773
1819
DIFF_SQ = $(subst ','\'',$(DIFF ) )
1774
1820
PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA ) )
1775
1821
1822
+ # RUNTIME_PREFIX's resolution logic requires resource paths to be expressed
1823
+ # relative to each other and share an installation path.
1824
+ #
1825
+ # This is a dependency in:
1826
+ # - Git's binary RUNTIME_PREFIX logic in (see "exec_cmd.c").
1827
+ # - The runtime prefix Perl header (see
1828
+ # "perl/header_templates/runtime_prefix.template.pl").
1829
+ ifdef RUNTIME_PREFIX
1830
+
1831
+ ifneq ($(filter /% ,$(firstword $(gitexecdir_relative ) ) ) ,)
1832
+ $(error RUNTIME_PREFIX requires a relative gitexecdir, not : $(gitexecdir ) )
1833
+ endif
1834
+
1835
+ ifneq ($(filter /% ,$(firstword $(localedir_relative ) ) ) ,)
1836
+ $(error RUNTIME_PREFIX requires a relative localedir, not : $(localedir ) )
1837
+ endif
1838
+
1839
+ ifndef NO_PERL
1840
+ ifneq ($(filter /% ,$(firstword $(perllibdir_relative ) ) ) ,)
1841
+ $(error RUNTIME_PREFIX requires a relative perllibdir, not : $(perllibdir ) )
1842
+ endif
1843
+ endif
1844
+
1845
+ endif
1846
+
1776
1847
# We must filter out any object files from $(GITLIBS),
1777
1848
# as it is typically used like:
1778
1849
#
@@ -1993,34 +2064,64 @@ git.res: git.rc GIT-VERSION-FILE
1993
2064
# This makes sure we depend on the NO_PERL setting itself.
1994
2065
$(SCRIPT_PERL_GEN ) : GIT-BUILD-OPTIONS
1995
2066
1996
- ifndef NO_PERL
1997
- $(SCRIPT_PERL_GEN ) :
2067
+ # Used for substitution in Perl modules. Disabled when using RUNTIME_PREFIX
2068
+ # since the locale directory is injected.
2069
+ perl_localedir_SQ = $(localedir_SQ )
1998
2070
2071
+ ifndef NO_PERL
2072
+ PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
1999
2073
PERL_DEFINES = $(PERL_PATH_SQ ) :$(PERLLIB_EXTRA_SQ ) :$(perllibdir_SQ )
2000
- $(SCRIPT_PERL_GEN ) : % : % .perl GIT-PERL-DEFINES GIT-VERSION-FILE
2074
+
2075
+ PERL_DEFINES := $(PERL_PATH_SQ ) $(PERLLIB_EXTRA_SQ ) $(perllibdir_SQ )
2076
+ PERL_DEFINES += $(RUNTIME_PREFIX )
2077
+
2078
+ # Support Perl runtime prefix. In this mode, a different header is installed
2079
+ # into Perl scripts.
2080
+ ifdef RUNTIME_PREFIX
2081
+
2082
+ PERL_HEADER_TEMPLATE = perl/header_templates/runtime_prefix.template.pl
2083
+
2084
+ # Don't export a fixed $(localedir) path; it will be resolved by the Perl header
2085
+ # at runtime.
2086
+ perl_localedir_SQ =
2087
+
2088
+ endif
2089
+
2090
+ PERL_DEFINES += $(gitexecdir ) $(perllibdir ) $(localedir )
2091
+
2092
+ $(SCRIPT_PERL_GEN ) : % : % .perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
2001
2093
$(QUIET_GEN )$(RM ) $@ $@ + && \
2002
- INSTLIBDIR=' $(perllibdir_SQ)' && \
2003
- INSTLIBDIR_EXTRA=' $(PERLLIB_EXTRA_SQ)' && \
2004
- INSTLIBDIR=" $$ INSTLIBDIR$$ {INSTLIBDIR_EXTRA:+:$$ INSTLIBDIR_EXTRA}" && \
2005
2094
sed -e ' 1{' \
2006
2095
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
2007
- -e ' h' \
2008
- -e ' s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "' " $$ INSTLIBDIR" ' "));=' \
2009
- -e ' H' \
2010
- -e ' x' \
2096
+ -e ' rGIT-PERL-HEADER' \
2097
+ -e ' G' \
2011
2098
-e ' }' \
2012
2099
-e ' s/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
2013
2100
$< > $@ + && \
2014
2101
chmod +x $@ + && \
2015
2102
mv $@ + $@
2016
2103
2104
+ PERL_DEFINES := $(subst $(space ) ,:,$(PERL_DEFINES ) )
2017
2105
GIT-PERL-DEFINES : FORCE
2018
2106
@FLAGS=' $(PERL_DEFINES)' ; \
2019
2107
if test x" $$ FLAGS" ! = x" ` cat $@ 2> /dev/null` " ; then \
2020
2108
echo >&2 " * new perl-specific parameters" ; \
2021
2109
echo " $$ FLAGS" > $@ ; \
2022
2110
fi
2023
2111
2112
+ GIT-PERL-HEADER : $(PERL_HEADER_TEMPLATE ) GIT-PERL-DEFINES Makefile
2113
+ $(QUIET_GEN )$(RM ) $@ && \
2114
+ INSTLIBDIR=' $(perllibdir_SQ)' && \
2115
+ INSTLIBDIR_EXTRA=' $(PERLLIB_EXTRA_SQ)' && \
2116
+ INSTLIBDIR=" $$ INSTLIBDIR$$ {INSTLIBDIR_EXTRA:+:$$ INSTLIBDIR_EXTRA}" && \
2117
+ sed -e ' s=@@PATHSEP@@=$(pathsep)=g' \
2118
+ -e " s=@@INSTLIBDIR@@=$$ INSTLIBDIR=g" \
2119
+ -e ' s=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
2120
+ -e ' s=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
2121
+ -e ' s=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
2122
+ $< > $@ + && \
2123
+ mv $@ + $@
2124
+
2024
2125
.PHONY : perllibdir
2025
2126
perllibdir :
2026
2127
@echo ' $(perllibdir_SQ)'
@@ -2168,6 +2269,7 @@ endif
2168
2269
exec-cmd.sp exec-cmd.s exec-cmd.o : GIT-PREFIX
2169
2270
exec-cmd.sp exec-cmd.s exec-cmd.o : EXTRA_CPPFLAGS = \
2170
2271
' -DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
2272
+ ' -DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
2171
2273
' -DBINDIR="$(bindir_relative_SQ)"' \
2172
2274
' -DPREFIX="$(prefix_SQ)"'
2173
2275
@@ -2185,7 +2287,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
2185
2287
2186
2288
gettext.sp gettext.s gettext.o : GIT-PREFIX
2187
2289
gettext.sp gettext.s gettext.o : EXTRA_CPPFLAGS = \
2188
- -DGIT_LOCALE_PATH=' "$(localedir_SQ )"'
2290
+ -DGIT_LOCALE_PATH=' "$(localedir_relative_SQ )"'
2189
2291
2190
2292
http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp : SPARSE_FLAGS += \
2191
2293
-DCURL_DISABLE_TYPECHECK
@@ -2345,7 +2447,7 @@ endif
2345
2447
2346
2448
perl/build/lib/% .pm : perl/% .pm
2347
2449
$(QUIET_GEN ) mkdir -p $(dir $@ ) && \
2348
- sed -e ' s|@@LOCALEDIR@@|$(localedir_SQ )|g' \
2450
+ sed -e ' s|@@LOCALEDIR@@|$(perl_localedir_SQ )|g' \
2349
2451
-e ' s|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
2350
2452
< $< > $@
2351
2453
@@ -2803,7 +2905,7 @@ ifndef NO_TCLTK
2803
2905
endif
2804
2906
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2805
2907
$(RM) GIT-USER-AGENT GIT-PREFIX
2806
- $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2908
+ $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT- PYTHON-VARS
2807
2909
2808
2910
.PHONY : all install profile-clean clean strip
2809
2911
.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
0 commit comments