# Brainstem2Example C

CPP = g++
ROOT = .
TARGET = BrainStem2Shell
OUT := linux_$(TARGET)
DBG_DST := $(OUT)/Debug
REL_DST := $(OUT)/Release

# We are looking for the BrainStem2 library in
# a lib folder sibling to this makefile. Change
# these defines to point somewhere else if this
# is not the case.
LIBRARIES := -L$(ROOT)/lib -lBrainStem2
INCLUDES := -Ilib/

# We add the current directory to the rpath expecting
# that libBrainStem2.so will be copied into the build
# folder. If this is not the case adjust the rpath
# do match your needs.
CFLAGS = -std=c++11 -Wall -Werror -Wl,-rpath,. $(INCLUDES)

all : dirs
	make app

app : debug release

.PHONY : debug
debug: dirs
	$(CPP) $(CFLAGS) BrainStem2Shell/main.cpp $(LIBRARIES) -o $(DBG_DST)/BrainStem2Shell
	cp lib/libBrainStem2.so $(DBG_DST)
	
.PHONY : release
release: dirs
	$(CPP) $(CFLAGS) -DNDEBUG BrainStem2Shell/main.cpp $(LIBRARIES) -o $(REL_DST)/BrainStem2Shell
	cp lib/libBrainStem2.so $(REL_DST)

.PHONY : dirs
dirs:
	mkdir -p $(DBG_DST)
	mkdir -p $(REL_DST)

clean:
	rm -rf $(OUT)
