#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1
export DH_OPTIONS
export LC_ALL=C.UTF-8

NUMJOBS = 1
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

export GIELLA_CORE=$(CURDIR)/giella-core-0.3.7

export GIELLA_SHARED=$(CURDIR)/giella-common-0.1.7

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	cd $(CURDIR)/giella-common-0.1.7 && autoreconf -fi && ./configure && $(MAKE) -j$(NUMJOBS)
	cd $(CURDIR)/giella-core-0.3.7 && autoreconf -fi && ./configure && $(MAKE) -j$(NUMJOBS)
	cd $(CURDIR)/giella-sme-0.1.0 && autoreconf -fi && ./configure --with-hfst --without-xfst --enable-alignment --enable-reversed-intersect --enable-apertium --with-backend-format=foma --disable-analysers --disable-generators
	cd $(CURDIR)/apertium-nob-1.1.0 && autoreconf -fi && ./configure
	dh_auto_configure -- --with-lang1=$(CURDIR)/giella-sme-0.1.0/tools/mt/apertium --with-lang2=$(CURDIR)/apertium-nob-1.1.0

override_dh_auto_build:
	cd $(CURDIR)/giella-sme-0.1.0 && $(MAKE) -j$(NUMJOBS)
	cd $(CURDIR)/apertium-nob-1.1.0 && $(MAKE) -j$(NUMJOBS)
	dh_auto_build

override_dh_missing:
	dh_missing --fail-missing
