#
#       Makefile 
#
#
# Where to install the build executables and man pages
PREFIX = /tmp/usr/local
ETCDIR = /tmp/etc
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man

MAN1DIR = $(MANDIR)/man1
MAN5DIR = $(MANDIR)/man5

# what are the targets
ETC	= stt.conf
BIN     = stt2
MAN1	= stt.1
MAN5	= stt.5

LN_S		= ln -s
INSTALL_SCRIPT  = install -c -m 555 
INSTALL_DATA    = install -c -m 444 
mkinstalldirs   = mkdir -p

transform	= s,x,x,

## default rule: make all targets (binaries).
all: install

## install 
# install each build target into the correct place

install: install_bin install_etc install_man1 install_man5

install_bin: $(BIN)
	-$(mkinstalldirs) $(BINDIR)
	@list='$(BIN)'; for p in $$list; do \
	if test -f $$p; then \
	  echo " $(INSTALL_SCRIPT) $$p $(BINDIR)/`echo $$p|sed '$(transform)'`"; \
	  $(INSTALL_SCRIPT) $$p $(BINDIR)/`echo $$p|sed '$(transform)'`; \
	fi; done

install_etc: $(ETC)
	-$(mkinstalldirs) $(ETCDIR)
	@list='$(ETC)'; for p in $$list; do \
	if test -f $$p; then \
	  echo " $(INSTALL_DATA) $$p $(ETCDIR)"; \
	  $(INSTALL_DATA) $$p $(ETCDIR); \
	fi; done


install_man1: $(MAN1)
	-$(mkinstalldirs) $(MAN1DIR)
	@list='$(MAN1)'; for p in $$list; do \
	if test -f $$p; then \
	  echo " $(INSTALL_DATA) $$p $(MAN1DIR)/`echo $$p|sed '$(transform)'`"; \
	  $(INSTALL_DATA) $$p $(MAN1DIR)/`echo $$p|sed '$(transform)'`; \
	fi; done

install_man5: $(MAN5)
	-$(mkinstalldirs) $(MAN5DIR)
	@list='$(MAN5)'; for p in $$list; do \
	if test -f $$p; then \
	  echo " $(INSTALL_DATA) $$p $(MAN5DIR)/`echo $$p|sed '$(transform)'`"; \
	  $(INSTALL_DATA) $$p $(MAN5DIR)/`echo $$p|sed '$(transform)'`; \
	fi; done

