# Makefile for program source directory in GNU NLS utilities package.
# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file file be copied and used freely without restrictions.  It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
#

# config.status complains if "po/Makefile.in.in was not created by intltoolize".
# INTLTOOL_MAKEFILE

GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
VERSION = @VERSION@

SHELL = /bin/sh
@SET_MAKE@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = @datadir@
datarootdir = @datarootdir@
localedir = $(datadir)/locale
#localedir = $(prefix)/share/locale
gnulocaledir = $(localedir)
subdir = po
# DESTDIR = $(install_prefix)
ac_aux_dir = @ac_aux_dir@

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

# The @MKINSTALLDIRS@ variable must have the absolute (or unqualified)
# path of the install program.
# MKINSTALLDIRS = $(top_builddir)/@MKINSTALLDIRS@

MKINSTALLDIRS = @MKINSTALLDIRS@

CC = @CC@
#GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
MSGFMT_OPTS = @MSGFMT_OPTS@
XGETTEXT = @XGETTEXT@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
MSGMERGE = $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
GENPOT   = $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot

DEFS = @DEFS@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@

INCLUDES = -I.. -I$(top_srcdir)/intl

COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)

SOURCES = 

EVAL_POFILES = cat $(srcdir)/LINGUAS | sed -e '/^\#/d' -e 's@^\(.*\)@ \1.po @'
POFILES := $(shell $(EVAL_POFILES))

EVAL_GMOFILES = cat $(srcdir)/LINGUAS | sed -e '/^\#/d' -e 's@^\(.*\)@ \1@CATOBJEXT@ @'
GMOFILES := $(shell $(EVAL_GMOFILES))

DISTFILES_1 = LINGUAS $(srcdir)/linguas.rc ChangeLog Makefile.in.in $(srcdir)/POTFILES.in
DISTFILES = $(DISTFILES_1) $(GETTEXT_PACKAGE).pot \
	    $(POFILES) $(SOURCES)

TARFILES = $(DISTFILES_1) $(POFILES) $(SOURCES)

# the next line is edited by config.status; do not change it
POTFILES = \

CATALOGS = $(GMOFILES)
CATOBJEXT = @CATOBJEXT@
INSTOBJEXT = @INSTOBJEXT@

AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@

am__v_MSGFMT_0 = @echo "  MSGFMT  "
am__v_MSGFMT_1 = @echo generating
AM_V_MSGFMT    = $(am__v_MSGFMT_$(V))
am__v_MSGFMT_  = $(am__v_MSGFMT_$(AM_DEFAULT_VERBOSITY))

AM_V_echo      = $(am__v_echo_$(V))
am__v_echo_0   = :
am__v_echo_1   = echo
am__v_echo_    = $(am__v_echo_$(AM_DEFAULT_VERBOSITY))

XGETTEXT_KEYWORDS = \
	--keyword=_ \
	--keyword=N_ \
	--keyword=U_ \
	--keyword=Q_ \
	--keyword=P_:1,2 \
	--keyword=C_:1c,2 \
	--keyword=NC_:1c,2

XGETTEXT_ARGS = --no-wrap --width=4

.SUFFIXES:
.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat

.c.o:
	$(COMPILE) $<

