#------------------------------------------------------------------------------
# Makefile for the Oberon library
# afb 1/92
#------------------------------------------------------------------------------

# the directories must be given in the topological order of their modules
LibDirs :=	lib
ClientDirs :=	clients
Dirs :=		$(LibDirs) $(ClientDirs)

#------------------------------------------------------------------------------
libobpath :=	.
clientobpath := ../lib
# directory of the compiler and the associated files
OBLIB :=	/usr/local/lib/oberon
# compilation flags (usually -OC -OT to suppress range and conversion checks)
OCFLAGS :=	-OC -OT
# where to install the libraries (usually equivalent to OBLIB)
LIBDIR :=	$(OBLIB)
# where to install binaries
BINDIR :=	/usr/local/bin

#------------------------------------------------------------------------------
define propagate-target
@for dir in $(LibDirs) ;\
do	cd $$dir; \
	echo make $@ in $$dir; \
	$(MAKE) OBPATH=$(libobpath) $@ || break; \
	cd ..; \
done
@for dir in $(ClientDirs) ;\
do	cd $$dir; \
	echo make $@ in $$dir; \
	$(MAKE) OBPATH=$(clientobpath) $@ || break; \
	cd ..; \
done
endef
#------------------------------------------------------------------------------

.PHONY: all
all:		; $(propagate-target)

.PHONY: install
install:	; $(propagate-target)

.PHONY: clean
clean:		; $(propagate-target)

.PHONY: depend
depend:
		@for dir in $(LibDirs) ;\
		do	echo make $@ in $$dir; \
			(cd $$dir; OBPATH=$(libobpath) mmo -u makefile) \
		done
		@for dir in $(ClientDirs) ;\
		do	echo make $@ in $$dir; \
			(cd $$dir; OBPATH=$(clientobpath) mmo -u makefile) \
		done
