xref: /netbsd-src/external/gpl2/grep/dist/autogen.sh (revision a8fa202a6440953be7b92a8960a811bff58203f4)
1#!/bin/sh
2# We want to support both legacy and current autoconf - this is a bit ugly...
3AC_VERSION=`autoconf --version 2>&1 |head -n1 |sed -e "s/.* //;s/\.//;s/[a-z]//"`
4if test -z "$AC_VERSION"; then
5	echo "Warning: Couldn't determine autoconf version. Assuming a current version."
6	AC_VERSION=252
7fi
8if test "$AC_VERSION" -lt 250; then
9	rm -f acinclude.m4
10	echo "#undef ssize_t" >acconfig.h
11	for i in m4/*.m4; do
12		if cat $i |grep -q "jm_"; then
13			cat $i >>acinclude.m4
14		elif test ! -e `aclocal --print-ac-dir`/`basename $i`; then
15			cat $i >>acinclude.m4
16		fi
17	done
18	aclocal
19else
20	aclocal -I m4
21fi
22autoheader
23automake -a
24if test "$AC_VERSION" -lt 250; then
25	# Workaround for a bug in ancient versions of autoheader
26	sed -e 's,#undef $,/* your autoheader is buggy */,g' config.hin >config.hin.new
27	rm config.hin
28	mv config.hin.new config.hin
29	# Make sure config.hin doesn't get rebuilt after the workaround
30	sed -e 's,@AUTOHEADER@,true,' Makefile.in >Makefile.in.new
31	rm Makefile.in
32	mv Makefile.in.new Makefile.in
33fi
34autoconf
35