INCLUDE_DIRS = -I . -L .

ERROR_LEVEL = 5

HOST_OS := $(shell uname -s)

ifeq ($(shell echo $(HOST_OS) | grep -c QNX), 1)
 QNX := 1
 CFLAGS = -D ERROR_LEVEL=${ERROR_LEVEL} -g ${INCLUDE_DIRS} -D_QNX -DUNIX
 AUV_BIN_DIR = ../../onboard/bin
 all: XPortIO.qnx
 targets = charger
endif

ifeq ($(shell echo $(HOST_OS) | grep -c CYGWIN), 1)
 CYGWIN := 1
 CFLAGS = -D ERROR_LEVEL=${ERROR_LEVEL} -g ${INCLUDE_DIRS} -Wall
 AUV_BIN_DIR = $(HOME)/bin
 all: XPortIO.cygwin
 targets = XPortIO.exe
endif

objects = XPortIO.o

.PHONY: XPortIO.cygwin
XPortIO.cygwin: $(objects)
	$(CC) $(CFLAGS) -o XPortIO $(objects)

.PHONY: XPortIO.qnx
XPortIO.qnx: $(objects)
	$(CC) -N 128K $(CFLAGS) -o XPortIO $(objects)

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

.PHONY: clean
clean:
	-rm *~ $(objects) XPortIO XPortIO.exe 

.PHONY: cleanlogs
cleanlogs:
	-rm *.log

install: $(targets)
	cp -f $(targets) $(AUV_BIN_DIR)/.


