1119679Smbr#!/bin/sh
2119679Smbr#set -x
3119679Smbr# helps bootstrapping am-utils, when checked out from CVS
4119679Smbr# requires GNU autoconf and GNU automake
5119679Smbr# this is not meant to go into the distributions
6119679Smbr# Erez Zadok <ezk@cs.columbia.edu>
7119679Smbr
8310490Scyvalidateversion() {
9310490Scy    local v="$(autoreconf --version 2>&1 | head -1)"
10310490Scy    case "$v" in
11310490Scy    *2.69)	;;
12310490Scy    *)		echo "am-utils requires autoconf 2.69, you have:"
13310490Scy		echo "	$v"
14310490Scy		exit 1;;
15310490Scy    esac
16310490Scy}
17310490Scy
18119679Smbr# test cwd
19119679Smbrtest -f ../amd/amd.c && cd ..
20119679Smbrif [ ! -f amd/amd.c ]; then
21119679Smbr    echo "Must run $0 from the top level source directory."
22119679Smbr    exit 1
23119679Smbrfi
24119679Smbr
25119679Smbr# validate macros directory and some macro files
26119679Smbrif [ ! -d m4/macros ]; then
27119679Smbr    echo No m4/macros directory found!
28119679Smbr    exit 1
29119679Smbrfi
30119679Smbrif [ ! -f m4/macros/HEADER ]; then
31119679Smbr    echo No m4/macros/HEADER file found!
32119679Smbr    exit 1
33119679Smbrfi
34119679Smbr
35119679Smbr# remove any remaining autom4te.cache directory
36174294Sobrienrm -fr autom4te.cache autom4te-*.cache
37119679Smbr
38119679Smbr# generate acinclude.m4 file
39119679Smbrecho "AMU: prepare acinclude.m4..."
40119679Smbrtest -f acinclude.m4 && mv -f acinclude.m4 acinclude.m4.old
41119679Smbr(cd m4/macros
42119679Smbr for i in HEADER *.m4; do
43119679Smbr     cat $i
44119679Smbr     echo
45119679Smbr     echo
46119679Smbr done
47119679Smbr cat TRAILER
48119679Smbr) > acinclude.m4
49119679Smbr
50310490Scy# generate the rest of the scripts
51310490Scyecho "AMU: autoreconf..."
52310490Scyvalidateversion
53310490Scyif autoreconf -f -i; then
54119679Smbr    :
55119679Smbrelse
56310490Scy    echo "autoreconf command failed.  fix errors and rerun $0."
57119679Smbr    exit 2
58119679Smbrfi
59119679Smbr
60119679Smbr# save timestamp
61119679Smbrecho "AMU: save timestamp..."
62119679Smbrecho timestamp > stamp-h.in
63119679Smbr
64119679Smbrexit 0
65