#!/bin/bash

echo Configuring gtypist 2.9.1
echo - using MinGW and PDCurses
echo - with Native Language Support

echo creating src/config.h...
echo -e '/* config.h */\r' > src/config.h
echo -e '#define ENABLE_NLS 1\r' >> src/config.h
echo -e '#define PACKAGE "gtypist"\r' >> src/config.h
echo -e '#define VERSION "2.9.1"\r' >> src/config.h
echo -e '#define HAVE_PDCURSES 1\r' >> src/config.h
echo -e '#define LOCALEDIR "locale"\r' >> src/config.h

echo copying UI translations...
(cd po/
for i in *.gmo
do
    lang=${i/.gmo/}
    mkdir -p ../locale/$lang/LC_MESSAGES
    cp $lang.gmo ../locale/$lang/LC_MESSAGES/gtypist.mo
done
)

echo creating Makefile...
echo -e '# gtypist: Makefile for MinGW\r' > Makefile
echo -e '#\r' >> Makefile
echo -e '# Please read INSTALL for help building gtypist with MinGW.\r' >> Makefile
echo -e '\r' >> Makefile
echo -e '# Set the path to a compiled PDCurses library here:\r' >> Makefile
echo -e 'PDCURSES_PATH=C:\dev\PDCurses-3.4\r' >> Makefile
echo -e '\r' >> Makefile
echo -e 'gtypist.exe:\r' >> Makefile
echo -e '	gcc -DMINGW -DPDC_WIDE -I$(PDCURSES_PATH) -Isrc -static -s -O2 -o gtypist src/error.c src/script.c src/cursmenu.c src/gtypist.c src/getopt.c src/getopt1.c src/utf8.c -L$(PDCURSES_PATH)/win32 -lpdcurses -lgettextlib.dll -lintl -liconv\r' >> Makefile
echo
echo
echo IMPORTANT: Before running make, change the PDCURSES_PATH variable in the
echo Makefile! Type 'notepad Makefile' to edit it.
echo
