APP := demo

CFLAGS := $(CFLAGS_COMMON) -I../tinySAK/src -I../tinyNET/src -I../tinySMS/include -I../tinyHTTP/include -I../tinySIP/include
LDFLAGS := $(LDFLAGS_COMMON) -Wl,-Bsymbolic,--whole-archive  -Wl,--entry=main -lm -ltinySAK -ltinyNET -ltinyHTTP -ltinyIPSec -ltinySMS -ltinySIP

all: $(APP)

OBJS = \
	cmd.o \
	common.o \
	dssl.o \
	invite.o \
	main.o \
	message.o \
	options.o \
	publish.o \
	register.o \
	subscribe.o

$(APP): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ 

%.o: %.c
	$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
	
install: $(APP)
	$(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(EXEC_DIR)/$(APP)
	$(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(APP)
ifneq ($(SN), )
	$(ANDROID_SDK_ROOT)/tools/adb push $(SN) $(EXEC_DIR)
	$(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(SN)
endif

run:
	$(ANDROID_SDK_ROOT)/tools/adb shell $(EXEC_DIR)/$(APP)

#dbg:
#	$(MAKE) $(MAKEFILE) DEBUG="-g -DDEBUG"
#	$(MAKE) $(MAKEFILE) install
	
clean:
	@rm -f $(OBJS) $(APP)