#!/bin/sh

GTK_INCLUDE=`pkg-config gtk+-2.0 --cflags`
GTK_LIB=`pkg-config gtk+-2.0 --libs`
CC='/usr/bin/gcc -O2 -fPIC'

touch config.h

echo -n "Checking if gkrellm has gkrellm_decal_text_insert()... "
cat << EOF > test.c
#include <gkrellm2/gkrellm.h>

int main()
{
#if GKRELLM_CHECK_VERSION(2,1,11)
#ifndef GKRELLM_HAVE_DECAL_TEXT_INSERT
	return 0;
#else
	return 1;
#endif
#else
	return 1;
#endif
}

EOF

${CC} ${GTK_INCLUDE} -c test.c -o test.o
${CC} test.o -o test ${GTK_LIBS}

echo "Done."

if ./test; then
	echo 'Defining GKRELLM_HAVE_DECAL_TEXT_INSERT...'
	echo '#define GKRELLM_HAVE_DECAL_TEXT_INSERT' > config.h
fi

echo -n "Checking OS type... "

UNAME=`uname`

case "$UNAME" in
	FreeBSD)
		echo 'FreeBSD'
		echo '#define COMMAND "w -h"' >> config.h
		echo '#define DEVTTY "/dev/tty"' >> config.h
		;;
	Linux)
		echo 'Linux'
		echo '#define COMMAND "w -hs"' >> config.h
		echo '#define DEVTTY "/dev/"' >> config.h
		;;
	*)
		echo 'Your system is not supported yet, please report to shisha@shisha.spb.ru'
		echo '#define COMMAND "w -h"' >> config.h
		echo '#define DEVTTY "/dev/"' >> config.h
esac

rm test test.o test.c

