#
# CDWserver/config/Makefile
#
# This file is part of webCDwriter - Network CD Writing.
#
# Copyright (C) 1999-2005 Jrg P. M. Haeger
#
# webCDwriter is free software. See CDWserver.cpp for details.
#

include ../../config

config: config.default
	cat config.default \
		| sed s*#portNo=12411*portNo=$(PORT)*g \
		> config

install: config
	install -d -m 755 $(CONFIGDIR)
	$(INSTALL_644) config.default $(CONFIGDIR)/
	@for name in *; do \
		if [ -e $(CONFIGDIR)/$$name ]; then \
			echo "$@ will not overwrite existing $(CONFIGDIR)/$$name"; \
			if test $$name = config; then \
				chown $(USER) $(CONFIGDIR)/config \
					|| echo "Cannot set the owner of $(CONFIGDIR)/config"; \
			fi; \
		elif [ $$name = accounts ] || [ $$name = password ]; then \
			$(INSTALL_UG) -m 600 $$name $(CONFIGDIR)/ 2> /dev/null \
				|| $(INSTALL) -m 600 $$name $(CONFIGDIR)/; \
		elif [ $$name = config ]; then \
			$(INSTALL_644UG) config $(CONFIGDIR)/ 2> /dev/null \
				|| $(INSTALL_644) config $(CONFIGDIR)/; \
		elif [ $$name = config-root ]; then \
			$(INSTALL) -m 600 config-root $(CONFIGDIR)/; \
		elif [ $$name = Makefile ]; then \
			:; \
		else \
			echo "$(INSTALL_FILE) $$name $(CONFIGDIR)/"; \
			$(INSTALL_644) $$name $(CONFIGDIR)/; \
		fi; \
	done

clean:
	rm -rf .[!.]*
	rm -f *~ *.o core config
