1#!/bin/sh
2#set -x
3# helps bootstrapping am-utils, when checked out from CVS
4# requires GNU autoconf and GNU automake
5# this is not meant to go into the distributions
6# Erez Zadok <ezk@cs.columbia.edu>
7
8validateversion() {
9    local v="$(autoreconf --version 2>&1 | head -1)"
10    case "$v" in
11    *2.69)	;;
12    *)		echo "am-utils requires autoconf 2.69, you have:"
13		echo "	$v"
14		exit 1;;
15    esac
16}
17
18# test cwd
19test -f ../amd/amd.c && cd ..
20if [ ! -f amd/amd.c ]; then
21    echo "Must run $0 from the top level source directory."
22    exit 1
23fi
24
25# validate macros directory and some macro files
26if [ ! -d m4/macros ]; then
27    echo No m4/macros directory found!
28    exit 1
29fi
30if [ ! -f m4/macros/HEADER ]; then
31    echo No m4/macros/HEADER file found!
32    exit 1
33fi
34
35# remove any remaining autom4te.cache directory
36rm -fr autom4te.cache autom4te-*.cache
37
38# generate acinclude.m4 file
39echo "AMU: prepare acinclude.m4..."
40test -f acinclude.m4 && mv -f acinclude.m4 acinclude.m4.old
41(cd m4/macros
42 for i in HEADER *.m4; do
43     cat $i
44     echo
45     echo
46 done
47 cat TRAILER
48) > acinclude.m4
49
50# generate the rest of the scripts
51echo "AMU: autoreconf..."
52validateversion
53if autoreconf -f -i; then
54    :
55else
56    echo "autoreconf command failed.  fix errors and rerun $0."
57    exit 2
58fi
59
60# save timestamp
61echo "AMU: save timestamp..."
62echo timestamp > stamp-h.in
63
64exit 0
65