# rcsid $Id: Makefile,v 1.1 1996/02/27 20:00:48 smp Exp smp $

# makefile for remote control clients & server

include rc.mk

PACKAGE = rc
DIR = rc

SUBDIRS = \
	daemon/ \
	x10d/ \
	x10d2/ \
	ird/ \
	hcs2d/ \
	mld/ \
	hcs2evnt/ \
	rccontrol/ \
	x10client/ \
	x10control/ \
	x10virtual/ \
	x10map/ \
	x10namer/ \
	ircontrol/ \
	irnamer/ \
	etc/ \
	bin/ \
	doc/ \
	irhardware/ \
	mlhardware/ \
	serplix/ \
	x10tclsh/ \
	x10wish/

# Xt clients
XTSUBDIRS = \
	x10X11/ \
	xmltherm/ \
	xremote/

# motif clients
MXSUBDIRS = \
	x10widget/

# all X clients
XSUBDIRS = $(XTSUBDIRS) $(MXSUBDIRS)

FILES = \
	Makefile \
	rc.mk \
	README \
	COPYRIGHT \
	TODO

EXECS = \
	x10d/x10d \
	x10d2/x10d2 \
	ird/ird \
	hcs2d/hcs2d \
	mld/mld \
	rccontrol/rccontrol \
	x10client/x10client \
	x10control/x10control \
	x10virtual/x10virtual \
	x10widget/x10widget \
	x10X11/x10X11 \
	xremote/xremote \
	x10map/x10map \
	x10namer/x10namer \
	ircontrol/ircontrol \
	irnamer/irnamer \
	mld/mlnamer \
	mld/mlcontrol \
	xmltherm/xmltherm \
	x10tclsh/x10tclsh \
	x10wish/x10wish


.PHONY: $(EXECS)


.PHONY : all
all ::
	@$(foreach d,$(SUBDIRS),cd $(dir $(d)); $(MAKE); cd ..;)
	@$(foreach d,$(XTSUBDIRS),cd $(dir $(d)); \
		xmkmf; $(MAKE); cd ..;)
	@$(foreach d,$(MXSUBDIRS),cd $(dir $(d)); \
		mxmkmf; $(MAKE); cd ..;)

.PHONY : install
install : setup
	@$(foreach d,$(SUBDIRS),cd $(dir $(d)); $(MAKE) install; cd ..;)
	@$(foreach d,$(XSUBDIRS),cd $(dir $(d)); $(MAKE) install; cd ..;)

.PHONY : clean
clean :
	rm -f $(PACKAGE).tarlist $(PACKAGE).tar
	$(foreach d,$(SUBDIRS),cd $(dir $(d)); $(MAKE) clean; cd ..;)
	$(foreach d,$(XSUBDIRS),cd $(dir $(d)); \
		$(MAKE) -f xmakefile clean; cd ..;)

.PHONY : installclean
installclean :
	@rm -rf $(BIN_DIR)
	@rm -rf $(DOC_DIR)
	@rm -rf $(DATA_DIR)
	@rm -rf $(LOG_DIR)

.PHONY : ci
ci :
	ci -l $(FILES)

.PHONY : ciall
ciall :
	$(foreach d,$(SUBDIRS),cd $(dir $(d)); $(MAKE) ci; cd ..;)
	$(foreach d,$(XSUBDIRS),cd $(dir $(d)); \
		$(MAKE) -f xmakefile ci; cd ..;)

.PHONY : list
list :
	@$(foreach f,$(FILES),echo $(PPATH)$(f);)

.PHONY : tarlist
tarlist :
	@$(MAKE) -s PPATH="rc/" list > $(PACKAGE).tarlist
	@$(foreach d,$(SUBDIRS),cd $(dir $(d));\
		$(MAKE) -s PPATH="rc/" list >> ../$(PACKAGE).tarlist; cd ..;)
	@$(foreach d,$(XSUBDIRS),cd $(dir $(d));\
		$(MAKE) -s -f xmakefile PPATH="rc/" \
		list >> ../$(PACKAGE).tarlist; cd ..;)

.PHONY : tar
tar :
	@$(MAKE) -s tarlist
	@cd ..;tar -cvf $(DIR)/$(PACKAGE).tar `cat $(DIR)/$(PACKAGE).tarlist`

.PHONY : setup
setup :
	@-mkdir $(INSTALL_DIR)
	@-mkdir $(BIN_DIR)
	@-mkdir $(DOC_DIR)
	@-mkdir $(DATA_DIR)
	@-mkdir $(LOG_DIR)
	@-touch $(LOG_DIR)/RCLog
