Skip to content

Commit 4d643f7

Browse files
danjacquesdscho
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]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 346c957 commit 4d643f7

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
@@ -1976,20 +1976,15 @@ git.res: git.rc GIT-VERSION-FILE GIT-PREFIX
19761976
$(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS
19771977

19781978
ifndef NO_PERL
1979-
$(SCRIPT_PERL_GEN):
1980-
1979+
PERL_HEADER_TEMPLATE = perl/header_templates/fixed_prefix.template.pl
19811980
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ)
1982-
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-VERSION-FILE
1981+
1982+
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE
19831983
$(QUIET_GEN)$(RM) $@ $@+ && \
1984-
INSTLIBDIR='$(perllibdir_SQ)' && \
1985-
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
1986-
INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
19871984
sed -e '1{' \
19881985
-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' \
1986+
-e ' rGIT-PERL-HEADER' \
1987+
-e ' G' \
19931988
-e '}' \
19941989
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
19951990
$< >$@+ && \
@@ -2003,6 +1998,16 @@ GIT-PERL-DEFINES: FORCE
20031998
echo "$$FLAGS" >$@; \
20041999
fi
20052000

2001+
GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile
2002+
$(QUIET_GEN)$(RM) $@ && \
2003+
INSTLIBDIR='$(perllibdir_SQ)' && \
2004+
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
2005+
INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
2006+
sed -e 's=@@PATHSEP@@=$(pathsep)=g' \
2007+
-e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \
2008+
-e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \
2009+
$< >$@+ && \
2010+
mv $@+ $@
20062011

20072012
.PHONY: gitweb
20082013
gitweb:
@@ -2799,7 +2804,7 @@ ifndef NO_TCLTK
27992804
endif
28002805
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
28012806
$(RM) GIT-USER-AGENT GIT-PREFIX
2802-
$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS
2807+
$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS
28032808
ifdef MSVC
28042809
$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
28052810
$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
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)