#  This is simple example of Makefile for Simula/CIM projects.
#  (Petr Novak 1999)

#  Usage notes:

#   1) Set the variables Exe_file, Main_source, Main_object at your main file
#         at the begining of this makefile

#   2) Set your 'OBJECTS' (except the main object) in the compilation order.

#   3) Set 'Individual file dependencies' at the end of makefile
#         (e.g.: "xxx.obj: xxx.sim yyy.atr")

# Run:
#   make       = make all files
#   make obj   = only make of objects (doesn't link)
#   make clean = clear files with extension .exe .o .c .atr
#   make link  = link only
#   make red   = make all but redirect output to make.log

# ************************************************************************
# !!!!!!!!!!!  * User Project files *   PLEASE FILL THIS VARIABLES !!!
# ************************************************************************

Exe_file    = main.exe
Main_source = main.sim
Main_object = main.o

OBJECTS = myclass1.o myclass2.o

# ************************************************************************
#                  * Ridici makra *
# ************************************************************************

Path=${PATH}
SHELL=${COMSPEC}

# parametry: c = dont link, v = verbose, d = check differnce
SIMC = cim
SIMPAR = -c -d --silent

# parametry pro kompilaci .sim -> .atr
SIMATRPAR = -d -S --silent

SIMLINKPAR = -P --silent 
LINK = cim

MAKELOG=make.log

ifdef redirect
REDIRECTION= >> $(MAKELOG)
endif


# Implicitni zavislosti

.SUFFIXES:

%.o: %.sim
	$(SIMC) $(SIMPAR) $< $(REDIRECTION)

%.atr:
	$(SIMC) $(SIMATRPAR) $*.sim $(REDIRECTION)

# ************************************************************************
#		* Managing Explicit Rules *
# ************************************************************************

all: $(Exe_file)

# Target "red" does 'make', but all stdoutput is redirected to file stored in
# the variable MAKELOG.
red:
	@echo make redirect=yes > make.temp.bat
	@make.temp.bat
	@del make.temp.bat

$(Exe_file): $(OBJECTS) $(Main_object)
	$(LINK) $(SIMLINKPAR) $(Main_source) $(OBJECTS) $(REDIRECTION)
	strip $(Exe_file) $(REDIRECTION)

clean:
	del *.exe
	del *.o
	del *.atr
	del *.c

obj: $(OBJECTS) $(Main_object)

lnk:
	$(LINK) $(SIMLINKPAR) $(OBJECTS) $(REDIRECTION)
	strip $(Exe_file) $(REDIRECTION)

# *************************************************************************
# !!!!!!!!!!   * Individual File Dependencies*  PLEASE FILL THIS RULES !!!
# *************************************************************************

# class1.o: class1.sim <== rule isn't needed (used implicit rule: %.o: %.sim)

class2.o:  class2.sim class1.atr
main.o:    main.sim   class2.atr   

# *************************************************************************
