#! /bin/bash

# Copyright (C) 2004, 2008, 2014
#               Enrico Scholz <enrico.scholz@ensc.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.


set -e

ENABLE_FLAGS="dietlibc logging release"

rm -rf compile-test

for val in $(seq 0 $[ 2**`echo $ENABLE_FLAGS | wc -w` - 1]); do
    idx=0
    cmd=
    dir=
    for par in $ENABLE_FLAGS; do
	test "$idx" -eq 0 || { cmd="${cmd} "; dir="${dir}-"; }
	cmd="${cmd}--enable-${par}="

	if test $[ val&(2**idx) ] -ne 0; then
	    cmd="${cmd}yes"
	    dir="${dir}$par"
	else
	    cmd="${cmd}no"
	    dir="${dir}no${par}"
	fi

	idx=$[ idx + 1 ]
    done

    D=compile-test/$dir
    mkdir -p $D
    pushd $D
	../../configure -q $cmd
	make -s
	strip dhcp-fwd -o dhcp-fwd.s
    popd
done
