# ecatd build
#   make            -> native build (x86 Linux, for testing with --sim)
#   make arm        -> ARMv7 hard-float static binary for groov EPIC PR1
#                      (needs arm-linux-gnueabihf-gcc, e.g. apt install gcc-arm-linux-gnueabihf)
SOEM   = third_party/SOEM
SRCS   = src/ecatd.c \
         $(wildcard $(SOEM)/soem/*.c) \
         $(SOEM)/osal/linux/osal.c \
         $(wildcard $(SOEM)/oshw/linux/*.c)
INCS   = -I$(SOEM)/soem -I$(SOEM)/osal -I$(SOEM)/osal/linux -I$(SOEM)/oshw/linux
CFLAGS = -O2 -Wall -Wno-unused-function -Wno-format-truncation $(INCS)
LIBS   = -lpthread -lrt

all: ecatd

ecatd: $(SRCS)
	$(CC) $(CFLAGS) -o $@ $(SRCS) $(LIBS)

arm: $(SRCS)
	arm-linux-gnueabihf-gcc $(CFLAGS) -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -static -o ecatd-armhf $(SRCS) $(LIBS)
	arm-linux-gnueabihf-strip ecatd-armhf

clean:
	rm -f ecatd ecatd-armhf

.PHONY: all arm clean
