# the sample executables static - dll - safe_dll
all: sample.exe sample_dll.exe sample_safe_dll.exe translation run_sample

sample.exe: sample.c
	REM
	REM building static sample
	REM
	gcc -O -s -osample.exe -DUSE_GETTEXT_STATIC sample.c -I../include -L../lib/mingw32 -lintl -mwindows

sample_dll.exe: sample.c
	REM
	REM building DLL sample
	REM
	gcc -O -s -osample_dll.exe -DUSE_GETTEXT_DLL sample.c -I../include -L../lib/mingw32 -lgnu_gettext -mwindows

sample_safe_dll.exe: sample.c ../src/safe_gettext_dll/safe_gettext_dll.cpp
	REM
	REM building safe DLL sample
	REM
	g++ -O -c -osafe_gettext_dll.o ../src/safe_gettext_dll/safe_gettext_dll.cpp
	gcc -O -s -osample_safe_dll.exe -DUSE_SAFE_GETTEXT_DLL sample.c safe_gettext_dll.o -I../include -L../lib/mingw32 -lstdc++ -mwindows

# translations
# Extract strings to be translated
sample.pot: sample.c
	REM
	REM extracting strings to file
	REM     using _ as the keyword
	REM
	..\\bin\\xgettext -k_ -o sample.pot sample.c

# copy untranslated file to destinations to be translated
# WARNING this overewrites previously translatetd files
#         this should NOT be use in production 
#         one should use msgmerge to merge allready translated strings with new ones
# Just a sample --- :-)

#GERMAN
de.po: sample.pot
	REM copying Textfile for german translation
	copy sample.pot de.po

de:
	REM creating german locale install directory
	mkdir de
	mkdir de\LC_MESSAGES

#FRENCH
fr.po: sample.pot
	REM copying Textfile for french translation
	copy sample.pot fr.po

fr:
	REM creating french locale install directory
	mkdir fr
	mkdir fr\LC_MESSAGES

#POTUGISE
pt.po: sample.pot
	REM copying Textfile for portugise translation
	copy sample.pot pt.po

pt:
	REM creating portugise locale install directory
	mkdir pt
	mkdir pt\LC_MESSAGES

#ITALIAN
it.po: sample.pot
	REM copying Textfile for italian translation
	copy sample.pot it.po

it:
	REM creating italian locale install directory
	mkdir it
	mkdir it\LC_MESSAGES

build_po: de.po fr.po pt.po it.po

translate: de.po fr.po pt.po it.po
	REM
	REM This is the point where the actual translation
	REM should be done. That means editing the *.po files
	REM
	REM we are using pre-translated po files for the sample
	REM
	pause
	copy translated\de.po de.po
	copy translated\fr.po fr.po
	copy translated\it.po it.po
	copy translated\pt.po pt.po

build_mo: de.po fr.po pt.po it.po
	REM
	REM compiling the translated message files
	REM
	REM german
	..\\bin\\msgfmt -o de.mo de.po
	REM portugise
	..\\bin\\msgfmt -o pt.mo pt.po
	REM italian
	..\\bin\\msgfmt -o it.mo it.po
	REM french
	..\\bin\\msgfmt -o fr.mo fr.po

inst_dirs: de fr pt it

inst_mo: de.mo fr.mo pt.mo it.mo
	REM
	REM installing the compiled message objects
	REM
	REM german
	copy de.mo de\LC_MESSAGES\sample.mo
	REM portugise
	copy pt.mo pt\LC_MESSAGES\sample.mo
	REM italian
	copy it.mo it\LC_MESSAGES\sample.mo
	REM french
	copy fr.mo fr\LC_MESSAGES\sample.mo

translation: inst_dirs translate build_mo inst_mo

run_sample:
	REM
	REM running samples in all languages
	REM
	run_sample.bat

.PHONY: build_po build_mo inst_mo inst_dirs translate translation run_sample

