# $Id: Makefile,v 1.6 1998/07/16 13:55:45 moritz Exp $
SUBSTFILES=Makefile fetchipac ipacsum ipacset fetchipac.8 ipacset.8 \
	ipacsum.8
INSTFILES=fetchipac ipacsum ipacset
MANFILES=fetchipac.8 ipacset.8 ipacsum.8
CC=cc
CONFIG=config

# =()<INSTALLPATH=@<INSTALLPATH>@>()=
INSTALLPATH=/usr/local/bin
# =()<IMANPATH=@<IMANPATH>@>()=
IMANPATH=/usr/local/man/man8

all: dosubst

dosubst: subst config $(SUBSTFILES)
	@for file in $(SUBSTFILES); do \
		./subst -f $(CONFIG) $$file || exit 1; \
	done
	chmod +x $(INSTFILES)
	touch dosubst

# subst may have changed Makefile!
install: dosubst
	make doinstall

doinstall: install-bin install-man

install-bin:
	@for file in $(INSTFILES); do \
		echo "install -o root -g bin -m 755 $$file $(INSTALLPATH)/$$file"; \
		install -o root -g bin -m 755 $$file $(INSTALLPATH)/$$file || exit 1; \
	done

install-man:
	@for file in $(MANFILES); do \
		echo "install -o root -g bin -m 644 $$file $(IMANPATH)/$$file"; \
		install -o root -g bin -m 644 $$file $(IMANPATH)/$$file || exit 1; \
	done
	

subst: subst.c
	$(CC) -o subst subst.c

clean:
	rm -f subst dosubst

