# Makefile - ua_pong example

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$(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 += -Wl,-Bdynamic -lpthread -lm

EXEC := ua_pong
LOBJS := common.o
ifeq ($(OPC_RT_CAP), true)
	LOBJS += opc-rt.o
endif
LOBJS += opc.o
LOBJS += main.o

all: $(EXEC)

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

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