# Define compilation command and options

COMPILE = vcom
OPTIONS = -93 -work work


# Define library paths

LIBRARY-work = work


# Define library unit files

UNIT-work-comp = \
	$(LIBRARY-work)/comp/_primary.dat
UNIT-work-comp-a_comp = \
	$(LIBRARY-work)/comp/a_comp.dat
UNIT-work-comp_sub = \
	$(LIBRARY-work)/comp_sub/_primary.dat
UNIT-work-comp_sub-a_comp_sub = \
	$(LIBRARY-work)/comp_sub/a_comp_sub.dat


# Define list of all library unit files

ALL_UNITS = \
	$(UNIT-work-comp) \
	$(UNIT-work-comp-a_comp) \
	$(UNIT-work-comp_sub) \
	$(UNIT-work-comp_sub-a_comp_sub)



# Rule for compiling entire design

all : \
		library \
		$(ALL_UNITS)


# Rule for cleaning entire design

clean : 
	-rm -f $(ALL_UNITS)


# Rule for creating library directory

library : \
		$(LIBRARY-work)

$(LIBRARY-work) :
	vlib $(LIBRARY-work); vmap work $(LIBRARY-work)


# Rules for compiling single library units and their subhierarchy

comp : \
		library \
		$(UNIT-work-comp) \
		$(UNIT-work-comp-a_comp) \
		comp_sub

comp_sub : \
		library \
		$(UNIT-work-comp_sub) \
		$(UNIT-work-comp_sub-a_comp_sub)


# Rules for compiling single library unit files

$(UNIT-work-comp) \
$(UNIT-work-comp-a_comp) : \
		D:\test\comp.vhd \
		$(UNIT-work-comp_sub)
	$(COMPILE) $(OPTIONS) D:\test\comp.vhd

$(UNIT-work-comp_sub) \
$(UNIT-work-comp_sub-a_comp_sub) : \
		D:\test\comp_sub.vhd
	$(COMPILE) $(OPTIONS) D:\test\comp_sub.vhd


### Makefile ends here
