
# Uncomment if debug wanted
#DEBUG:=true

# Application name (name of adef file)
APPLICATION:=arduinomaster

# application includes (for mkapp) - where to find things like API files
#APPLICATION_INCLUDES:= -i reMangOH

# application sources (for mkapp) - where to find non-standard sources
APPLICATION_SOURCES:=

# airvantage application name - must be unique to airvantage
AIRVANTAGE_NAME:=$(APPLICATION)

# mangOH Device IP
DEVICEIP:=192.168.2.2

# Define LEGATO_ROOT
# uncomment following line to use custom LEGATO_ROOT
#LEGATO_ROOT:=/home/developer/legato-16.07.0

# Define target type
TARGET:=wp85

# set some parameters if DEBUG mode
ifdef DEBUG
MKAPPFLAGS:=-C -g -X -g -L -g
APPDBG:=.debug
else
MKAPPFLAGS:=
APPDBG:=
endif

# Target artifact.*
TARGET_ARTIFACT:=$(APPLICATION)$(APPDBG).$(TARGET).update

# WORKING Directory for MKCOMMAND
WORKING_DIR:=_BUILD_.$(TARGET).$(APPLICATION)$(APPDBG)

# Clean commands
CLEAN:=rm -f
CLEANDIR:=rm -rf


# MK command
MKCOMMAND:=mkapp -t $(TARGET) -w $(WORKING_DIR) \
	-i "$(LEGATO_ROOT)/interfaces/wifi" \
	-i "$(LEGATO_ROOT)/interfaces/positioning" \
	-i "$(LEGATO_ROOT)/interfaces/secureStorage" \
	-i "$(LEGATO_ROOT)/interfaces/modemServices" \
	-i "$(LEGATO_ROOT)/interfaces/logDaemon" \
	-i "$(LEGATO_ROOT)/interfaces/supervisor" \
	-i "$(LEGATO_ROOT)/interfaces/airVantage" \
	-i "$(LEGATO_ROOT)/interfaces/atServices" \
	-i "$(LEGATO_ROOT)/interfaces" \
	$(APPLICATION_INCLUDES) \
	-s "." \
	-s "$(LEGATO_ROOT)/components" \
	$(APPLICATION_SOURCES) \
	$(MKAPPFLAGS) \
	$(APPLICATION).adef

.PHONY: all target clean airvantage install start status stop

all: clean target airvantage

target: 
	$(MKCOMMAND)

clean:
	$(CLEANDIR) $(WORKING_DIR)
	$(CLEAN) *.update *.$(TARGET) $(AIRVANTAGE_NAME).zip manifest.* mktool* *.so *.ninja* .ninja*

airvantage: target
	av-pack -f $(TARGET_ARTIFACT) $(AIRVANTAGE_NAME)

install: target
	@echo "installing $(TARGET_ARTIFACT) to $(DEVICEIP)" ; \
	app install $(TARGET_ARTIFACT) $(DEVICEIP) 
	
start:
	app start $(APPLICATION) $(DEVICEIP)

stop:
	app stop $(APPLICATION) $(DEVICEIP)

status:
	app status $(APPLICATION) $(DEVICEIP)

sshclean:
	ssh-keygen -f "$(HOME)/.ssh/known_hosts" -R 192.168.2.2

