@@ -434,6 +434,29 @@ all::
434
434
#
435
435
# When cross-compiling, define HOST_CPU as the canonical name of the CPU on
436
436
# which the built Git will run (for instance "x86_64").
437
+ #
438
+ # Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and
439
+ # support files relative to the location of the runtime binary, rather than
440
+ # hard-coding them into the binary. Git installations built with RUNTIME_PREFIX
441
+ # can be moved to arbitrary filesystem locations. RUNTIME_PREFIX also causes
442
+ # Perl scripts to use a modified entry point header allowing them to resolve
443
+ # support files at runtime.
444
+ #
445
+ # When using RUNTIME_PREFIX, define HAVE_BSD_KERN_PROC_SYSCTL if your platform
446
+ # supports the KERN_PROC BSD sysctl function.
447
+ #
448
+ # When using RUNTIME_PREFIX, define PROCFS_EXECUTABLE_PATH if your platform
449
+ # mounts a "procfs" filesystem capable of resolving the path of the current
450
+ # executable. If defined, this must be the canonical path for the "procfs"
451
+ # current executable path.
452
+ #
453
+ # When using RUNTIME_PREFIX, define HAVE_NS_GET_EXECUTABLE_PATH if your platform
454
+ # supports calling _NSGetExecutablePath to retrieve the path of the running
455
+ # executable.
456
+ #
457
+ # When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers
458
+ # the global variable _wpgmptr containing the absolute path of the current
459
+ # executable (this is the case on Windows).
437
460
438
461
GIT-VERSION-FILE : FORCE
439
462
@$(SHELL_PATH ) ./GIT-VERSION-GEN
@@ -471,6 +494,8 @@ ARFLAGS = rcs
471
494
# mandir
472
495
# infodir
473
496
# htmldir
497
+ # localedir
498
+ # perllibdir
474
499
# This can help installing the suite in a relocatable way.
475
500
476
501
prefix = $(HOME )
@@ -492,10 +517,12 @@ lib = lib
492
517
# DESTDIR =
493
518
pathsep = :
494
519
495
- localedir_relative = $(patsubst $(prefix ) /% ,% ,$(localedir ) )
496
520
mandir_relative = $(patsubst $(prefix ) /% ,% ,$(mandir ) )
497
521
infodir_relative = $(patsubst $(prefix ) /% ,% ,$(infodir ) )
522
+ gitexecdir_relative = $(patsubst $(prefix ) /% ,% ,$(gitexecdir ) )
523
+ localedir_relative = $(patsubst $(prefix ) /% ,% ,$(localedir ) )
498
524
htmldir_relative = $(patsubst $(prefix ) /% ,% ,$(htmldir ) )
525
+ perllibdir_relative = $(patsubst $(prefix ) /% ,% ,$(perllibdir ) )
499
526
500
527
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
501
528
@@ -1654,10 +1681,27 @@ ifdef HAVE_BSD_SYSCTL
1654
1681
BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
1655
1682
endif
1656
1683
1684
+ ifdef HAVE_BSD_KERN_PROC_SYSCTL
1685
+ BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
1686
+ endif
1687
+
1657
1688
ifdef HAVE_GETDELIM
1658
1689
BASIC_CFLAGS += -DHAVE_GETDELIM
1659
1690
endif
1660
1691
1692
+ ifneq ($(PROCFS_EXECUTABLE_PATH ) ,)
1693
+ procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
1694
+ BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
1695
+ endif
1696
+
1697
+ ifdef HAVE_NS_GET_EXECUTABLE_PATH
1698
+ BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
1699
+ endif
1700
+
1701
+ ifdef HAVE_WPGMPTR
1702
+ BASIC_CFLAGS += -DHAVE_WPGMPTR
1703
+ endif
1704
+
1661
1705
ifeq ($(TCLTK_PATH ) ,)
1662
1706
NO_TCLTK = NoThanks
1663
1707
endif
@@ -1747,6 +1791,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1747
1791
template_dir_SQ = $(subst ','\'',$(template_dir ) )
1748
1792
htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative ) )
1749
1793
prefix_SQ = $(subst ','\'',$(prefix ) )
1794
+ perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative ) )
1750
1795
gitwebdir_SQ = $(subst ','\'',$(gitwebdir ) )
1751
1796
1752
1797
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH ) )
@@ -1757,6 +1802,31 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1757
1802
DIFF_SQ = $(subst ','\'',$(DIFF ) )
1758
1803
PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA ) )
1759
1804
1805
+ # RUNTIME_PREFIX's resolution logic requires resource paths to be expressed
1806
+ # relative to each other and share an installation path.
1807
+ #
1808
+ # This is a dependency in:
1809
+ # - Git's binary RUNTIME_PREFIX logic in (see "exec_cmd.c").
1810
+ # - The runtime prefix Perl header (see
1811
+ # "perl/header_templates/runtime_prefix.template.pl").
1812
+ ifdef RUNTIME_PREFIX
1813
+
1814
+ ifneq ($(filter /% ,$(firstword $(gitexecdir_relative ) ) ) ,)
1815
+ $(error RUNTIME_PREFIX requires a relative gitexecdir, not : $(gitexecdir ) )
1816
+ endif
1817
+
1818
+ ifneq ($(filter /% ,$(firstword $(localedir_relative ) ) ) ,)
1819
+ $(error RUNTIME_PREFIX requires a relative localedir, not : $(localedir ) )
1820
+ endif
1821
+
1822
+ ifndef NO_PERL
1823
+ ifneq ($(filter /% ,$(firstword $(perllibdir_relative ) ) ) ,)
1824
+ $(error RUNTIME_PREFIX requires a relative perllibdir, not : $(perllibdir ) )
1825
+ endif
1826
+ endif
1827
+
1828
+ endif
1829
+
1760
1830
# We must filter out any object files from $(GITLIBS),
1761
1831
# as it is typically used like:
1762
1832
#
@@ -1977,34 +2047,64 @@ git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
1977
2047
# This makes sure we depend on the NO_PERL setting itself.
1978
2048
$(SCRIPT_PERL_GEN ) : GIT-BUILD-OPTIONS
1979
2049
1980
- ifndef NO_PERL
1981
- $(SCRIPT_PERL_GEN ) :
2050
+ # Used for substitution in Perl modules. Disabled when using RUNTIME_PREFIX
2051
+ # since the locale directory is injected.
2052
+ perl_localedir_SQ = $(localedir_SQ )
1982
2053
2054
+ ifndef NO_PERL
2055
+ PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
1983
2056
PERL_DEFINES = $(PERL_PATH_SQ ) :$(PERLLIB_EXTRA_SQ ) :$(perllibdir_SQ )
1984
- $(SCRIPT_PERL_GEN ) : % : % .perl GIT-PERL-DEFINES GIT-VERSION-FILE
2057
+
2058
+ PERL_DEFINES := $(PERL_PATH_SQ ) $(PERLLIB_EXTRA_SQ ) $(perllibdir_SQ )
2059
+ PERL_DEFINES += $(RUNTIME_PREFIX )
2060
+
2061
+ # Support Perl runtime prefix. In this mode, a different header is installed
2062
+ # into Perl scripts.
2063
+ ifdef RUNTIME_PREFIX
2064
+
2065
+ PERL_HEADER_TEMPLATE = perl/header_templates/runtime_prefix.template.pl
2066
+
2067
+ # Don't export a fixed $(localedir) path; it will be resolved by the Perl header
2068
+ # at runtime.
2069
+ perl_localedir_SQ =
2070
+
2071
+ endif
2072
+
2073
+ PERL_DEFINES += $(gitexecdir ) $(perllibdir ) $(localedir )
2074
+
2075
+ $(SCRIPT_PERL_GEN ) : % : % .perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
1985
2076
$(QUIET_GEN )$(RM ) $@ $@ + && \
1986
- INSTLIBDIR=' $(perllibdir_SQ)' && \
1987
- INSTLIBDIR_EXTRA=' $(PERLLIB_EXTRA_SQ)' && \
1988
- INSTLIBDIR=" $$ INSTLIBDIR$$ {INSTLIBDIR_EXTRA:+:$$ INSTLIBDIR_EXTRA}" && \
1989
2077
sed -e ' 1{' \
1990
2078
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1991
- -e ' h' \
1992
- -e ' s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "' " $$ INSTLIBDIR" ' "));=' \
1993
- -e ' H' \
1994
- -e ' x' \
2079
+ -e ' rGIT-PERL-HEADER' \
2080
+ -e ' G' \
1995
2081
-e ' }' \
1996
2082
-e ' s/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1997
2083
$< > $@ + && \
1998
2084
chmod +x $@ + && \
1999
2085
mv $@ + $@
2000
2086
2087
+ PERL_DEFINES := $(subst $(space ) ,:,$(PERL_DEFINES ) )
2001
2088
GIT-PERL-DEFINES : FORCE
2002
2089
@FLAGS=' $(PERL_DEFINES)' ; \
2003
2090
if test x" $$ FLAGS" ! = x" ` cat $@ 2> /dev/null` " ; then \
2004
2091
echo >&2 " * new perl-specific parameters" ; \
2005
2092
echo " $$ FLAGS" > $@ ; \
2006
2093
fi
2007
2094
2095
+ GIT-PERL-HEADER : $(PERL_HEADER_TEMPLATE ) GIT-PERL-DEFINES Makefile
2096
+ $(QUIET_GEN )$(RM ) $@ && \
2097
+ INSTLIBDIR=' $(perllibdir_SQ)' && \
2098
+ INSTLIBDIR_EXTRA=' $(PERLLIB_EXTRA_SQ)' && \
2099
+ INSTLIBDIR=" $$ INSTLIBDIR$$ {INSTLIBDIR_EXTRA:+:$$ INSTLIBDIR_EXTRA}" && \
2100
+ sed -e ' s=@@PATHSEP@@=$(pathsep)=g' \
2101
+ -e ' s=@@INSTLIBDIR@@=' $$ INSTLIBDIR' =g' \
2102
+ -e ' s=@@PERLLIBDIR@@=' $(perllibdir_SQ ) ' =g' \
2103
+ -e ' s=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \
2104
+ -e ' s=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \
2105
+ -e ' s=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \
2106
+ $< > $@ + && \
2107
+ mv $@ + $@
2008
2108
2009
2109
.PHONY : gitweb
2010
2110
gitweb :
@@ -2149,6 +2249,7 @@ endif
2149
2249
exec_cmd.sp exec_cmd.s exec_cmd.o : GIT-PREFIX
2150
2250
exec_cmd.sp exec_cmd.s exec_cmd.o : EXTRA_CPPFLAGS = \
2151
2251
' -DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
2252
+ ' -DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
2152
2253
' -DBINDIR="$(bindir_relative_SQ)"' \
2153
2254
' -DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
2154
2255
@@ -2326,7 +2427,7 @@ endif
2326
2427
2327
2428
perl/build/lib/% .pm : perl/% .pm
2328
2429
$(QUIET_GEN ) mkdir -p $(dir $@ ) && \
2329
- sed -e ' s|@@LOCALEDIR@@|$(localedir_SQ )|g' \
2430
+ sed -e ' s|@@LOCALEDIR@@|$(perl_localedir_SQ )|g' \
2330
2431
-e ' s|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
2331
2432
< $< > $@
2332
2433
@@ -2801,7 +2902,7 @@ ifndef NO_TCLTK
2801
2902
endif
2802
2903
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2803
2904
$(RM) GIT-USER-AGENT GIT-PREFIX
2804
- $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2905
+ $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT- PYTHON-VARS
2805
2906
ifdef MSVC
2806
2907
$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
2807
2908
$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
0 commit comments