#
# Makefile for etc subdirectory
#
# $Id: Makefile.in,v 1.15 2005/11/08 16:58:08 opk Exp $
#

SHELL = /bin/sh

top_srcdir = @top_srcdir@
srcdir     = @srcdir@
VPATH      = @srcdir@

prefix      = @prefix@
exec_prefix = @exec_prefix@
bindir      = @bindir@
libdir      = @libdir@
etcdir      = @sysconfdir@

MTS         = @MTS@
mailspool   = @mailspool@
masquerade  = @masquerade@
smtpservers = @smtpservers@

INSTALL         = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT  = @INSTALL_SCRIPT@
INSTALL_DATA    = @INSTALL_DATA@

# Path to search for programs to handle MIME
# content.  Used to create mhn.defaults
MHNSEARCHPATH = "$(PATH):/usr/demo/SOUND"

# Program used to search path for various programs to
# handle MIME content.  Used to create mhn.defaults
MHNSEARCHPROG = $(srcdir)/mhn.find.sh

SED = sed

.SUFFIXES:

# static configuration, format, and components files
STATIC_FILES =  MailAliases components digestcomps distcomps forwcomps	\
		mhl.body mhl.digest mhl.format mhl.forward mhl.headers	\
		mhl.reply rcvdistcomps rcvdistcomps.outbox		\
	       	replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD	\
	       	scan.default scan.mailx scan.nomime scan.size scan.time	\
	       	scan.timely scan.unseen

# templates and scripts from which non-static files are generated
GENERATED_FILE_SRCS = mhn.defaults.sh mhn.find.sh mts.conf.in sendfiles.in

# scripts generated using above GENERATED_FILE_SRCs
GENERATED_BIN_FILES = sendfiles

# non-scripts generated using above GENERATED_FILE_SRCs
GENERATED_ETC_FILES = mhn.defaults mts.conf

# auxiliary files (included in distribution but not installed)
AUX = Makefile.in

# all non-generated files in this directory are included in the distribution
DIST = $(STATIC_FILES) $(GENERATED_FILE_SRCS) $(AUX)

# ========= DEPENDENCIES FOR BUILDING ==========

all: $(GENERATED_BIN_FILES) $(GENERATED_ETC_FILES)

mhn.defaults: $(srcdir)/mhn.defaults.sh $(MHNSEARCHPROG)
	rm -f $@
	$(srcdir)/mhn.defaults.sh $(MHNSEARCHPATH) $(MHNSEARCHPROG) > $@

mts.conf: $(srcdir)/mts.conf.in Makefile
	rm -f $@
	$(SED) -e 's,%mts%,$(MTS),' \
	       -e 's,%mailspool%,$(mailspool),' \
	       -e 's,%etcdir%,$(etcdir),' \
	       -e 's,%masquerade%,$(masquerade),' \
	       -e 's,%smtpservers%,$(smtpservers),' < $(srcdir)/mts.conf.in > $@

sendfiles: $(srcdir)/sendfiles.in Makefile
	rm -f $@
	$(SED) -e 's,%libdir%,$(libdir),' < $(srcdir)/sendfiles.in > $@

install: install-bin-files install-etc-files

install-bin-files:
	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
	for script in $(GENERATED_BIN_FILES); do \
	  $(INSTALL_SCRIPT) $$script $(DESTDIR)$(bindir)/$$script; \
	done

install-etc-files:
	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(etcdir)
	INSTALL_FILES="$(GENERATED_ETC_FILES)"; \
	for file in $(STATIC_FILES); do \
	  INSTALL_FILES="$$INSTALL_FILES $(srcdir)/$$file"; \
	done; \
	for path in $$INSTALL_FILES; do \
	  file=`basename $$path`; \
	  echo "Installing $$file..."; \
	  if [ -f $(DESTDIR)$(etcdir)/$$file ]; then \
	    mv $(DESTDIR)$(etcdir)/$$file $(DESTDIR)$(etcdir)/$$file.prev; \
	    $(INSTALL_DATA) $$path $(DESTDIR)$(etcdir)/$$file; \
	    if diff $(DESTDIR)$(etcdir)/$$file.prev $(DESTDIR)$(etcdir)/$$file; then \
	      rm $(DESTDIR)$(etcdir)/$$file.prev; \
	    else \
	      echo; \
	      echo "  Previous version of $$file saved as $$file.prev due\c";\
	      echo   " to diffs."; \
	      echo "  Please merge any local config changes into the new\c"; \
	      echo   " $$file."; \
	      echo; \
	    fi; \
	  else \
	    $(INSTALL_DATA) $$path $(DESTDIR)$(etcdir)/$$file; \
	  fi; \
	  $(INSTALL_DATA) $$path $(DESTDIR)$(etcdir)/$$file-dist; \
	done

uninstall: uninstall-bin-files uninstall-etc-files

uninstall-bin-files:
	for script in $(GENERATED_BIN_FILES); do \
	  rm -f $(DESTDIR)$(bindir)/$$script; \
	done

uninstall-etc-files:
	for file in $(STATIC_FILES) $(GENERATED_ETC_FILES); do \
	  rm -f $(DESTDIR)$(etcdir)/$$file; \
	done

# ========== DEPENDENCIES FOR CLEANUP ==========

mostlyclean:
	rm -f *~

clean: mostlyclean
	rm -f $(GENERATED_ETC_FILES) $(GENERATED_BIN_FILES)

distclean: clean
	rm -f Makefile

realclean: distclean

superclean: realclean

# ========== DEPENDENCIES FOR MAINTENANCE ==========

subdir = etc

Makefile: Makefile.in ../config.status
	cd .. && ./config.status $(subdir)/$@
 
distdir = ../`cat ../distname`/$(subdir)
nmhdist: $(DIST)
	@echo "Copying distribution files in $(subdir)"
	@for file in $(DIST); do \
	  cp -p $(srcdir)/$$file $(distdir); \
	done



syntax highlighted by Code2HTML, v. 0.9.1