#!/bin/bash
#export CFLAGS="-Wimplicit -Wreturn-type -Wuninitialized -g -O2"
N="`grep -c ^processor /proc/cpuinfo 2>/dev/null || true`"
if ! test "$N" = 0 -o "$N" = ""; then
	MAKEFLAGS=-j$N
	export MAKEFLAGS
fi
export CFLAGS="-Wall -Wno-pointer-sign -g -O2 -ansi -U__STRICT_ANSI__ $CFLAGS"
rm -f config.h configure Makefile config.cache config.log stamp-h
rm -rf .deps
if which automake-1.4 2>/dev/null >/dev/null; then
	automake="automake-1.4"
else
	automake="automake"
fi
if which aclocal-1.4 2>/dev/null >/dev/null; then
	aclocal="aclocal-1.4"
	if [ -d /usr/share/aclocal-1.4/ ]; then
		aclocal="$aclocal --acdir=/usr/share/aclocal-1.4/"
	fi
else
	aclocal="aclocal"
fi
if which autoconf2.13 2>/dev/null >/dev/null; then
	autoconf="autoconf2.13"
elif which autoconf-2.13 2>/dev/null >/dev/null; then
	autoconf="autoconf-2.13"
else
	autoconf="autoconf"
fi
if which autoheader2.13 2>/dev/null >/dev/null; then
	autoheader="autoheader2.13"
elif which autoheader-2.13 2>/dev/null >/dev/null; then
	autoheader="autoheader-2.13"
else
	autoheader="autoheader"
fi
set -e
$autoheader
rm -f autoh*
$aclocal -I .
$automake
$autoconf
#sed 's/\\\.am/\\\.\[aA]\[mM]/' <missing >missing.tmp
#mv missing.tmp missing
./configure
make dist
make clean
make
$automake --add-missing --include-deps --build-dir=. --srcdir-name=. --output-dir=.
