$NetBSD: patch-Makefile,v 1.7 2023/06/09 12:05:14 riastradh Exp $

Do not override compiler/linker flags.
Provide proper path for Perl module.
New target for building Perl libraries.
Do not install git-p4 (requires Python).
Fix tar operations.

--- Makefile.orig	2023-06-01 07:03:05.000000000 +0000
+++ Makefile
@@ -612,7 +612,7 @@ mergetoolsdir = $(gitexecdir)/mergetools
 sharedir = $(prefix)/share
 gitwebdir = $(sharedir)/gitweb
 gitwebstaticdir = $(gitwebdir)/static
-perllibdir = $(sharedir)/perl5
+perllibdir = ${PERLLIBDIR}
 localedir = $(sharedir)/locale
 template_dir = share/git-core/templates
 htmldir = $(prefix)/share/doc/git-doc
@@ -633,13 +633,9 @@ perllibdir_relative = $(patsubst $(prefi
 export prefix bindir sharedir sysconfdir perllibdir localedir
 
 # Set our default programs
-CC = cc
-AR = ar
 RM = rm -f
 DIFF = diff
-TAR = tar
 FIND = find
-INSTALL = install
 TCL_PATH = tclsh
 TCLTK_PATH = wish
 XGETTEXT = xgettext
@@ -744,7 +740,6 @@ clean-python-script:
 
 SCRIPTS = $(SCRIPT_SH_GEN) \
 	  $(SCRIPT_PERL_GEN) \
-	  $(SCRIPT_PYTHON_GEN) \
 	  git-instaweb
 
 ETAGS_TARGET = TAGS
@@ -2304,8 +2299,8 @@ ifdef DEFAULT_HELP_FORMAT
 BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
 endif
 
-ALL_CFLAGS += $(BASIC_CFLAGS)
-ALL_LDFLAGS += $(BASIC_LDFLAGS)
+ALL_CFLAGS = $(BASIC_CFLAGS) $(CPPFLAGS) $(CFLAGS)
+ALL_LDFLAGS = $(BASIC_LDFLAGS) $(LDFLAGS)
 
 export DIFF TAR INSTALL DESTDIR SHELL_PATH
 
@@ -3018,6 +3013,7 @@ endif
 NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS))
 endif
 
+build-perl-libs: $(LIB_PERL_GEN) $(LIB_CPAN_GEN)
 perl/build/lib/%.pm: perl/%.pm GIT-PERL-DEFINES
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN) \
@@ -3457,12 +3453,12 @@ endif
 ifndef NO_GETTEXT
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(localedir_SQ)'
 	(cd po/build/locale && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xof -)
+	(cd '$(DESTDIR_SQ)$(localedir_SQ)' && umask 022 && $(TAR) xf -)
 endif
 ifndef NO_PERL
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perllibdir_SQ)'
 	(cd perl/build/lib && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xof -)
+	(cd '$(DESTDIR_SQ)$(perllibdir_SQ)' && umask 022 && $(TAR) xf -)
 endif
 ifndef NO_TCLTK
 	$(MAKE) -C gitk-git install
@@ -3529,7 +3525,7 @@ install-man: install-man-perl
 install-man-perl: man-perl
 	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3'
 	(cd perl/build/man/man3 && $(TAR) cf - .) | \
-	(cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR) xof -)
+	(cd '$(DESTDIR_SQ)$(mandir_SQ)/man3' && umask 022 && $(TAR) xf -)
 
 install-html:
 	$(MAKE) -C Documentation install-html
