#!/bin/sh

if test "$1" = "n900"; then

	echo "Creating debian configure scripts for build target Nokia N900..."
	fakeroot debian/rules clean 1>/dev/null 2>&1
	rm -f debian/postinst
	cp debian/install.n900 debian/install
	cp debian/links.n900 debian/links
	cp debian/control.n900 debian/control
	cat > Makefile << EOF
all:
	\$(CC) \$(CFLAGS) \$(LDFLAGS) src/evkey.c -o src/evkey
	\$(CC) \$(CFLAGS) \$(LDFLAGS) -DWITH_LIBCAL -lcal src/watchdogs.c -o src/watchdogs
clean:
	\$(RM) src/evkey src/watchdogs
EOF

elif test "$1" = "n8x0"; then

	echo "Creating debian configure scripts for build target Nokia N8x0..."
	fakeroot debian/rules clean 1>/dev/null 2>&1
	cp debian/install.n8x0 debian/install
	cp debian/links.n8x0 debian/links
	cp debian/postinst.n8x0 debian/postinst
	cp debian/control.n8x0 debian/control
	cat > Makefile << EOF
all:
clean:
EOF

elif test "$1" = "clean"; then

	echo "Removing debian configure scripts..."
	fakeroot debian/rules clean 1>/dev/null 2>&1
	rm -f debian/install
	rm -f debian/links
	rm -f debian/postinst
	rm -f debian/control
	rm -f Makefile

else

	echo "Unknow option $1"
	echo "Usage:"
	echo "$0 n900"
	echo "$0 n8x0"
	echo "$0 clean"
	exit 1

fi
