#!/bin/bash

# Copyright (C) 2011, 2012, 2013, 2014, 2016, 2017, 2018,
#               2019, 2020 Tim Marston, Felix Natter
# Copyright (C) 2021, 2022, 2023 Felix Natter, Mihai Gătejescu

# This file if a part of GNU Typist

# GNU Typist 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, either version 3 of the License, or
# (at your option) any later version.

# GNU Typist 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 GNU Typist.  If not, see <http://www.gnu.org/licenses/>.

echo Configuring gtypist 2.10.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.10.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 src/speedbox.c src/infoview.c src/banner.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
