Skip to content

Commit f6a0ad4

Browse files
danjacquesgitster
authored andcommitted
Makefile: generate Perl header from template file
Currently, the generated Perl script headers are emitted by commands in the Makefile. This mechanism restricts options to introduce alternative header content, needed by Perl runtime prefix support, and obscures the origin of the Perl script header. Change the Makefile to generate a header by processing a template file and move the header content into the "perl/" subdirectory. The generated header content will now be stored in the "GIT-PERL-HEADER" file. This allows the content of the Perl header to be controlled by changing the path of the template in the Makefile. Signed-off-by: Dan Jacques <[email protected]> Thanks-to: Ævar Arnfjörð Bjarmason <[email protected]> Thanks-to: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b026ed commit f6a0ad4

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/GIT-LDFLAGS
44
/GIT-PREFIX
55
/GIT-PERL-DEFINES
6+
/GIT-PERL-HEADER
67
/GIT-PYTHON-VARS
78
/GIT-SCRIPT-DEFINES
89
/GIT-USER-AGENT

Makefile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,20 +1987,15 @@ git.res: git.rc GIT-VERSION-FILE
19871987
$(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS
19881988

19891989
ifndef NO_PERL
1990-
$(SCRIPT_PERL_GEN):
1991-
1990+
PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
19921991
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ)
1993-
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-VERSION-FILE
1992+
1993+
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
19941994
$(QUIET_GEN)$(RM) $@ $@+ && \
1995-
INSTLIBDIR='$(perllibdir_SQ)' && \
1996-
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
1997-
INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
19981995
sed -e '1{' \
19991996
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
2000-
-e ' h' \
2001-
-e ' s=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || "'"$$INSTLIBDIR"'"));=' \
2002-
-e ' H' \
2003-
-e ' x' \
1997+
-e ' rGIT-PERL-HEADER' \
1998+
-e ' G' \
20041999
-e '}' \
20052000
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
20062001
$< >$@+ && \
@@ -2014,6 +2009,16 @@ GIT-PERL-DEFINES: FORCE
20142009
echo "$$FLAGS" >$@; \
20152010
fi
20162011

2012+
GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
2013+
$(QUIET_GEN)$(RM) $@ && \
2014+
INSTLIBDIR='$(perllibdir_SQ)' && \
2015+
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
2016+
INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
2017+
sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
2018+
-e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \
2019+
-e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \
2020+
$< >$@+ && \
2021+
mv $@+ $@
20172022

20182023
.PHONY: gitweb
20192024
gitweb:
@@ -2793,7 +2798,7 @@ ifndef NO_TCLTK
27932798
endif
27942799
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
27952800
$(RM) GIT-USER-AGENT GIT-PREFIX
2796-
$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2801+
$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
27972802

27982803
.PHONY: all install profile-clean clean strip
27992804
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || '@@INSTLIBDIR@@'));

0 commit comments

Comments
 (0)