include ../../Makefile.in
CUR_DIR := $(shell pwd)
RELATIVE_PATH := $(shell realpath --relative-to=$(PLATFORM_SAMPLES_DIR) $(CUR_DIR))

TARGET = generate_bin

SRCS := $(wildcard *.c)
OBJS :=  $(SRCS:.c=.o)

CFLAGS := -L/usr/hobot/lib
CFLAGS += -lvpf -lvio -lcam -lhbmem
INCS := -I/usr/hobot/include -I/usr/include/cjson/

.PHONY: all clean install


%.o:%.c
	@mkdir -p $(abspath $(dir $@))
	$(CC) $(INCS) $(CFLAGS) -c $< $(LIBS) $(LIBSDIR) -o $@


$(TARGET):$(OBJS)
	@mkdir -p $(abspath $(dir $@))
	$(CC) -O0 -o $@ $(OBJS) $(CFLAGS) ${LIBSDIR} $(LIBS)

all: ${TARGET}

clean:
	rm -rf ${OBJS} ${TARGET} install

install: ${TARGET}
	$(Q)install -d ${PLATFORM_SAMPLES_DEPLOY_DIR}/${RELATIVE_PATH}
	$(Q)install -m 0775 ${TARGET} \
		${PLATFORM_SAMPLES_DEPLOY_DIR}/${RELATIVE_PATH}/
	$(Q)install -m 0664 gdc_bin_*_config*.json \
		${PLATFORM_SAMPLES_DEPLOY_DIR}/${RELATIVE_PATH}/
