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
8119679Smbr# test cwd
9119679Smbrtest -f ../amd/amd.c && cd ..
10119679Smbrif [ ! -f amd/amd.c ]; then
11119679Smbr    echo "Must run $0 from the top level source directory."
12119679Smbr    exit 1
13119679Smbrfi
14119679Smbr
15119679Smbr# validate macros directory and some macro files
16119679Smbrif [ ! -d m4/macros ]; then
17119679Smbr    echo No m4/macros directory found!
18119679Smbr    exit 1
19119679Smbrfi
20119679Smbrif [ ! -f m4/macros/HEADER ]; then
21119679Smbr    echo No m4/macros/HEADER file found!
22119679Smbr    exit 1
23119679Smbrfi
24119679Smbr
25119679Smbr# remove any remaining autom4te.cache directory
26174294Sobrienrm -fr autom4te.cache autom4te-*.cache
27119679Smbr
28119679Smbr# generate acinclude.m4 file
29119679Smbrecho "AMU: prepare acinclude.m4..."
30119679Smbrtest -f acinclude.m4 && mv -f acinclude.m4 acinclude.m4.old
31119679Smbr(cd m4/macros
32119679Smbr for i in HEADER *.m4; do
33119679Smbr     cat $i
34119679Smbr     echo
35119679Smbr     echo
36119679Smbr done
37119679Smbr cat TRAILER
38119679Smbr) > acinclude.m4
39119679Smbr
40119679Smbr# generate aclocal.m4 file
41119679Smbrecho "AMU: aclocal..."
42119679Smbrtest -f aclocal.m4 && mv -f aclocal.m4 aclocal.m4.old
43119679Smbr# show version
44119679Smbraclocal --version 2>&1 | head -1
45119679Smbrif aclocal ; then
46119679Smbr    :
47119679Smbrelse
48119679Smbr    echo "aclocal command failed.  fix errors and rerun $0."
49119679Smbr    exit 2
50119679Smbrfi
51119679Smbr
52119679Smbr# produce new configure.in (temp) script
53119679Smbrecho "AMU: autoconf..."
54119679Smbr# show version
55119679Smbrautoconf --version 2>&1 | head -1
56119679SmbrLOG=/tmp/amu-$$.log
57119679Smbrrm -f ${LOG}
58119679Smbrautoconf configure.in > configure.new 2> ${LOG}
59119679Smbr# until Automake requires Autoconf 2.50, manual says to ignore this
60119679SmbrCUTWARNMSG1="warning: AC_PROG_LEX invoked multiple times|do not use m4_(patsubst|regexp):"
61119679Smbregrep -v "${CUTWARNMSG1}" ${LOG} > ${LOG}.new
62119679Smbrmv ${LOG}.new ${LOG}
63119679Smbrif test -s ${LOG}; then
64119679Smbr    echo "AUTOCONF ERRORS (MUST FIX):"
65119679Smbr    cat ${LOG}
66119679Smbr    rm -f ${LOG}
67119679Smbr    exit 2
68119679Smbrfi
69119679Smbr# now prepare the real configure script
70131702Smbrtest -f configure && mv -f configure configure.old
71119679Smbrmv -f configure.new configure
72119679Smbrchmod a+rx configure
73119679Smbrrm -f configure.old
74119679Smbr
75119679Smbr# run autoheader to produce C header .in files
76119679Smbrecho "AMU: autoheader..."
77119679Smbr# show version
78119679Smbrautoheader --version 2>&1 | head -1
79119679Smbrautoheader configure.in > config.h.in 2> ${LOG}
80119679SmbrCUTWARNMSG2="autoheader: \`config.h.in' is updated"
81119679Smbregrep -v "${CUTWARNMSG2}" ${LOG} > ${LOG}.new
82119679Smbrmv ${LOG}.new ${LOG}
83119679Smbrif test -s ${LOG}; then
84119679Smbr    echo "AUTOHEADER ERRORS (MUST FIX):"
85119679Smbr    cat ${LOG}
86119679Smbr    rm -f ${LOG}
87119679Smbr    exit 2
88119679Smbrfi
89119679Smbrrm -f ${LOG}
90119679Smbr
91119679Smbr# generate makefiles
92119679Smbrcmd="automake --add-missing --copy --ignore-deps"
93119679Smbr#cmd="automake --add-missing"
94119679Smbrecho "AMU: $cmd..."
95119679Smbr# show version
96119679Smbrautomake --version 2>&1 | head -1
97119679Smbrif ${cmd} ; then
98119679Smbr    :
99119679Smbrelse
100119679Smbr    echo "automake command failed.  fix errors and rerun $0."
101119679Smbr    exit 2
102119679Smbrfi
103119679Smbr
104119679Smbr# save timestamp
105119679Smbrecho "AMU: save timestamp..."
106119679Smbrecho timestamp > stamp-h.in
107119679Smbr
108119679Smbrexit 0
109