# Makefile for the Sherlock Language Processing Modules (c) 2003--2007 Martin Mares <mj@ucw.cz>

DIRS+=lang
CONFIGS+=lang

# The basic modules are compiled even when CONFIG_LANG is not enabled
LIBLANG_MODS=lang
LIBLANG_INCLUDES=lang.h

ifdef CONFIG_LANG
PROGS+=$(o)/lang/stem-table-gen $(o)/lang/stemtest $(o)/lang/stem-dict-gen
LIBLANG_MODS+=stemmer stem-porter stem-table stem-dict syndict

ifdef CONFIG_LANG_DETECT
PROGS+=$(o)/lang/lang-tables
CONFIGS+=lang-detect
LIBLANG_MODS+=detect
LIBLANG_INCLUDES+=detect.h
endif

INCLUDES+=$(o)/lang/.include-stamp
$(o)/lang/.include-stamp: $(addprefix $(s)/lang/,$(LIBLANG_INCLUDES))
	$(s)/build/install-includes $(s)/lang run/include/lang $(?F)
	touch $(o)/lang/.include-stamp
endif

$(o)/lang/liblang.a: $(addsuffix .o,$(addprefix $(o)/lang/,$(LIBLANG_MODS)) $(LIBLANG_EXTRAS))
$(o)/lang/liblang.so: $(addsuffix .oo,$(addprefix $(o)/lang/,$(LIBLANG_MODS)) $(LIBLANG_EXTRAS))

$(o)/lang/stemtest: $(o)/lang/stemtest.o $(LIBLANG) $(LIBCHARSET) $(LIBUCW)
$(o)/lang/stemtest: LIBS+=$(LIBLANG_LIBS)
$(o)/lang/lang-tables: $(o)/lang/lang-tables.o $(o)/indexer/getbuck.o $(o)/indexer/iconfig.o $(LIBFILTER) $(LIBLANG) $(LIBCHARSET) $(LIBSH)
$(o)/lang/lang-tables: LIBS+=$(LIBLANG_LIBS)
$(o)/lang/stem-table-gen: $(o)/lang/stem-table-gen.o $(LIBUCW)
$(o)/lang/stem-dict-gen: $(o)/lang/stem-dict-gen.o $(LIBCHARSET) $(LIBUCW)
