#
# $Id: Makefile,v 1.6 2006/11/18 09:20:55 maxim Exp $
# 
include src/Rules.make

compile:
	cd src/common && $(MAKE)
	cd src/httpd && $(MAKE)

clean:
	cd src/common && $(MAKE) clean
	cd src/httpd && $(MAKE) clean
	rm -f *~ src/*~

install: compile
	install -d $(ROOT)/bin $(ROOT)/conf $(ROOT)/docs
	install -d -o $(OWNER) -g $(GROUP) $(ROOT)/logs $(ROOT)/data/pids $(ROOT)/data/httpd
	test -f $(ROOT)/conf/httpd.conf || install -m 644 conf/httpd.conf* $(ROOT)/conf
	install -b -m 644 conf/countries* conf/regions* $(ROOT)/conf
	install -b -m 644 docs/crontab docs/httpd.ru.txt $(ROOT)/docs
	install -b bin/update-countries.sh src/httpd/convert-ranges src/httpd/convert-geoip $(ROOT)/bin
	install -b -m 6755 -o $(OWNER) -g $(GROUP) src/httpd/0W-httpd $(ROOT)/bin
	@echo
	@echo "Installed, run as root: $(ROOT)/bin/0W-httpd [-h]"

upgrade: install
	$(ROOT)/bin/0W-httpd -t
	killall 0W-httpd && sleep 1 || true
	$(ROOT)/bin/0W-httpd -w

uninstall:
	@test -d $(ROOT) || (echo "0W-httpd is not installed in $(ROOT)" && false)
	@echo
	@echo "This will remove directory $(ROOT)!"
	@echo "Press <Enter> to confirm, <Ctrl-C> to abort"
	@read answer
	killall 0W-httpd || true
	rm -rf $(ROOT)
