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