TOP=$(shell pwd)/../
LIBDIR=$(TOP)/linux

CFLAGS=-I$(TOP)/includes -I$(TOP)/includes/csky -I$(TOP)/includes/riscv

LDFLAGS=-L$(LIBDIR)/libs -lTarget -lUtils -lusb-1.0 -lXml -lScripts
LDFLAGS+=-Wl,-rpath=./

TARGET=../Output/Example

CSRC = $(wildcard ../*.c)
OBJS =  $(CSRC:%.c=%.o)

all: mkdebugdir $(TARGET)

.PHONY: clean

$(TARGET): $(OBJS)
	cp libs/* ../Output -rf
	g++ -o $@ $(OBJS) $(LDFLAGS)

%.o:%.c
	gcc -c $(CFLAGS) -o $@ $<

mkdebugdir:
	@if test ! -d ../Output ; then \
	  mkdir ../Output; \
	fi

clean:
	rm -f $(OBJS)
	rm -f $(TARGET)
