Skip to content

Commit ed1b87e

Browse files
committed
Merge branch 'ab/simplify-perl-makefile'
The build procedure for perl/ part has been greatly simplified by weaning ourselves off of MakeMaker. * ab/simplify-perl-makefile: perl: treat PERLLIB_EXTRA as an extra path again perl: avoid *.pmc and fix Error.pm further Makefile: replace perl/Makefile.PL with simple make rules
2 parents 5be1f00 + 7a7bfc7 commit ed1b87e

File tree

14 files changed

+106
-198
lines changed

14 files changed

+106
-198
lines changed

INSTALL

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,24 @@ Issues of note:
8484

8585
GIT_EXEC_PATH=`pwd`
8686
PATH=`pwd`:$PATH
87-
GITPERLLIB=`pwd`/perl/blib/lib
87+
GITPERLLIB=`pwd`/perl/build/lib
8888
export GIT_EXEC_PATH PATH GITPERLLIB
8989

90+
- By default (unless NO_PERL is provided) Git will ship various perl
91+
scripts & libraries it needs. However, for simplicity it doesn't
92+
use the ExtUtils::MakeMaker toolchain to decide where to place the
93+
perl libraries. Depending on the system this can result in the perl
94+
libraries not being where you'd like them if they're expected to be
95+
used by things other than Git itself.
96+
97+
Manually supplying a perllibdir prefix should fix this, if this is
98+
a problem you care about, e.g.:
99+
100+
prefix=/usr perllibdir=/usr/$(/usr/bin/perl -MConfig -wle 'print substr $Config{installsitelib}, 1 + length $Config{siteprefixexp}')
101+
102+
Will result in e.g. perllibdir=/usr/share/perl/5.26.1 on Debian,
103+
perllibdir=/usr/share/perl5 (which we'd use by default) on CentOS.
104+
90105
- Git is reasonably self-sufficient, but does depend on a few external
91106
programs and libraries. Git can be used without most of them by adding
92107
the approriate "NO_<LIBRARY>=YesPlease" to the make command line or

Makefile

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ all::
294294
#
295295
# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
296296
#
297-
# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
298-
# MakeMaker (e.g. using ActiveState under Cygwin).
299-
#
300297
# Define NO_PERL if you do not want Perl scripts or libraries at all.
301298
#
302299
# Define PYTHON_PATH to the path of your Python binary (often /usr/bin/python
@@ -479,6 +476,7 @@ gitexecdir = libexec/git-core
479476
mergetoolsdir = $(gitexecdir)/mergetools
480477
sharedir = $(prefix)/share
481478
gitwebdir = $(sharedir)/gitweb
479+
perllibdir = $(sharedir)/perl5
482480
localedir = $(sharedir)/locale
483481
template_dir = share/git-core/templates
484482
htmldir = $(prefix)/share/doc/git-doc
@@ -492,7 +490,7 @@ mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
492490
infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
493491
htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
494492

495-
export prefix bindir sharedir sysconfdir gitwebdir localedir
493+
export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir
496494

497495
CC = cc
498496
AR = ar
@@ -1543,9 +1541,6 @@ ifdef SHA1_MAX_BLOCK_SIZE
15431541
LIB_OBJS += compat/sha1-chunked.o
15441542
BASIC_CFLAGS += -DSHA1_MAX_BLOCK_SIZE="$(SHA1_MAX_BLOCK_SIZE)"
15451543
endif
1546-
ifdef NO_PERL_MAKEMAKER
1547-
export NO_PERL_MAKEMAKER
1548-
endif
15491544
ifdef NO_HSTRERROR
15501545
COMPAT_CFLAGS += -DNO_HSTRERROR
15511546
COMPAT_OBJS += compat/hstrerror.o
@@ -1732,8 +1727,10 @@ ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
17321727
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
17331728
bindir_SQ = $(subst ','\'',$(bindir))
17341729
bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
1730+
mandir_SQ = $(subst ','\'',$(mandir))
17351731
mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
17361732
infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
1733+
perllibdir_SQ = $(subst ','\'',$(perllibdir))
17371734
localedir_SQ = $(subst ','\'',$(localedir))
17381735
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
17391736
template_dir_SQ = $(subst ','\'',$(template_dir))
@@ -1843,9 +1840,6 @@ all::
18431840
ifndef NO_TCLTK
18441841
$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
18451842
$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
1846-
endif
1847-
ifndef NO_PERL
1848-
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' localedir='$(localedir_SQ)' all
18491843
endif
18501844
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
18511845

@@ -1928,7 +1922,8 @@ common-cmds.h: $(wildcard Documentation/git-*.txt)
19281922

19291923
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
19301924
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
1931-
$(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP):$(PAGER_ENV)
1925+
$(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP):$(PAGER_ENV):\
1926+
$(perllibdir_SQ)
19321927
define cmd_munge_script
19331928
$(RM) $@ $@+ && \
19341929
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -1972,23 +1967,12 @@ git.res: git.rc GIT-VERSION-FILE
19721967
$(SCRIPT_PERL_GEN): GIT-BUILD-OPTIONS
19731968

19741969
ifndef NO_PERL
1975-
$(SCRIPT_PERL_GEN): perl/perl.mak
1976-
1977-
perl/perl.mak: perl/PM.stamp
1978-
1979-
perl/PM.stamp: FORCE
1980-
@$(FIND) perl -type f -name '*.pm' | sort >$@+ && \
1981-
$(PERL_PATH) -V >>$@+ && \
1982-
{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
1983-
$(RM) $@+
1984-
1985-
perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL
1986-
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
1970+
$(SCRIPT_PERL_GEN):
19871971

1988-
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)
1989-
$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE
1972+
PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ):$(perllibdir_SQ)
1973+
$(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-VERSION-FILE
19901974
$(QUIET_GEN)$(RM) $@ $@+ && \
1991-
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
1975+
INSTLIBDIR='$(perllibdir_SQ)' && \
19921976
INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \
19931977
INSTLIBDIR="$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}" && \
19941978
sed -e '1{' \
@@ -2312,6 +2296,21 @@ endif
23122296
po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
23132297
$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
23142298

2299+
LIB_PERL := $(wildcard perl/Git.pm perl/Git/*.pm perl/Git/*/*.pm perl/Git/*/*/*.pm)
2300+
LIB_PERL_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_PERL))
2301+
2302+
ifndef NO_PERL
2303+
all:: $(LIB_PERL_GEN)
2304+
endif
2305+
2306+
perl/build/lib/%.pm: perl/%.pm
2307+
$(QUIET_GEN)mkdir -p $(dir $@) && \
2308+
sed -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' < $< > $@
2309+
2310+
perl/build/man/man3/Git.3pm: perl/Git.pm
2311+
$(QUIET_GEN)mkdir -p $(dir $@) && \
2312+
pod2man $< $@
2313+
23152314
FIND_SOURCE_FILES = ( \
23162315
git ls-files \
23172316
'*.[hcS]' \
@@ -2572,7 +2571,9 @@ ifndef NO_GETTEXT
25722571
(cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
25732572
endif
25742573
ifndef NO_PERL
2575-
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
2574+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
2575+
(cd perl/build/lib && $(TAR) cf - .) | \
2576+
(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
25762577
$(MAKE) -C gitweb install
25772578
endif
25782579
ifndef NO_TCLTK
@@ -2622,12 +2623,17 @@ endif
26222623
install-gitweb:
26232624
$(MAKE) -C gitweb install
26242625

2625-
install-doc:
2626+
install-doc: install-man-perl
26262627
$(MAKE) -C Documentation install
26272628

2628-
install-man:
2629+
install-man: install-man-perl
26292630
$(MAKE) -C Documentation install-man
26302631

2632+
install-man-perl: perl/build/man/man3/Git.3pm
2633+
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3'
2634+
(cd perl/build/man/man3 && $(TAR) cf - .) | \
2635+
(cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR) xof -)
2636+
26312637
install-html:
26322638
$(MAKE) -C Documentation install-html
26332639

@@ -2719,7 +2725,7 @@ clean: profile-clean coverage-clean
27192725
$(MAKE) -C Documentation/ clean
27202726
ifndef NO_PERL
27212727
$(MAKE) -C gitweb clean
2722-
$(MAKE) -C perl clean
2728+
$(RM) -r perl/build/
27232729
endif
27242730
$(MAKE) -C templates/ clean
27252731
$(MAKE) -C t/ clean

contrib/examples/git-difftool.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use 5.008;
1414
use strict;
1515
use warnings;
16-
use Error qw(:try);
16+
use Git::Error qw(:try);
1717
use File::Basename qw(dirname);
1818
use File::Copy;
1919
use File::Find;

git-send-email.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use Term::ANSIColor;
2727
use File::Temp qw/ tempdir tempfile /;
2828
use File::Spec::Functions qw(catdir catfile);
29-
use Error qw(:try);
29+
use Git::Error qw(:try);
3030
use Cwd qw(abs_path cwd);
3131
use Git;
3232
use Git::I18N;

perl/.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
perl.mak
2-
perl.mak.old
3-
MYMETA.json
4-
MYMETA.yml
5-
blib
6-
blibdirs
7-
pm_to_blib
8-
PM.stamp
1+
/build/

perl/Git.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ increase notwithstanding).
101101

102102

103103
use Carp qw(carp croak); # but croak is bad - throw instead
104-
use Error qw(:try);
104+
use Git::Error qw(:try);
105105
use Cwd qw(abs_path cwd);
106106
use IPC::Open2 qw(open2);
107107
use Fcntl qw(SEEK_SET SEEK_CUR);

perl/Git/Error.pm

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package Git::Error;
2+
use 5.008;
3+
use strict;
4+
use warnings;
5+
6+
=head1 NAME
7+
8+
Git::Error - Wrapper for the L<Error> module, in case it's not installed
9+
10+
=head1 DESCRIPTION
11+
12+
Wraps the import function for the L<Error> module.
13+
14+
This module is only intended to be used for code shipping in the
15+
C<git.git> repository. Use it for anything else at your peril!
16+
17+
=cut
18+
19+
sub import {
20+
shift;
21+
my $caller = caller;
22+
23+
eval {
24+
require Error;
25+
1;
26+
} or do {
27+
my $error = $@ || "Zombie Error";
28+
29+
my $Git_Error_pm_path = $INC{"Git/Error.pm"} || die "BUG: Should have our own path from %INC!";
30+
31+
require File::Basename;
32+
my $Git_Error_pm_root = File::Basename::dirname($Git_Error_pm_path) || die "BUG: Can't figure out lib/Git dirname from '$Git_Error_pm_path'!";
33+
34+
require File::Spec;
35+
my $Git_pm_FromCPAN_root = File::Spec->catdir($Git_Error_pm_root, 'FromCPAN');
36+
die "BUG: '$Git_pm_FromCPAN_root' should be a directory!" unless -d $Git_pm_FromCPAN_root;
37+
38+
local @INC = ($Git_pm_FromCPAN_root, @INC);
39+
require Error;
40+
};
41+
42+
unshift @_, $caller;
43+
goto &Error::import;
44+
}
45+
46+
1;

perl/Git/I18N.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ our @EXPORT_OK = @EXPORT;
1818

1919
sub __bootstrap_locale_messages {
2020
our $TEXTDOMAIN = 'git';
21-
our $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '++LOCALEDIR++';
21+
our $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '@@LOCALEDIR@@';
2222

2323
require POSIX;
2424
POSIX->import(qw(setlocale));

perl/Makefile

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)