
### this is the top-level makefile for the opihi collection of programs

default: all

### the include file dependencies need to be cleaned up still

mana:     	 lib.data lib.shell cmd.basic cmd.data cmd.astro
dimm:     	 lib.data lib.shell cmd.basic cmd.data cmd.astro
dvo:      	 lib.data lib.shell cmd.basic cmd.data cmd.astro
pantasks: 	 lib.data lib.shell cmd.basic cmd.data cmd.astro
pantasks_server: lib.data lib.shell cmd.basic cmd.data cmd.astro
pantasks_client: lib.data lib.shell cmd.basic cmd.data cmd.astro
pclient:  	 lib.data lib.shell cmd.basic
pcontrol: 	 lib.data lib.shell cmd.basic

LIBS = lib.data lib.shell cmd.basic cmd.data cmd.astro

PROGRAM = mana dvo pantasks pclient pcontrol
SPECIAL = pantasks_client pantasks_server

EXTRAS = dimm

all:
	for i in $(PROGRAM) $(SPECIAL); do make $$i || exit; done
	make pantasks_client
	make pantasks_server

libs:
	for i in $(LIBS); do make $$i || exit; done

extras:
	for i in $(EXTRAS); do make $$i || exit; done

install:
	for i in $(PROGRAM) $(SPECIAL); do make $$i.install || exit; done
	make pantasks_client.install
	make pantasks_server.install

extras-install:
	for i in $(EXTRAS); do make $$i.install || exit; done

clean:
	for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do make $$i.clean || exit; done

libs-uninstall:
	for i in $(LIBS); do make $$i.uninstall || exit; done

dist: clean
	for i in $(PROGRAM) $(SPECIAL) $(EXTRAS) $(LIBS); do make $$i.dist || exit; done
	rm -rf bin
	rm -rf lib

#############################################################

pantasks_client pantasks_server:
	if [ -d pantasks ]; then (cd pantasks && make $@); fi

pantasks_client.install: pantasks_client
	if [ -d pantasks ]; then (cd pantasks && make $@); fi

pantasks_server.install: pantasks_server
	if [ -d pantasks ]; then (cd pantasks && make $@); fi

$(PROGRAM) $(LIBS) $(EXTRAS):
	if [ -d "$@" ]; then (cd $@ && make); fi

%.install:
	if [ -d "$*" ]; then make $*; fi
	if [ -d "$*" ]; then (cd $* && make install); fi

%.clean:
	if [ -d "$*" ]; then (cd $* && make clean); fi

%.dist:
	if [ -d "$*" ]; then (cd $* && make dist); fi

%.uninstall:
	if [ -d "$*" ]; then (cd $* && make uninstall); fi

.PHONY: $(PROGRAM) $(LIBS) pantasks_server pantasks_client
