#!/bin/sh
#
# This is bootstrap for development (not for release):
#   * version number is derived from Mercurial identificator of the changeset
#   * RSS is not generated
#
# This bootstrap file has been inspired by Bootstraping chapter
# in Autobook by Vaughan, Elliston, Tromey and Taylor.
# http://sources.redhat.com/autobook/
#
# Usage: $0 [path to wxwin.m4]
#
#
# Reccomended usage for developing. It switch-on all possible flags of checking
# and installs all to a single directory under /scratch/opt.
#
# $ ./bootstrap-dev
# $ ./configure FCFLAGS="-Wall -g -p -fcheck=all -fimplicit-none -fbacktrace -ffpe-trap=invalid,zero,overflow" CFLAGS="-Wall -g -p"  CXXFLAGS="-D__WXDEBUG__ -g -p -Wall -fbounds-check" --prefix=/scratch/opt --enable-bundle BUNDLEDIR=/scratch/opt

set -x
set -e

# define environment variable used by configure
DEVELOPMENT=yes

# define version number as both last tag and identificator
H=$(hg tags | awk -F'[: ]+' '{if(FNR==1) print $2;}')
V=$(hg tags | awk -F'[: ]+' '{if(FNR==2) print $1;}')
VERSION="${V}+hg${H}"

export DEVELOPMENT VERSION

# Changelog is required by autoconf
hg log --style changelog > ChangeLog

# Generate thumbnails in doc/ and icons in xmunipack/. It can be run later, when need.
( cd doc && sh genthumb.sh )
( cd xmunipack && sh image_list.sh )

# add -I for localy installed wxwin.m4 (or add its parent directory as
#                                      the first command-line argument)
# example:
# $ ./bootstrap-dev /usr/local/share/aclocal

#if [ "$1" ]; then
#   ACLOCAL_PATH="-I $1"
#fi

#autoreconf $ACLOCAL_PATH -i
