#BIN is the name of the binary to produce
BIN:=msxe360x_client
#BIN may be overridden by LOCALBIN from the command line
ifneq ($(LOCALBIN),)
BIN:=LOCALBIN
endif
#LOCALCFLAGS may be added to the command line
CFLAGS:=-Wall -O3 -fno-strict-aliasing -Werror -D_DEBUG
CFLAGS+=$(LOCALCFLAGS)
#if MINGW is defined, like in make MINGW=y, uses definitions for mingw32msvc cross-compiler, otherwise, compiles for Linux
ifneq ($(MINGW),)
CC:=i586-mingw32msvc-gcc
LDFLAGS:=-mwindows -mconsole -lws2_32
else
LDFLAGS:=-lpthread
endif
#LOCALLDFLAGS may be added to the command line
LDFLAGS+=$(LOCALLDFLAGS)

all: $(BIN)

$(BIN): ../../Interface_Library/modbus_clientlib.c ../../Interface_Library/msxe360x_modbus_clientlib.c ../../Interface_Library/common_modbus_clientlib.c *.c
	$(CC) $(CFLAGS) -I $(PWD) -I $(PWD)/../../Interface_Library $^ $(LDFLAGS) -o $@

clean:
	-rm $(BIN)
