#
# Makefile for BigXionFlasher for Linux and Windows (MinGW)
# Copyright (c) 2011-2013 by Thomas König <info@bigxionflasher.org>.
# All rights reserved.
#

#
# point this variable to the /can_api/lib directory of the extracted
# tiny_can_*(.zip|.tar.gz) archive.
#
# Get it here http://www.mhs-elektronik.de/
# 
TINY_CAN_API = ../can_api/lib

CC = gcc
LD = gcc
INCLUDE = -I$(TINY_CAN_API)
LDFLAGS = -Wall

UNAME := $(shell uname)

ifeq ($(UNAME),Linux)
 API_DRV = can_drv_linux
 LIB = -ldl -lc
 CFLAGS = -Wall -pthread -g0 -O2 
else
 API_DRV = can_drv_win
 LIB =
 CFLAGS = -Wall -g0 -O2
endif

OBJS = BigXionFlasher.o $(API_DRV).o

all: $(OBJS)
	$(LD) $(LDFLAGS) -o BigXionFlasher $(OBJS) $(LIB)

BigXionFlasher.o: BigXionFlasher.c
	$(CC) $(CFLAGS) $(INCLUDE) -o BigXionFlasher.o -c BigXionFlasher.c

$(API_DRV).o: $(TINY_CAN_API)/$(API_DRV).c
	$(CC) $(CFLAGS) $(INCLUDE) -o $(API_DRV).o -c $(TINY_CAN_API)/$(API_DRV).c

clean:	
	rm -f *.o *~ ./BigXionFlasher ./BigXionFlasher.exe
