2 # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
3 # Copyright © 2007 Frank Lichtenheld <djpig@debian.org>
4 # Copyright © 2007-2023 Guillem Jover <guillem@debian.org>
8 # Locate a POSIX shell interpreter to use in dpkg. It should support
9 # passing -- after -c for robust argument parsing.
10 AC_DEFUN([DPKG_PROG_SHELL], [
11 AC_ARG_VAR([DPKG_SHELL], [default POSIX shell interpreter used by dpkg])
12 AC_CACHE_CHECK([for a POSIX sh that supports -- after -c], [ac_cv_path_DPKG_SHELL], [
13 AC_PATH_PROGS_FEATURE_CHECK([DPKG_SHELL], [sh dash bsh ksh bash], [
14 shellcheck=$(test -x $ac_path_DPKG_SHELL && \
15 $ac_path_DPKG_SHELL -c -- "echo yes" 2>/dev/null)
16 AS_IF([test "x$shellcheck" = "xyes"], [
17 ac_cv_path_DPKG_SHELL="$(AS_BASENAME([$ac_path_DPKG_SHELL]))"
18 ac_path_DPKG_SHELL_found=:
21 ac_cv_path_DPKG_SHELL=none
24 dnl We could not find any shell supporting --, fallback to sh.
25 AS_IF([test "$ac_cv_path_DPKG_SHELL" = "none"], [
27 dpkg_shell_supports_dash_dash=0
29 DPKG_SHELL=$ac_cv_path_DPKG_SHELL
30 dpkg_shell_supports_dash_dash=1
33 AC_SUBST([DPKG_DEFAULT_SHELL], [$DPKG_SHELL])
34 AC_DEFINE_UNQUOTED([DPKG_DEFAULT_SHELL], ["$DPKG_SHELL"],
35 [POSIX shell interpreter used by dpkg])
36 AC_DEFINE_UNQUOTED([HAVE_DPKG_SHELL_WITH_DASH_DASH],
37 [$dpkg_shell_supports_dash_dash],
38 [POSIX shell interpreter used by dpkg supports -- after -c])
43 # Locate a pager program to use in dpkg, if none are found we default to cat.
44 AC_DEFUN([DPKG_PROG_PAGER], [
45 AC_ARG_VAR([DPKG_PAGER], [default pager program used by dpkg])
46 AC_CHECK_PROGS([DPKG_PAGER], [pager less more], [cat])
48 AC_SUBST([DPKG_DEFAULT_PAGER], [$DPKG_PAGER])
49 AC_DEFINE_UNQUOTED([DPKG_DEFAULT_PAGER], ["$DPKG_PAGER"],
50 [pager program used by dpkg])
55 # Locate perl interpreter in the path
56 AC_DEFUN([DPKG_PROG_PERL], [
57 AC_ARG_VAR([PERL], [Perl interpreter])dnl
58 m4_define([_PERL_MIN_VERSION], [5.32.1])
59 AC_SUBST([PERL_MIN_VERSION], [_PERL_MIN_VERSION])
60 AC_CACHE_CHECK([for perl >= _PERL_MIN_VERSION], [ac_cv_path_PERL], [
61 AC_PATH_PROGS_FEATURE_CHECK([PERL], [perl], [
62 perlcheck=$(test -x $ac_path_PERL && \
63 $ac_path_PERL -MConfig -Mversion -e \
64 'my $r = qv("v$Config{version}") >= qv("_PERL_MIN_VERSION");
66 AS_IF([test "x$perlcheck" = "xyes"], [
67 ac_cv_path_PERL=$ac_path_PERL ac_path_PERL_found=:
70 AC_MSG_ERROR([cannot find perl >= _PERL_MIN_VERSION])
73 AC_SUBST([PERL], [$ac_cv_path_PERL])
74 AC_ARG_VAR([PERL_LIBDIR], [Perl library directory])dnl
75 # Let the user override the variable.
76 AS_IF([test -z "$PERL_LIBDIR"], [
77 PERL_LIBDIR=$($PERL -MConfig -e \
78 'my $r = $Config{vendorlibexp};
79 $r =~ s/$Config{vendorprefixexp}/\$(prefix)/;
82 DPKG_WITH_DIR([perllibdir], [${PERL_LIBDIR}],
83 [perl modules directory])
88 AC_DEFUN([DPKG_PROG_PO4A], [
90 AC_REQUIRE([DPKG_PROG_PERL])
91 AC_ARG_VAR([PO4A], [po4a program])
92 m4_define([_PO4A_MIN_VERSION], [0.59])
93 AC_CACHE_CHECK([for po4a >= _PO4A_MIN_VERSION], [ac_cv_path_PO4A], [
94 AC_PATH_PROGS_FEATURE_CHECK([PO4A], [po4a], [
95 po4aversion=$(LC_ALL=C $ac_path_PO4A --version \
96 | $SED -ne 's/^po4a version \(.*\)\.$/\1/p')
97 AS_VERSION_COMPARE([$po4aversion], [_PO4A_MIN_VERSION],
98 [po4acheck=no], [po4acheck=yes], [po4acheck=yes])
99 AS_IF([test "x$po4acheck" = "xyes"], [
100 ac_cv_path_PO4A=$ac_path_PO4A ac_path_PO4A_found=:
106 AC_SUBST([PO4A], [$ac_cv_path_PO4A])
108 AS_IF([test "$USE_NLS" = "yes" && test "$ac_cv_path_PO4A" != "no"], [
118 AC_DEFUN([DPKG_PROG_POD2MAN], [
119 AC_ARG_VAR([POD2MAN], [pod2man program])
120 AC_CHECK_PROGS([POD2MAN], [pod2man])
121 AM_CONDITIONAL([BUILD_POD_DOC], [test "x$POD2MAN" != "x"])
122 ])# DPKG_PROG_POD2MAN
126 # Specify GNU tar program name to use by dpkg. On GNU systems this is
127 # usually simply tar, on BSD systems this is usually gnutar or gtar.
128 AC_DEFUN([DPKG_PROG_TAR], [
129 AC_ARG_VAR([TAR], [GNU tar program])
130 AC_CHECK_PROGS([TAR], [gnutar gtar tar], [tar])
131 AS_IF([! $TAR --version 2>/dev/null | grep -q '^tar (GNU tar)'], [
132 AC_MSG_ERROR([cannot find a GNU tar program])
134 AC_DEFINE_UNQUOTED([TAR], ["$TAR"], [GNU tar program])
139 # Specify GNU patch program name to use by dpkg-source. On GNU systems this
140 # is usually simply patch, on BSD systems this is usually gpatch.
141 # Even though most invocations would work with other patch implementations,
142 # currently only GNU patch is directory traversal resistant.
143 AC_DEFUN([DPKG_PROG_PATCH], [
144 AC_ARG_VAR([PATCH], [GNU patch program])
145 AC_CHECK_PROGS([PATCH], [gpatch patch], [patch])
146 AS_IF([! $PATCH --version 2>/dev/null | grep -q '^GNU patch'], [
147 AC_MSG_ERROR([cannot find a GNU patch program])
149 AC_DEFINE_UNQUOTED([PATCH], ["$PATCH"], [GNU patch program])