.PHONY: all system-info help depend libs apps dist \
        install install-bin install-apps install-doc \
	uninstall uninstall-bin uninstall-apps uninstall-doc
@if libs
.PHONY: libs
@end
@if texinfo
.PHONY: install-dvi uninstall-dvi
@end

PROJECT_HOME = .
include $(PROJECT_HOME)/rules/init.mk

@if libs
LIB_DIRS =	LIBRARYDIRS
@end
APP_DIRS =	APPLICATIONDIRS
@if libs
SUB_DIRS =	$(LIB_DIRS) $(APP_DIRS)
@else
SUB_DIRS =	$(APP_DIRS)
@end

@if libs
all: libs apps
@else
all: apps
@end

help:
	@(\
	echo "make help            prints this help-text";\
	echo "make system-info     prints system-identifier";\
@if libs
	echo "make all             = make libs apps";\
@else
	echo "make all             = make apps";\
@end
	echo "make depend          sets up dependencies";\
@if libs
	echo "make libs            creates the libraries";\
@end
	echo "make apps            compiles the applications";\
	echo "make dist            tar and gzip everything to \$$TARGET_DIR";\
	echo "make install         = make install-bin install-doc";\
	echo "make install-bin     installs all binaries";\
	echo "make install-doc     installs documentation";\
@if texinfo
	echo "make install-dvi     installs pretty documentation";\
@endif
	echo "make uninstall       = make uninstall-bin uninstall-doc";\
	echo "make uninstall-bin   removes all installed binaries"; \
	echo "make uninstall-doc   removes installed documentation";\
@if texinfo
	echo "make uninstall-dvi   removes installed pretty documentation";\
@endif
	echo "make mostlyclean     deletes systems' programs and objects";\
	echo "make clean           deletes systems' binaries";\
	echo "make realclean       deletes all files created for this system";\
	echo "make distclean       deletes everything that can be remade";\
	)

system-info:
	@echo "$(SYSTEM)"

dist:
	rules/collect.sh \
	  --home=$(PROJECT_HOME) \
	  --version=$(VERSION) \
	  --target-dir=$(TARGET_DIR)

@if libs
libs:
	for DIR in $(LIB_DIRS); do $(MAKE) -C $$DIR; done
@endif

apps:
	for DIR in $(APP_DIRS); do $(MAKE) -C $$DIR; done

include $(PROJECT_HOME)/rules/subdirs.mk
