# Makefile - uafipd

PWRFIP_INC_DIR ?= /usr/local/include/powerfip
UA_INC_DIR ?= /usr/local/include/open62541

# Enable OPC real-time capability
OPC_RT_CAP = true
# Enable/Disable debug
APP_DEBUG = false

CFLAGS = -Wall -I. -I$(PWRFIP_INC_DIR) -I$(UA_INC_DIR)
ifeq ($(APP_DEBUG), true)
	CFLAGS += -g
else
	CFLAGS += -O3
endif
ifeq ($(OPC_RT_CAP), true)
	CFLAGS += -DOPC_ENABLE_REALTIME_CAP
	LDLIBS += -lopen62541 -lbpf
else
	LDLIBS += -lopen62541
endif

LDLIBS += -lpowerfip
LDLIBS += -ljson-c
LDLIBS += -Wl,-Bdynamic -lpthread -lm

EXEC := uafipd
LOBJS := common.o
LOBJS += dev.o
LOBJS += opc-fip-types.o
ifeq ($(OPC_RT_CAP), true)
	LOBJS += opc-rt.o
endif
LOBJS += opc.o
LOBJS += fip.o
LOBJS += gw.o
LOBJS += parser.o
LOBJS += main.o

all: $(EXEC)

$(EXEC): $(LOBJS)
	$(CC) $(CFLAGS) $(LOBJS) $(LDLIBS) -o $@

clean:
	rm -f *.[o,so,a] $(EXEC)
