Merge branch 'wip202511-ft-tar-m4' into 'master'

Draft: Add ft_tar.m4: FT_PROG_TAR, a substitution of _AM_PROG_TAR.

See merge request freetype/freetype!403
This commit is contained in:
suzuki toshiya 2025-11-23 05:38:08 +00:00
commit c631ab7733
4 changed files with 116 additions and 6 deletions

View file

@ -229,20 +229,22 @@ work :=
# Not to be run by a normal user -- there are no attempts to make it
# generic.
TAR_CHF_ ?= tar --format=ustar -chf - $${tardir}
dist:
-rm -rf tmp
rm -f freetype-$(version).tar.gz
rm -f freetype-$(version).tar.xz
rm -f ft$(winversion).zip
for d in `find . -wholename '*/.git' -prune \
for d in `find . -name '.git' -prune \
-o -type f \
-o -print` ; do \
mkdir -p tmp/$$d ; \
done ;
currdir=`pwd` ; \
for f in `find . -wholename '*/.git' -prune \
for f in `find . -name '.git' -prune \
-o -name .gitattributes \
-o -name .gitignore \
-o -name .gitlab-ci.yml \
@ -259,10 +261,8 @@ dist:
mv tmp freetype-$(version)
tar --format=ustar -chf - freetype-$(version) \
| gzip -9 -c > freetype-$(version).tar.gz
tar --format=ustar -chf - freetype-$(version) \
| xz -c > freetype-$(version).tar.xz
tardir=freetype-$(version) && $(TAR_CHF_) | gzip -9 -c > freetype-$(version).tar.gz
tardir=freetype-$(version) && $(TAR_CHF_) | xz -c > freetype-$(version).tar.xz
@# Use CR/LF for zip files.
zip -lr9 ft$(winversion).zip freetype-$(version)

View file

@ -1015,6 +1015,11 @@ esac
AX_PTHREAD([have_pthread=yes], [have_pthread=no])
# Check for tar for "make dist"
FT_PROG_TAR([gnutar gtar bsdtar tar pax cpio])
TAR_CHF_="${ft_tar_chf_}"
AC_SUBST([TAR_CHF_])
# Check for Python and docwriter
PYTHON_MIN_VERSION=3.5
have_py3=no

101
builds/unix/ft_tar.m4 Normal file
View file

@ -0,0 +1,101 @@
dnl
dnl This is a cloning of _AM_PROG_TAR in aclocal/tar.m4,
dnl although its namespace is FT_XXX.
dnl
dnl
dnl FT_PROG_TAR()
dnl $1 = space separated commands to be tried
dnl (default: gnutar gtar bsdtar tar pax cpio)
dnl
dnl The tested results are recorded in:
dnl ft_tar_cmd: the command to emit POSIX ustar
dnl it can be the commands whose syntax
dnl is incompatible with tar - like,
dnl pax or cpio.
dnl ft_tar_flags: the options to emit POSIX ustar
dnl ft_tar_chf_: the command with flags to emit
dnl ustar bitstream from $(tardir)
dnl to STDOUT.
dnl ft_tar_xf_: the command with flags to extract
dnl ustar bitstream from STDIN.
dnl
dnl Example of usage in configure.ac
dnl
dnl FT_PROG_TAR([gnutar gtar bsdtar tar pax cpio])
dnl AC_SUBST([TAR_CHF_],[${ft_tar_chf_}])
dnl AC_SUBST([UNTAR_XF_],[${ft_tar_xf_}])
dnl
dnl Example of usage in Makefile.am
dnl
dnl freetype-$(version).tar:
dnl ...
dnl tardir=freetype-$(version) && $(TAR_CHF_) > $@
dnl
dnl
AC_DEFUN([FT_PROG_TAR],[
tar_candidates="$1"
if test -z "${tar_candidates}"
then
tar_candidates="gnutar gtar bsdtar tar pax cpio"
fi
AC_MSG_CHECKING([tar supporting ustar and following symlink])
unset ft_tarflags
for ft_tar_cmd in ${tar_candidates}
do
case ${ft_tar_cmd} in
*tar)
ft_tar_cflags="--format=ustar -chf -"
ft_tar_xflags="--format=ustar -xf -"
;;
*pax)
ft_tar_cflags="-w -x ustar -L"
ft_tar_xflags="-r"
;;
*cpio)
ft_tar_cflags="-o -H ustar -L"
ft_tar_xflags="-i -H ustar"
;;
*)
AC_MSG_WARN([cannot test ${ft_tar_cmd}])
continue
;;
esac
if expr "${ft_tar_cmd}" : ".*cpio" > /dev/null
then
ft_tar_ok=`(echo . | ${ft_tar_cmd} ${ft_tar_cflags} > /dev/null 2>/dev/null && echo yes) || echo no`
ft_tar_chf_='find $${tardir} -print | '"${ft_tar_cmd} ${ft_tar_cflags}"
else
ft_tar_ok=`(${ft_tar_cmd} ${ft_tar_cflags} . > /dev/null 2>/dev/null && echo yes) || echo no`
ft_tar_chf_="${ft_tar_cmd} ${ft_tar_cflags} "'$${tardir}'
fi
if test "x${ft_tar_ok}" = xyes
then
AC_MSG_RESULT([found, "${ft_tar_cmd} ${ft_tar_cflags}"])
break
fi
done
if test "x${ft_tar_ok}" != xyes
then
AC_MSG_RESULT([not found, fallback plain tar])
unset ft_tar_cmd
AC_CHECK_PROG([ft_tar_cmd],[tar],[tar],[false])
if test "x${ft_tar_cmd}" = xtar
then
ft_tar_cflags="chf -"
ft_tar_xflags="xf -"
ft_tar_chf_='tar chf - $${tardir}'
ft_tar_xf_='tar xf -'
else
AC_MSG_WARN(["tar" command is missing, "make dist" will fail])
ft_tar_cflags=""
ft_tar_xflags=""
ft_tar_chf_=false
ft_tar_xf_=false
fi
fi
])

View file

@ -21,6 +21,10 @@ DELDIR := rm -rf
CAT := cat
SEP := /
# This is used for `make dist'
#
TAR_CHF_ := @TAR_CHF_@
# This is used for `make refdoc' and `make refdoc-venv'
#
PYTHON := @PYTHON@