#
# Select LANGUAGE you want to compile World Cup with
#
LANGUAGE ?= DEUTSCH
# LANGUAGE = ENGLISH
# LANGUAGE = FRENCH
# LANGUAGE = SPANISH
# LANGUAGE = SWEDISH
# LANGUAGE = PORTUGUESE
# LANGUAGE = POLISH
# LANGUAGE = CHINESE
# LANGUAGE = RUSSIAN
# LANGUAGE = CZECH
# LANGUAGE = ITALIAN
# LANGUAGE = HRVATSKI
# LANGUAGE = HEBREW
# LANGUAGE = DUTCH
# LANGUAGE = JAPANESE
# LANGUAGE = SUOMI
# LANGUAGE = TRKCE
# LANGUAGE = SHQIP
# LANGUAGE = MAGYAR
# LANGUAGE = CATALAN
# LANGUAGE = TRADITIONALCHINESE
# LANGUAGE = DANISH
# LANGUAGE = KOREAN
# LANGUAGE = ROMANA
# LANGUAGE = THAI

AS         = m68k-palmos-gcc
ASFLAGS    = -c

CC         = m68k-palmos-gcc
ifdef debug
CFLAGS     = -g -Wstrict-prototypes -Wall
else
CFLAGS     = -Os -Wstrict-prototypes -Wall
endif

BUILDPRC   = build-prc
MULTIGEN   = /usr/m68k-palmos/bin/multigen
PILRC      = pilrc
PRCFLAGS   = -q -L $(LANGUAGE)
M4         = m4

OBJS       = main.o utils.o worldcup.o database.o teams.o\
	stadium.o matches.o datedb.o fixture.o

worldcup.prc: worldcup bin.res lang-tmp.rcp
	$(BUILDPRC) worldcup.def worldcup res/*.bin
	ls -l worldcup.prc

all-lang:
	rm -f bin.res && make LANGUAGE=DEUTSCH && mv worldcup.prc worldcup.de.prc
	rm -f bin.res && make LANGUAGE=ENGLISH && mv worldcup.prc worldcup.en.prc
	rm -f bin.res && make LANGUAGE=FRENCH && mv worldcup.prc worldcup.fr.prc
	rm -f bin.res && make LANGUAGE=SPANISH && mv worldcup.prc worldcup.es.prc
	rm -f bin.res && make LANGUAGE=SWEDISH && mv worldcup.prc worldcup.sw.prc
	rm -f bin.res && make LANGUAGE=PORTUGUESE && mv worldcup.prc worldcup.pt.prc
	rm -f bin.res && make LANGUAGE=POLISH && mv worldcup.prc worldcup.pl.prc
	rm -f bin.res && make LANGUAGE=CHINESE && mv worldcup.prc worldcup.cn.prc
	rm -f bin.res && make LANGUAGE=RUSSIAN && mv worldcup.prc worldcup.ru.prc
	rm -f bin.res && make LANGUAGE=CZECH && mv worldcup.prc worldcup.cz.prc
	rm -f bin.res && make LANGUAGE=ITALIAN && mv worldcup.prc worldcup.it.prc
	rm -f bin.res && make LANGUAGE=HRVATSKI && mv worldcup.prc worldcup.cr.prc
	rm -f bin.res && make LANGUAGE=DUTCH && mv worldcup.prc worldcup.nl.prc
	rm -f bin.res && make LANGUAGE=HEBREW && mv worldcup.prc worldcup.he.prc
	rm -f bin.res && make LANGUAGE=JAPANESE && mv worldcup.prc worldcup.jp.prc
	rm -f bin.res && make LANGUAGE=SUOMI && mv worldcup.prc worldcup.fi.prc
	rm -f bin.res && make LANGUAGE=TRKCE && mv worldcup.prc worldcup.tr.prc
	rm -f bin.res && make LANGUAGE=SHQIP && mv worldcup.prc worldcup.al.prc
	rm -f bin.res && make LANGUAGE=MAGYAR && mv worldcup.prc worldcup.hu.prc
	rm -f bin.res && make LANGUAGE=CATALAN && mv worldcup.prc worldcup.ct.prc
	rm -f bin.res && make LANGUAGE=TRADITIONALCHINESE && mv worldcup.prc worldcup.tc.prc
	rm -f bin.res && make LANGUAGE=DANISH && mv worldcup.prc worldcup.dk.prc
	rm -f bin.res && make LANGUAGE=KOREAN && mv worldcup.prc worldcup.kr.prc
	rm -f bin.res && make LANGUAGE=ROMANA && mv worldcup.prc worldcup.ro.prc
	rm -f bin.res && make LANGUAGE=THAI && mv worldcup.prc worldcup.th.prc

pics: pics/flags/fra.4.pgm
pics/flags/fra.4.pgm:
	make -C pics/flags

res:
	mkdir res

bin.res: lang-tmp.rcp res pics
	rm -f *.bin bin.res
	$(PILRC) $(PRCFLAGS) lang-tmp.rcp res
	touch bin.res

lang-tmp.rcp: worldcup.rcp worldcuprcp.h
	$(M4) -Ilangs worldcup.rcp > lang-tmp.rcp

worldcup-sections.o: worldcup-sections.s
worldcup-sections.s worldcup-sections.ld: worldcup.def
	$(MULTIGEN) worldcup.def

worldcup: $(OBJS) worldcup-sections.o worldcup-sections.ld
	$(CC) $(CFLAGS) $(OBJS) worldcup-sections.o worldcup-sections.ld -o $@

$(OBJS): Makefile

clean:
	make -C pics/flags clean
	rm -f $(OBJS) worldcup worldcup-sections.* res/*.bin bin.res *.bak *~ *.log lang-tmp.rcp

distclean realclean: clean
	rm -fr *.prc *.pdb res

dist:
	sh dist.sh
