bootstrap revision 174295
133965Sjdp#!/bin/sh
278828Sobrien#set -x
333965Sjdp# helps bootstrapping am-utils, when checked out from CVS
4218822Sdim# requires GNU autoconf and GNU automake
578828Sobrien# this is not meant to go into the distributions
678828Sobrien# Erez Zadok <ezk@cs.columbia.edu>
778828Sobrien
878828Sobrien# test cwd
978828Sobrientest -f ../amd/amd.c && cd ..
1078828Sobrienif [ ! -f amd/amd.c ]; then
1178828Sobrien    echo "Must run $0 from the top level source directory."
1278828Sobrien    exit 1
1378828Sobrienfi
1478828Sobrien
1578828Sobrien# validate macros directory and some macro files
1678828Sobrienif [ ! -d m4/macros ]; then
1778828Sobrien    echo No m4/macros directory found!
18218822Sdim    exit 1
1978828Sobrienfi
2033965Sjdpif [ ! -f m4/macros/HEADER ]; then
2133965Sjdp    echo No m4/macros/HEADER file found!
2289857Sobrien    exit 1
2389857Sobrienfi
2433965Sjdp
2533965Sjdp# remove any remaining autom4te.cache directory
2633965Sjdprm -fr autom4te.cache autom4te-*.cache
2733965Sjdp
2833965Sjdp# generate acinclude.m4 file
2933965Sjdpecho "AMU: prepare acinclude.m4..."
3033965Sjdptest -f acinclude.m4 && mv -f acinclude.m4 acinclude.m4.old
3133965Sjdp(cd m4/macros
3233965Sjdp for i in HEADER *.m4; do
3333965Sjdp     cat $i
3433965Sjdp     echo
3533965Sjdp     echo
3633965Sjdp done
37218822Sdim cat TRAILER
38218822Sdim) > acinclude.m4
39218822Sdim
4033965Sjdp# generate aclocal.m4 file
4133965Sjdpecho "AMU: aclocal..."
4233965Sjdptest -f aclocal.m4 && mv -f aclocal.m4 aclocal.m4.old
4333965Sjdp# show version
4433965Sjdpaclocal --version 2>&1 | head -1
4533965Sjdpif aclocal ; then
4633965Sjdp    :
4733965Sjdpelse
4833965Sjdp    echo "aclocal command failed.  fix errors and rerun $0."
4933965Sjdp    exit 2
5033965Sjdpfi
5133965Sjdp
5233965Sjdp# produce new configure.in (temp) script
5333965Sjdpecho "AMU: autoconf..."
5433965Sjdp# show version
5533965Sjdpautoconf --version 2>&1 | head -1
5633965SjdpLOG=/tmp/amu-$$.log
5733965Sjdprm -f ${LOG}
5833965Sjdpautoconf configure.in > configure.new 2> ${LOG}
5933965Sjdp# until Automake requires Autoconf 2.50, manual says to ignore this
6033965SjdpCUTWARNMSG1="warning: AC_PROG_LEX invoked multiple times|do not use m4_(patsubst|regexp):"
6133965Sjdpegrep -v "${CUTWARNMSG1}" ${LOG} > ${LOG}.new
6233965Sjdpmv ${LOG}.new ${LOG}
6333965Sjdpif test -s ${LOG}; then
6433965Sjdp    echo "AUTOCONF ERRORS (MUST FIX):"
6533965Sjdp    cat ${LOG}
6633965Sjdp    rm -f ${LOG}
6733965Sjdp    exit 2
6833965Sjdpfi
6933965Sjdp# now prepare the real configure script
7033965Sjdptest -f configure && mv -f configure configure.old
7133965Sjdpmv -f configure.new configure
7233965Sjdpchmod a+rx configure
7333965Sjdprm -f configure.old
7433965Sjdp
7533965Sjdp# run autoheader to produce C header .in files
7689857Sobrienecho "AMU: autoheader..."
7789857Sobrien# show version
7833965Sjdpautoheader --version 2>&1 | head -1
7933965Sjdpautoheader configure.in > config.h.in 2> ${LOG}
8033965SjdpCUTWARNMSG2="autoheader: \`config.h.in' is updated"
8133965Sjdpegrep -v "${CUTWARNMSG2}" ${LOG} > ${LOG}.new
8233965Sjdpmv ${LOG}.new ${LOG}
8333965Sjdpif test -s ${LOG}; then
8433965Sjdp    echo "AUTOHEADER ERRORS (MUST FIX):"
8533965Sjdp    cat ${LOG}
8633965Sjdp    rm -f ${LOG}
8733965Sjdp    exit 2
8833965Sjdpfi
8933965Sjdprm -f ${LOG}
9033965Sjdp
9133965Sjdp# generate makefiles
9233965Sjdpcmd="automake --add-missing --copy --ignore-deps"
9333965Sjdp#cmd="automake --add-missing"
9433965Sjdpecho "AMU: $cmd..."
9589857Sobrien# show version
9689857Sobrienautomake --version 2>&1 | head -1
9733965Sjdpif ${cmd} ; then
9833965Sjdp    :
9933965Sjdpelse
10033965Sjdp    echo "automake command failed.  fix errors and rerun $0."
10133965Sjdp    exit 2
10233965Sjdpfi
10333965Sjdp
10433965Sjdp# save timestamp
10533965Sjdpecho "AMU: save timestamp..."
10633965Sjdpecho timestamp > stamp-h.in
10733965Sjdp
10833965Sjdpexit 0
10933965Sjdp