#!/bin/sh
targetos=`uname -s`
exeext=''
fltkdir=`fltk2-config --prefix`
pnglib=

echo "Target OS: "$targetos
case $targetos in
MINGW32*)
	windows="yes";;
CYGWIN*)
	windows="yes";;
esac
if [ "$windows" = "yes" ] ; then
	exeext=".exe"
fi

for opt do
	case $opt in
		--static) static="-static";;
		--no-png) nopng="-DNO_PNG";;
		*) echo "ERROR: unknown option $opt"; show_help="yes";;
	esac
done

if [ "$show_help" = "yes" ] ; then
	echo "Recognized options:"
	echo " --static"
else
	echo "FLTKDIR  = $fltkdir" > make.include
	if [ "$nopng" = "" ] ; then
		pnglib=`find $fltkdir -iname libfltk2_png.a -exec ls 2> /dev/null {} \;`
		if [ "$pnglib" = "" ] ; then
			echo "Warning: libfltk2_png not found; assuming -lpng"
			echo "   Try configure --no-png if the build fails or install the library."
			pnglib="-lpng"
		fi
	fi
	echo 'CXXFLAGS = -I$(FLTKDIR) -I$(FLTKDIR)/images/libpng '$nopng >> make.include
	echo "LDFLAGS  = "`fltk2-config --ldstaticflags` $pnglib -lz $static >> make.include
	echo "EXEEXT   = "$exeext >> make.include
fi
