APP := lib$(PROJECT)_$(MARCH).$(EXT)

CFLAGS := $(CFLAGS_LIB) -I../tinySAK/src -I./include
LDFLAGS := $(LDFLAGS_LIB) -ltinySAK_$(MARCH)

all: $(APP)

OBJS = \
	src/tsdp.o\
	src/tsdp_message.o
	### heasers
OBJS += src/headers/tsdp_header.o\
	src/headers/tsdp_header_A.o\
	src/headers/tsdp_header_B.o\
	src/headers/tsdp_header_C.o\
	src/headers/tsdp_header_Dummy.o\
	src/headers/tsdp_header_E.o\
	src/headers/tsdp_header_I.o\
	src/headers/tsdp_header_K.o\
	src/headers/tsdp_header_M.o\
	src/headers/tsdp_header_O.o\
	src/headers/tsdp_header_P.o\
	src/headers/tsdp_header_R.o\
	src/headers/tsdp_header_S.o\
	src/headers/tsdp_header_T.o\
	src/headers/tsdp_header_U.o\
	src/headers/tsdp_header_V.o\
	src/headers/tsdp_header_Z.o
	### parsers
OBJS += src/parsers/tsdp_parser_message.o
	

$(APP): $(OBJS)
ifeq ($(EXT), a)
	$(AR) rcs $@ $^
else
	$(CC) $(LDFLAGS) -o $@ $^
endif

%.o: %.c
	$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
	
install: $(APP)
	$(ANDROID_SDK_ROOT)/tools/adb remount
	$(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(LIB_DIR)/$(APP)
	$(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(LIB_DIR)/$(APP)
	
clean:
	@rm -f $(OBJS) $(APP)