.po.pox:
	$(MAKE) $(GETTEXT_PACKAGE).pot
	INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) ; \
	export INTLTOOL_EXTRACT ; \
	XGETTEXT_ARGS="$(XGETTEXT_ARGS)" ; \
	export XGETTEXT_ARGS ; \
	echo $(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox ; \
	     $(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox

.po.mo:
	$(AM_V_MSGFMT) $@
	$(AM_V_at)$(MSGFMT) $(MSGFMT_OPTS) -o $@ $<

.po.gmo:
	$(AM_V_MSGFMT) $@
	@file=`echo $* | sed 's,.*/,,'`.gmo ; \
	 $(RM) "$$file" ; \
	 $(AM_V_echo) $(GMSGFMT) -o "$$file" $< ; \
	      $(GMSGFMT) -c -v --statistics -o "$$file" $<

#.po.cat:
#	@echo "sed -f ../intl/po2msg.sed < $< > $*.msg" ; \
#	       sed -f ../intl/po2msg.sed < $< > $*.msg && \
#	 $(RM) $@ && \
#	 echo $(GENCAT) "$@" "$*.msg" ; \
#	      $(GENCAT) "$@" "$*.msg"


all: all-@USE_NLS@
default: all

all-yes: $(CATALOGS) $(srcdir)/linguas.rc
all-no:

$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES) $(INTLTOOL_EXTRACT) $(INTLTOOL_UPDATE)
	@INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" ; \
	export INTLTOOL_EXTRACT ; \
	XGETTEXT_ARGS="$(XGETTEXT_ARGS)" ; \
	export XGETTEXT_ARGS ; \
	srcdir="$(srcdir)" ; \
	export srcdir ; \
	top_srcdir="$(top_srcdir)" ; \
	export top_srcdir ; \
	echo $(GENPOT) ; \
	     $(GENPOT)

install-strip: install

install: install-exec install-data
install-exec:
install-program:
install-man:
install-strip:
tags:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
	@set -e; \
	catalogs='$(CATALOGS)'; \
	losers=""; \
	for cat in $$catalogs; do \
	  cat=`basename $$cat`; \
	  case "$$cat" in \
	    *.gmo) destdir=$(gnulocaledir);; \
	    *)     destdir=$(localedir);; \
	  esac; \
	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
	  dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
	  dest=$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
	  if test -r $$cat -o -r $$cat.m; then \
	    echo $(MKINSTALLDIRS) $$dir; \
	         $(MKINSTALLDIRS) $$dir; \
	  else \
	    losers="$$losers $$lang"; \
	  fi ; \
	  if test -r $$cat; then \
	    echo $(INSTALL_DATA) $$cat $$dest; \
		 $(INSTALL_DATA) $$cat $$dest; \
	  fi; \
	  if test -r $$cat.m; then \
	    echo $(INSTALL_DATA) $$cat.m $$dest.m; \
		 $(INSTALL_DATA) $$cat.m $$dest.m; \
	  fi; \
	done; \
	if [ "$$losers" != '' ]; then \
	  echo "Warning: these catalogs were not installed:" >&2 ; \
	  echo "	$$losers" >&2; \
	fi

# Define this as empty until I found a useful application.
installcheck:

uninstall:
	@catalogs='$(CATALOGS)'; \
	for cat in $$catalogs; do \
	  cat=`basename $$cat`; \
	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
	  suffix="$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
	  for f in $(DESTDIR)$(localedir)/$$suffix \
		   $(DESTDIR)$(localedir)/$$suffix.m \
		   $(DESTDIR)$(gnulocaledir)/$$suffix \
		   $(DESTDIR)$(gnulocaledir)/$$suffix.m; do \
	    if [ -f $$f ]; then \
	      echo $(RM) $$f; \
	           $(RM) $$f; \
	    fi; \
	  done; \
	done

uninstall-program:
uninstall-man:

check: all

dvi info tags TAGS ID:

mostlyclean:
	$(RM) core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp .intltool-merge-cache
	$(RM) *.o $(GMOFILES)

clean: mostlyclean

distclean: clean
	$(RM) Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m *.gmo *.pot
	if test "$(srcdir)" != "."; then \
	dists="$(DISTFILES)"; \
	for file in $$dists; do \
	  $(RM) `basename $$file`; \
	done; \
	fi

maintainer-clean: distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
	$(RM) $(GMOFILES)

depend:
# fuck off.  love, jwz.
#distdepend: generate_potfiles_in update-po $(DISTFILES)
distdepend::


