#------------------------------------------------------------------------------
# Main Targets
#------------------------------------------------------------------------------
all: LIBSUB 

#------------------------------------------------------------------------------
# Config
#------------------------------------------------------------------------------
OS=$(shell uname)

#------------------------------------------------------------------------------
# Compiler
#------------------------------------------------------------------------------

# C Compiler and Linker Executable
CC      := $(CROSS)gcc


#------------------------------------------------------------------------------
# Inc && Lib 
#------------------------------------------------------------------------------
LDLIB   := 

#------------------------------------------------------------------------------
# Compiler Flags 
#------------------------------------------------------------------------------
CFLAGS  := -O2 -Wall -Werror -g -I../src -I../boot/vnd/fw -I.
ifneq (,$(findstring $(OS),Linux Darwin))
	CFLAGS += -DLIBUSB_1_0 -I/usr/local/include/libusb-1.0
endif

#------------------------------------------------------------------------------
# Linker Flags 
#------------------------------------------------------------------------------
LFLAGS  :=  


#------------------------------------------------------------------------------
# Common rules
#------------------------------------------------------------------------------
%.o:	%.c  
	$(CC) -c $(CFLAGS) -o $@ $<


#------------------------------------------------------------------------------
# Target Builds
# 
#------------------------------------------------------------------------------
LIBSUB : libsub.a ###libsub.so
libsub.a : libsub.o
	ar -rcsv $@ $^
libsub.so: libsub.o
	$(CC) -shared -Wl,-soname,$@ -o $@ libsub.o

clean:
	@echo $(OS) Clean
	rm -f *.o *.out *.err *.exe *.a *.so

