From e2786de8c6c82d00b450faecff662d585f932286 Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Date: Sun, 24 Apr 2022 13:28:11 +0200
Subject: Add check to autogen.sh for required tools

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 autogen.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/autogen.sh b/autogen.sh
index c08fadf..34b6978 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,3 +1,50 @@
 #!/bin/sh
 
+DIE=0
+
+(autoreconf --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have autoconf installed to compile this package."
+	echo "Download the appropriate package for your distribution,"
+	echo "or see http://www.gnu.org/software/autoconf"
+	DIE=1
+}
+
+(libtoolize --version) < /dev/null > /dev/null 2>&1 ||
+(glibtoolize --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have libtool installed to compile this package."
+	echo "Download the appropriate package for your distribution,"
+	echo "or see http://www.gnu.org/software/libtool"
+	DIE=1
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have automake installed to compile this package."
+	echo "Download the appropriate package for your distribution,"
+	echo "or see http://www.gnu.org/software/automake"
+	DIE=1
+}
+
+if ! test -f "$(aclocal --print-ac-dir)"/pkg.m4; then
+	echo
+	echo "You must have pkg-config installed to compile this package."
+	echo "Download the appropriate package for your distribution,"
+	echo "or see https://www.freedesktop.org/wiki/Software/pkg-config/"
+	DIE=1
+fi
+
+if test "$DIE" -eq 1; then
+	exit 1
+fi
+
 autoreconf --force --install --symlink
+
+if ! grep -q pkg.m4 aclocal.m4; then
+	cat <<EOF
+Couldn't find pkg.m4 from pkg-config. Install the appropriate package for
+your distribution or set ACLOCAL_PATH to the directory containing pkg.m4.
+EOF
+	exit 1
+fi
-- 
cgit v1.2.3