# $Id: Makefile,v 1.11 2001/01/26 16:23:10 reggers Exp $
#
# Install things in the right places. Tools for patch management.
# If your right place is elsewhere try:
#
#	make ROOT=/opt/patches install
#
# Reg Quinton <reggers@ist.uwaterloo.ca>; 27-Sep-2000

SHELL=/bin/sh
INSTALL=/usr/ucb/install

# Tailor these from the command line (or edit to your liking

ROOT=/usr/local
ETC=$(ROOT)/etc

# the rest is boiler plate

ETCS= CheckPatches GetApplyPatch
DOCS= CheckPatches.README GetApplyPatch.README
MANS= CheckPatches.8      GetApplyPatch.8
HTML= CheckPatches.html   GetApplyPatch.html
LIBS= CheckPatches.cron   GetApplyPatch.cron
SRCS= $(ETCS) $(DOCS) $(MANS) $(LIBS) Makefile BEWARE
DOC=$(ROOT)/doc
MAN=$(ROOT)/man
MAN8=$(MAN)/man8
CAT8=$(MAN)/cat8
LIB=$(ROOT)/lib
DIRS= $(ROOT) $(ETC) $(DOC)  $(MAN) $(MAN8) $(CAT8) $(LIB)

OWNER=root
GROUP=root

all: $(SRCS)

install:  $(SRCS) $(DIRS)
	for i in $(ETCS); do \
		$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 $$i $(ETC);\
	done
	for i in $(DOCS); do \
		$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 644 $$i $(DOC); \
	done
	for i in $(MANS); do \
		$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 644 $$i $(MAN8); \
		nroff -man $$i > $(CAT8)/$$i; chmod 644 $(CAT8)/$$i; \
	done
	for i in $(LIBS); do \
		$(INSTALL) -c -o $(OWNER) -g $(GROUP) -m 755 $$i $(LIB);\
	done

$(SRCS):; co $@

$(DIRS):; umask 022; mkdir -p $@

# if not at UWaterloo/Xhier try "make traditional"

traditional:; make install ROOT=/usr/local ETC=/usr/local/etc

# A traditional Unix kit to share with others

kit:	$(SRCS) $(HTML)
	chmod a+r  $(SRCS) $(HTML)
	tar cf patches.tar $(SRCS) $(HTML)

# To turn man pages into html pages

.SUFFIXES: .html .8
.8.html:; nroff -man $? | man2html > $@
