# @configure_input@
#
# See po/README for documentation.

ALL_LINGUAS = bg cs da de eo es fi fr it nl nb pl pt ru sv 

SRC_FILES = ../include/sane/saneopts.h ../backend/artec_eplus48u.c \
  ../backend/avision.h \
  ../backend/canon630u.c ../backend/canon.c ../backend/canon-sane.c \
  ../backend/epson.c ../backend/epson.h \
  ../backend/epson2.c ../backend/epson2.h \
  ../backend/genesys.c \
  ../backend/gt68xx.c ../backend/gt68xx_low.h \
  ../backend/hp3500.c ../backend/hp3900_sane.c ../backend/hp5400_sane.c \
  ../backend/hp5590.c \
  ../backend/hp-option.c ../backend/hp-option.h \
  ../backend/leo.c ../backend/leo.h ../backend/lexmark.c \
  ../backend/ma1509.c \
  ../backend/matsushita.c ../backend/matsushita.h \
  ../backend/microtek2.c ../backend/microtek2.h \
  ../backend/mustek.c ../backend/mustek_usb.c ../backend/mustek_usb2.c \
  ../backend/niash.c \
  ../backend/pixma.c ../backend/pixma_sane_options.c \
  ../backend/plustek.c ../backend/plustek_pp.c \
  ../backend/pnm.c \
  ../backend/sceptre.c ../backend/sceptre.h  ../backend/sm3840.c \
  ../backend/snapscan.c ../backend/snapscan-options.c \
  ../backend/stv680.c ../backend/stv680.h \
  ../backend/teco1.c ../backend/teco1.h \
  ../backend/teco2.c ../backend/teco2.h \
  ../backend/teco3.c ../backend/teco3.h \
  ../backend/test.c ../backend/u12.c ../backend/umax1220u.c \
  ../backend/umax.c ../backend/umax_pp.c

DISTFILES = Makefile.in README template.po \
  $(foreach lang,$(ALL_LINGUAS),sane-backends.$(lang).po)

# End of configuration section

SHELL = /bin/sh
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
localedir = $(datadir)/locale
gnulocaledir = $(prefix)/share/locale
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

PACKAGE = @PACKAGE@
VERSION = @VERSION@
distdir = $(top_srcdir)/$(PACKAGE)-$(VERSION)

INSTALL_TRANSLATIONS = @INSTALL_TRANSLATIONS@
ifeq ($(INSTALL_TRANSLATIONS),install-translations)
UNINSTALL_TRANSLATIONS = uninstall-translations
ALL = all-mos
endif

MKDIR = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@ -w75

TMP_FILE_DIR = .tmp

DISTCLEAN_FILES = @DISTCLEAN_FILES@

.PHONY: all clean depend dist distclean install install-translations \
  uninstall uninstall-translations all-mos update

all: $(ALL)

all-mos: $(foreach lang,$(ALL_LINGUAS),sane-backends.$(lang).mo)

%.mo: %.po
	@echo "generating $@ from $^"
	@$(MSGFMT) -o $@ $^

sane-backends.pot: $(SRC_FILES)
	@echo "creating $@ from $^"
	@rm -rf $(TMP_FILE_DIR)
	@mkdir $(TMP_FILE_DIR) && \
	 for file in $^ ; do \
	   sed < $${file} -e 's/#define//g' \
	     > $(TMP_FILE_DIR)/`basename $${file}` ; \
	 done
	@$(XGETTEXT) -dsane-backends -kSANE_I18N --flag=SANE_I18N:1:no-c-format $(TMP_FILE_DIR)/*.*
	@mv sane-backends.po sane-backends.pot

update: sane-backends.pot
	@for lang in $(ALL_LINGUAS) ; do \
	   pofile=sane-backends.$${lang}.po ; \
	   if test ! -f $${pofile} ; then \
	     echo "creating $${pofile}" ; \
	     cp template.po $${pofile} ; \
	   fi ; \
	   echo "updating $${pofile}" ; \
	   cp $${pofile} $${pofile}.old  ; \
	   $(MSGMERGE) $${pofile}.old $< -o $${pofile} ; \
	   rm -f $${pofile}.old ; \
	 done 

install-translations:
	@for lang in $(ALL_LINGUAS) ; do \
	  dir=$(gnulocaledir)/$${lang}/LC_MESSAGES ; \
	  echo "installing sane-backends.$${lang}.mo to $${dir}/sane-backends.mo..." ; \
	 $(MKDIR) $(DESTDIR)$${dir} && \
	 $(INSTALL_DATA) sane-backends.$${lang}.mo $(DESTDIR)$${dir}/sane-backends.mo ; \
	 done

install: $(INSTALL_TRANSLATIONS)

uninstall-translations:
	@for lang in $(ALL_LINGUAS) ; do \
	   dir=$(gnulocaledir)/$${lang}/LC_MESSAGES ; \
	   echo removing $${dir}/sane-*.mo ; \
	   rm -f $${dir}/sane-*.mo ; \
	 done

uninstall: $(UNINSTALL_TRANSLATIONS)

clean:
	rm -f *.mo
	rm -f *.old
	rm -f *.pot

distclean: clean
	rm -f $(DISTCLEAN_FILES)
	rm -f Makefile
	rm -rf $(TMP_FILE_DIR)

depend:

dist: $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file $(distdir)/po 2> /dev/null \
	    || cp -p $$file $(distdir)/po ; \
	done
