#
# Destinations
APP   = firewall
INIT  = /etc/init.d
ETC   = /etc
ETCD  = /etc/firewall.d
BIN   = /usr/local/bin
UID   = root
S_lvl = S100
K_lvl = K100
DOC   = /usr/local/doc


#
# Binaries
INSTALL = install


#
# Sources
SRC   = src
S_BIN = $(SRC)/bin/*
S_CFG = $(SRC)/etc/firewall.conf
S_SCR = $(SRC)/etc/firewall.d/*
S_DOC = doc/*
S_RC  = rc.d/firewall






all:
	@echo "type 'make install' or 'make update'"



install: confinstall bininstall docinstall


update: bininstall docinstall


bininstall:
	install -o $(UID) -m 700 $(S_RC) $(INIT)/$(APP)
	ln -sf $(INIT)/$(APP) ../rc2.d/$(S_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc2.d/$(K_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc3.d/$(S_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc3.d/$(K_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc5.d/$(S_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc5.d/$(K_lvl)_$(APP)
	ln -sf $(INIT)/$(APP) ../rc0.d/$(K_lvl)_$(APP)


confinstall:
	install -d -o $(UID) -m 700 $(ETCD)
	install -o $(UID) -m 600 $(S_SCR) $(ETCD)/
	install -o $(UID) -m 600 $(S_CFG) $(ETC)/
	install -o $(UID) -m 700 $(S_BIN) $(BIN)/


docinstall:
	install -d -o $(UID) -m 755 $(DOC)/$(APP)
	install -o $(UID) -m 644 $(S_DOC) $(DOC)/$(APP)/

	@echo "Edit /etc/firewall.* and execute '/etc/init.d/firewall start'"



clean:
	pod2text doc/readme.pod > doc/readme.txt
	pod2html doc/readme.pod > doc/readme.html
	rm -rf *~ */*~ */*/*~