@@ -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 )
@@ -494,7 +519,10 @@ pathsep = :
494
519
495
520
mandir_relative = $(patsubst $(prefix ) /% ,% ,$(mandir ) )
496
521
infodir_relative = $(patsubst $(prefix ) /% ,% ,$(infodir ) )
522
+ gitexecdir_relative = $(patsubst $(prefix ) /% ,% ,$(gitexecdir ) )
523
+ localedir_relative = $(patsubst $(prefix ) /% ,% ,$(localedir ) )
497
524
htmldir_relative = $(patsubst $(prefix ) /% ,% ,$(htmldir ) )
525
+ perllibdir_relative = $(patsubst $(prefix ) /% ,% ,$(perllibdir ) )
498
526
499
527
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
500
528
@@ -1653,10 +1681,27 @@ ifdef HAVE_BSD_SYSCTL
1653
1681
BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
1654
1682
endif
1655
1683
1684
+ ifdef HAVE_BSD_KERN_PROC_SYSCTL
1685
+ BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
1686
+ endif
1687
+
1656
1688
ifdef HAVE_GETDELIM
1657
1689
BASIC_CFLAGS += -DHAVE_GETDELIM
1658
1690
endif
1659
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
+
1660
1705
ifeq ($(TCLTK_PATH ) ,)
1661
1706
NO_TCLTK = NoThanks
1662
1707
endif
@@ -1741,10 +1786,12 @@ mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
1741
1786
infodir_relative_SQ = $(subst ','\'',$(infodir_relative ) )
1742
1787
perllibdir_SQ = $(subst ','\'',$(perllibdir ) )
1743
1788
localedir_SQ = $(subst ','\'',$(localedir ) )
1789
+ localedir_relative_SQ = $(subst ','\'',$(localedir_relative ) )
1744
1790
gitexecdir_SQ = $(subst ','\'',$(gitexecdir ) )
1745
1791
template_dir_SQ = $(subst ','\'',$(template_dir ) )
1746
1792
htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative ) )
1747
1793
prefix_SQ = $(subst ','\'',$(prefix ) )
1794
+ perllibdir_relative_SQ = $(subst ','\'',$(perllibdir_relative ) )
1748
1795
gitwebdir_SQ = $(subst ','\'',$(gitwebdir ) )
1749
1796
1750
1797
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH ) )
@@ -1755,6 +1802,31 @@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
1755
1802
DIFF_SQ = $(subst ','\'',$(DIFF ) )
1756
1803
PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA ) )
1757
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
+
1758
1830
# We must filter out any object files from $(GITLIBS),
1759
1831
# as it is typically used like:
1760
1832
#
@@ -1975,34 +2047,64 @@ git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
1975
2047
# This makes sure we depend on the NO_PERL setting itself.
1976
2048
$(SCRIPT_PERL_GEN ) : GIT-BUILD-OPTIONS
1977
2049
1978
- ifndef NO_PERL
1979
- $(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 )
1980
2053
2054
+ ifndef NO_PERL
2055
+ PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
1981
2056
PERL_DEFINES = $(PERL_PATH_SQ ) :$(PERLLIB_EXTRA_SQ ) :$(perllibdir_SQ )
1982
- $(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
1983
2076
$(QUIET_GEN )$(RM ) $@ $@ + && \
1984
- INSTLIBDIR=' $(perllibdir_SQ)' && \
1985
- INSTLIBDIR_EXTRA=' $(PERLLIB_EXTRA_SQ)' && \
1986
- INSTLIBDIR=" $$ INSTLIBDIR$$ {INSTLIBDIR_EXTRA:+:$$ INSTLIBDIR_EXTRA}" && \
1987
2077
sed -e ' 1{' \
1988
2078
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
1989
- -e ' h' \
1990
- -e ' s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "' " $$ INSTLIBDIR" ' "));=' \
1991
- -e ' H' \
1992
- -e ' x' \
2079
+ -e ' rGIT-PERL-HEADER' \
2080
+ -e ' G' \
1993
2081
-e ' }' \
1994
2082
-e ' s/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1995
2083
$< > $@ + && \
1996
2084
chmod +x $@ + && \
1997
2085
mv $@ + $@
1998
2086
2087
+ PERL_DEFINES := $(subst $(space ) ,:,$(PERL_DEFINES ) )
1999
2088
GIT-PERL-DEFINES : FORCE
2000
2089
@FLAGS=' $(PERL_DEFINES)' ; \
2001
2090
if test x" $$ FLAGS" ! = x" ` cat $@ 2> /dev/null` " ; then \
2002
2091
echo >&2 " * new perl-specific parameters" ; \
2003
2092
echo " $$ FLAGS" > $@ ; \
2004
2093
fi
2005
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 $@ + $@
2006
2108
2007
2109
.PHONY : gitweb
2008
2110
gitweb :
@@ -2147,6 +2249,7 @@ endif
2147
2249
exec_cmd.sp exec_cmd.s exec_cmd.o : GIT-PREFIX
2148
2250
exec_cmd.sp exec_cmd.s exec_cmd.o : EXTRA_CPPFLAGS = \
2149
2251
' -DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
2252
+ ' -DGIT_LOCALE_PATH="$(localedir_relative_SQ)"' \
2150
2253
' -DBINDIR="$(bindir_relative_SQ)"' \
2151
2254
' -DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
2152
2255
@@ -2164,7 +2267,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \
2164
2267
2165
2268
gettext.sp gettext.s gettext.o : GIT-PREFIX
2166
2269
gettext.sp gettext.s gettext.o : EXTRA_CPPFLAGS = \
2167
- -DGIT_LOCALE_PATH=' "$(localedir_SQ )"'
2270
+ -DGIT_LOCALE_PATH=' "$(localedir_relative_SQ )"'
2168
2271
2169
2272
http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp : SPARSE_FLAGS += \
2170
2273
-DCURL_DISABLE_TYPECHECK
@@ -2324,7 +2427,7 @@ endif
2324
2427
2325
2428
perl/build/lib/% .pm : perl/% .pm
2326
2429
$(QUIET_GEN ) mkdir -p $(dir $@ ) && \
2327
- sed -e ' s|@@LOCALEDIR@@|$(localedir_SQ )|g' \
2430
+ sed -e ' s|@@LOCALEDIR@@|$(perl_localedir_SQ )|g' \
2328
2431
-e ' s|@@NO_PERL_CPAN_FALLBACKS@@|$(NO_PERL_CPAN_FALLBACKS_SQ)|g' \
2329
2432
< $< > $@
2330
2433
@@ -2799,7 +2902,7 @@ ifndef NO_TCLTK
2799
2902
endif
2800
2903
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
2801
2904
$(RM) GIT-USER-AGENT GIT-PREFIX
2802
- $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2905
+ $(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT- PYTHON-VARS
2803
2906
ifdef MSVC
2804
2907
$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
2805
2908
$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
0 commit comments