#
# $Id: Makefile.sub,v 1.1.1.2 2002/11/06 23:21:40 jevans Exp $
#
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
CLEANADD=temp

all: mmroff

install: install_mm

install_mm: install_mmroff install_m
	-test -d $(tmacdir)/mm || $(mkinstalldirs) $(tmacdir)/mm
	-for f in $(FILES); do \
		rm -f $(tmacdir)/mm/$$f; \
		$(INSTALL_DATA) $(srcdir)/mm/$$f $(tmacdir)/mm/$$f; \
	done
	-for f in $(LOCALE); do \
		test -f $(tmacdir)/mm/$$f || touch $(tmacdir)/mm/$$f; \
	done

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

install_mmroff: mmroff
	-test -d $(bindir) || $(mkinstalldirs) $(bindir)
	-rm -f $(bindir)/mmroff
	$(INSTALL_SCRIPT) mmroff $(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 $(tmacdir)/mm/$$f; done
	-for f in $(LOCALE); do \
	test -s $(tmacdir)/mm/$$f || rm -f $(tmacdir)/mm/$$f; \
	done
	-rm -f $(tmacdir)/tmac.$(tmac_m_prefix)m
	-rm -f $(tmacdir)/$(tmac_m_prefix)m.tmac
	-rm -f $(tmacdir)/$(tmac_m_prefix)mm.tmac
	-rm -f $(tmacdir)/$(tmac_m_prefix)mse.tmac
	-rm -f $(tmacdir)/$(tmac_m_prefix)mmse.tmac
	-rmdir $(tmacdir)/mm
	-rm -f $(bindir)/mmroff
