# Copyright 1991-1993, 1999-2001, 2006, 2007, 2009, 2011
# 
# This file is part of groff.
# 
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# groff is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Makefile.sub
#
#
PROG=mmroff
MAN1=\
  mmroff.n
MAN7=\
  groff_mm.n \
  groff_mmse.n
FILES=0.MT 5.MT 4.MT ms.cov se_ms.cov 
# Local configuration files with default values.
LOCALE=locale se_locale
MOSTLYCLEANADD=temp

all: mmroff

install_bin: install_mmroff

install_data: install_m
	-test -d $(DESTDIR)$(tmacdir)/mm \
	  || $(mkinstalldirs) $(DESTDIR)$(tmacdir)/mm
	-for f in $(FILES); do \
		rm -f $(DESTDIR)$(tmacdir)/mm/$$f; \
		$(INSTALL_DATA) $(srcdir)/mm/$$f $(DESTDIR)$(tmacdir)/mm/$$f; \
	done
	-for f in $(LOCALE); do \
		test -f $(DESTDIR)$(tmacdir)/mm/$$f \
		  || touch $(DESTDIR)$(tmacdir)/mm/$$f; \
	done
	$(INSTALL_DATA) $(srcdir)/refer-mm.tmac $(DESTDIR)$(tmacdir)/refer-mm.tmac

install_m:
	-test -d $(DESTDIR)$(tmacdir) \
	  || $(mkinstalldirs) $(DESTDIR)$(tmacdir)
	-rm -f $(DESTDIR)$(tmacdir)/tmac.$(tmac_m_prefix)m
	-rm -f $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)m.tmac
	$(INSTALL_DATA) $(srcdir)/m.tmac \
	  $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)m.tmac
	@sed -e "s;^.mso m.tmac;.mso $(tmac_m_prefix)m.tmac;g" \
	  $(srcdir)/mse.tmac > $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mse.tmac
	@sed -e "s;^.mso mse.tmac;.mso $(tmac_m_prefix)mse.tmac;g" \
	  $(srcdir)/mmse.tmac > $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mmse.tmac
	@sed -e "s;^.mso m.tmac;.mso $(tmac_m_prefix)m.tmac;g" \
	  $(srcdir)/mm.tmac > $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mm.tmac

install_mmroff: mmroff
	-test -d $(DESTDIR)$(bindir) || $(mkinstalldirs) $(DESTDIR)$(bindir)
	-rm -f $(DESTDIR)$(bindir)/mmroff
	$(INSTALL_SCRIPT) mmroff $(DESTDIR)$(bindir)/mmroff

mmroff: mmroff.pl
	-rm -f $@
	-sed -e 's;/usr/bin/perl;$(PERLPATH);' $(srcdir)/mmroff.pl >$@
	-chmod +x $@

uninstall_sub:
	-for f in $(FILES); do \
		rm -f $(DESTDIR)$(tmacdir)/mm/$$f; \
	done
	-for f in $(LOCALE); do \
		test -s $(DESTDIR)$(tmacdir)/mm/$$f \
		  || rm -f $(DESTDIR)$(tmacdir)/mm/$$f; \
	done
	-rm -f $(DESTDIR)$(tmacdir)/tmac.$(tmac_m_prefix)m
	-rm -f $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)m.tmac
	-rm -f $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mm.tmac
	-rm -f $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mse.tmac
	-rm -f $(DESTDIR)$(tmacdir)/$(tmac_m_prefix)mmse.tmac
	-rm -f $(DESTDIR)$(tmacdir)/refer-mm.tmac
	-rmdir $(DESTDIR)$(tmacdir)/mm
	-rm -f $(DESTDIR)$(bindir)/mmroff
