# We know this file's position relative to the root directory of the project,
# and MAKEFILE_LIST will give us the full path to this file no matter where the
# user has installed this project.
export MYPROJECT_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)

# Specify include paths for your headers.
MYPROJECT_INCLUDE := -I$(MYPROJECT_HOME)/include

# Users may set different flags for C and C++, so you should really modify both
# to be safe.
TRICK_CFLAGS   += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)
TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE)

MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/trickified_myproject.o

# Tell Trick the headers and source at this location are part of a
# Trickified project
TRICK_EXT_LIB_DIRS += :$(MYPROJECT_HOME)

# Tell Trick where to find the Python modules generated by SWIG
TRICK_PYTHON_PATH += :$(MYPROJECT_HOME)/trickified/python

# Tell SWIG where to find py_*.i files
TRICK_SWIG_FLAGS += -I$(MYPROJECT_HOME)/trickified

# Link in the Trickified object
TRICK_LDFLAGS += $(MYPROJECT_TRICK)

# Append a prerequisite to the $(SWIG_SRC) target. This will build the
# Trickified library along with the sim if it does not already exist. Using
# $(SWIG_SRC) ensures that all Trickified .i files are created before SWIG is
# run on any simulation .i files, which may %import them. Note that this does
# NOT cause the Trickified library to be rebuilt if it already exists, even if
# the Trickified source code has changed.
$(SWIG_SRC): $(MYPROJECT_TRICK)

$(MYPROJECT_TRICK):
	@$(MAKE) -s -C $(MYPROJECT_HOME)/trickified
