### Change the variable below, so they match your system ###

#Path to your SCV installation
SCV=/Users/robertguenzel/apps/systemc-scv-2.2

#Path where to install ocpip package
# Note, this must exactly match what you have chosen
#  for the OCP socket kit!
INSTALLPATH=/Users/robertguenzel/apps/ocp_install

#Path to your systemc installation
SYSTEMC=/Users/robertguenzel/apps/systemc-2.2

#Path to your TLM2 installation
TLM2=/Users/robertguenzel/mydev/cpp_systemc/tlm2_svn/svn

#the target architecture of your system
#  the default value tries to guess it from your systemc installation
#  if that fails, set it manually
TARGET_ARCH = $(subst $(SYSTEMC)/lib-,,$(wildcard $(SYSTEMC)/lib-*))

#### DO NOT MODIFY BELOW THIS LINE !#####

VERSION=$(shell less ../recent_version.txt)
SRC_EXT=cpp
SOURCES=$(wildcard ./src/ocpip_dev/*.$(SRC_EXT))
OBJECTS=$(SOURCES:%.$(SRC_EXT)=%.o)
DIR=$(shell pwd)

TPPS=$(subst ocpip_dev,ocpip_$(VERSION),$(foreach file, $(wildcard src/ocpip_dev/*.tpp), $(INSTALLPATH)/mon/$(file)))
HPPS=$(subst ocpip_dev,ocpip_$(VERSION),$(foreach file, $(wildcard src/ocpip_dev/*.hpp), $(INSTALLPATH)/mon/$(file)))
G_HEADERS=$(foreach file, $(wildcard include/generic/*.h), $(INSTALLPATH)/mon/$(file)) 
V_HEADERS=$(subst ocpip_dev,ocpip_$(VERSION),$(foreach file, $(wildcard include/ocpip_dev/*.h), $(INSTALLPATH)/mon/$(file)))
TARGETLIB=$(INSTALLPATH)/lib-$(TARGET_ARCH)/$(FULL_LIBNAME)
EXAMPLE_MKF=$(wildcard $(INSTALLPATH)/examples/Makefile.conf)
LEGACY_SOURCE=$(foreach file, $(wildcard include/legacy_code_base/*.legacy.h), $(INSTALLPATH)/mon/$(file))

all: install

debug | opt : make_dirs $(G_HEADERS) $(V_HEADERS) $(TPPS) $(HPPS) $(LEGACY_SOURCE) Makefile

install: opt
	@echo $(EXAMPLE_MKF)
ifeq ($(EXAMPLE_MKF), $(INSTALLPATH)/examples/Makefile.conf)
	@echo Adding Makefile.mon.conf to examples
	@echo USE_OCP_MONITOR=1 >$(INSTALLPATH)/examples/Makefile.mon.conf;
	@echo SCV=$(SCV)>>$(INSTALLPATH)/examples/Makefile.mon.conf;
	@echo GOLDEN_PATH=$(DIR)/../regression/golden_vectors>>$(INSTALLPATH)/examples/Makefile.mon.conf;
endif
	@echo Installation done

make_dirs:
	mkdir -p $(INSTALLPATH)/mon/include/ocpip_$(VERSION);
	mkdir -p $(INSTALLPATH)/mon/include/generic;
	mkdir -p $(INSTALLPATH)/mon/src/ocpip_$(VERSION);
	mkdir -p $(INSTALLPATH)/mon/include/legacy_code_base;
	mkdir -p $(INSTALLPATH)/mon/include/legacy_support;

$(INSTALLPATH)/mon/src/ocpip_$(VERSION)/%.tpp : ./src/ocpip_dev/%.tpp
	cp $< $@

$(INSTALLPATH)/mon/include/legacy_code_base/%.legacy.h : ./include/legacy_code_base/%.legacy.h
	../cp_legacy $< $@ $(INSTALLPATH)/mon $(@F) ../recent_version.txt ./

$(INSTALLPATH)/mon/src/ocpip_$(VERSION)/%.hpp : ./src/ocpip_dev/%.hpp
	cp $< $@

$(INSTALLPATH)/mon/include/ocpip_$(VERSION)/%.h : ./include/ocpip_dev/%.h
	cp $< $@

$(INSTALLPATH)/mon/include/generic/%.h : ./include/generic/%.h
	cp $< $@

