# --------------------------------------------------------------------------
# Copyright 1992 by Forschungszentrum Informatik (FZI)
#
# You can use and distribute this software under the terms of the license
# version 1 you should have received along with this software.
# If not or if you want additional information, write to
# Forschungszentrum Informatik, "OBST Projekt", Haid-und-Neu-Strasse 10-14,
# D-76131 Karlsruhe, Germany.
# --------------------------------------------------------------------------
default: all

include ../tut_common.mk

EXAMPLES=$(SAMPLE)

UF=$(EXAMPLES)/UnixFile
TF=$(EXAMPLES)/TextFile
CP=$(EXAMPLES)/Compiler

INCLUDES=$(OBST_INCLUDES) -I$(UF) -I$(TF)


# ~~~~~~~~~~~~~
# Compiler demo
# ~~~~~~~~~~~~~

all: USED_MODULES $(CP)/Compiler

clean:
	rm -f $(CP)/*.o $(CP)/Compiler

realclean: clean
	rm -f $(CP)/*_obst.[Cch] $(CP)/*_use.h $(CP)/*_scp.C
	touch $(CP)/*.obst


# ~~~~~~~~~~~~~~~~
# used modules
# ~~~~~~~~~~~~~~~~
# Compiler uses TextFile uses UnixFile

TF_OBJS = $(TF)/TextFile_obst.o $(TF)/TextFile.o
UF_OBJS = $(UF)/UnixFile_obst.o $(UF)/UnixFile.o

USED_MODULES:
	cd $(TF); make ALL_MODULES


# ~~~~~~~~~~~~~~~~~
# module:  Compiler
# ~~~~~~~~~~~~~~~~

CP_OBJS = $(CP_MODULES) $(CP_MAIN)

CP_MAIN = $(CP)/Compiler_main.o

CP_MODULES = $(CP)/Compiler_obst.o $(CP)/Compiler.o

ALL_MODULES: USED_MODULES $(CP_MODULES)


$(CP)/Compiler_obst.h $(CP)/Compiler_use.h $(CP)/Compiler_obst.C: \
	   $(CP)/Compiler.obst
	$(OBST.CMP) Compiler

$(CP)/Compiler_obst.o: $(CP)/Compiler_obst.C $(CP)/Compiler_obst.h
	$(OBST.GEN.CC) $(CP)/Compiler_obst.C

$(CP)/Compiler.o: $(CP)/Compiler_obst.h $(CP)/Compiler.C
	$(OBST.CC) $(CP)/Compiler.C


$(CP)/Compiler_main.o: $(CP)/Compiler_use.h $(CP)/Compiler_main.C
	$(COMP.CC) $(CP)/Compiler_main.C 

$(CP)/Compiler: ALL_MODULES $(CP_MAIN) $(OBSTLIB)/libOBST*
	$(LINK.CC) $(UF_OBJS) $(TF_OBJS) \
		   $(CP_OBJS) $(libOBST)  $(LDFLAGS)