# Generates po/POTFILES.in by examining the source tree:
# that way we don't have to keep this list up to date as files are added.
#
generate_potfiles_in:
	@tmp=po.$$$$ ;				\
	 file=$(srcdir)/POTFILES.in ;			\
	 ( cd $(srcdir)/..;			\
	   echo "# Auto-generated: `LANG=C date`" ;	\
	   ( grep -l '[^a-zA-Z_]_("' src/*.[ch] ;	\
	     grep -l '[^a-zA-Z_]N_("' src/*.[ch] ;	\
	     ) | sort -u \
	  ) > $$tmp &&				\
	 mv $$tmp $$file &&			\
	 echo "created `pwd`/$$file" || $(RM) $tmp

echo_tarfiles:
	@echo $(TARFILES)

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
dist distdir: update-po $(DISTFILES)
	dists="$(DISTFILES)"; \
	for file in $$dists; do \
	  ln $(srcdir)/$$file $(distdir) 2> /dev/null \
	    || cp -p $(srcdir)/$$file $(distdir); \
	done

update-po: Makefile
	$(MAKE) $(GETTEXT_PACKAGE).pot
	@catalogs='$(CATALOGS)'; \
	INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) ; \
	export INTLTOOL_EXTRACT ; \
	XGETTEXT_ARGS="$(XGETTEXT_ARGS)" ; \
	export XGETTEXT_ARGS ; \
	for cat in $$catalogs; do \
	  cat=`basename $$cat`; \
	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
          if [ ! -f $$lang.po ] ; then \
             cp $(srcdir)/$$lang.po . ; \
          fi ; \
	  cp $$lang.po $$lang.old.po; \
	  echo $(MSGMERGE) $$lang; \
	  if   $(MSGMERGE) $$lang >/dev/null 2>&1; then \
	    $(RM) $$lang.old.po; \
	  else \
	    echo "msgmerge for $$cat failed!"; \
	    $(RM) $$lang.po; \
	    mv $$lang.old.po $$lang.po; \
	  fi; \
	done

.po: Makefile
	$(MAKE) $(GETTEXT_PACKAGE).pot;
	INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) ; \
	export INTLTOOL_EXTRACT ; \
	XGETTEXT_ARGS="$(XGETTEXT_ARGS)" ; \
	export XGETTEXT_ARGS ; \
	echo; printf "$*: "; \
	if $(MSGMERGE) $*; then \
	  $(RM) $*.old.po; \
	  else \
	    echo "msgmerge for * failed!"; \
	    mv $*.old.po $*.po; \
	fi; \
	msgfmt --statistics $*.po; echo;


# POTFILES is created from POTFILES.in by stripping comments, empty lines
# and Intltool tags (enclosed in square brackets), and appending a full
# relative path to them
POTFILES: $(srcdir)/POTFILES.in
	( if test 'x$(srcdir)' != 'x.'; then \
	    posrcprefix='$(srcdir)/../'; \
	  else \
	    posrcprefix="../"; \
	  fi; \
	  $(RM) $@-t $@ \
	    && (sed -e '/^#/d' 						\
		    -e "s/^\[.*\] +//" 					\
		    -e '/^[ 	]*$$/d' 				\
		    -e "s@.*@	$$posrcprefix& \\\\@" < $(srcdir)/$@.in	\
		| sed -e '$$s/\\$$//') > $@-t \
	    && chmod a-w $@-t \
	    && mv $@-t $@ )

Makefile: Makefile.in.in $(top_builddir)/config.status POTFILES
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
	       $(SHELL) ./config.status

$(INTLTOOL_MERGE): $(top_srcdir)/intltool-merge.in
	cd $(top_builddir) && $(SHELL) ./config.status intltool

$(INTLTOOL_UPDATE): $(top_srcdir)/intltool-update.in
	cd $(top_builddir) && $(SHELL) ./config.status intltool

$(INTLTOOL_EXTRACT): $(top_srcdir)/intltool-extract.in
	cd $(top_builddir) && $(SHELL) ./config.status intltool

$(srcdir)/linguas.rc: $(srcdir)/LINGUAS
	$(MAKE) -C $(top_builddir)/potools all-am
	$(AM_V_GEN)$(top_builddir)/potools/polinguas --podir . --linguas $< > $@.tmp && mv $@.tmp $@ || { $(RM) $@.tmp; false; }

# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
