CC = gcc
CXX = g++
CFLAGS =  -std=c99 -I ./ -I ./include -I /opt/zeromq/include -DUA_NO_AMALGAMATION        # put pre-processor settings (-I, -D, etc) here
LDFLAGS =         # put linker settings here
LIBS = ./lib/libopen62541-static.a

.PHONY: all
all:	myServer server_method server_folders myMqttTestModelServer myZeromqTestModelServer myZeromqTemperatureServer myZeromqTemperatureSniffer

myServer: myServer.o 
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)

server_method: server_method.o
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)

server_folders: server_folders.o 
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)

TestModel.c:	testmodel.xml
	./tools/pyUANamespace/generate_open62541CCode.py tools/schema/namespace0/Opc.Ua.NodeSet2.xml $^ TestModel

TestModel.h:	TestModel.c

myMqttTestModelServer.o:	myMqttTestModelServer.c TestModel.h

myMqttTestModelServer: myMqttTestModelServer.o TestModel.o 
	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -lmosquitto

myZeromqTestModelServer.o:	myZeromqTestModelServer.c TestModel.h

myZeromqTestModelServer: myZeromqTestModelServer.o TestModel.o 
	$(CXX) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS) /opt/zeromq/lib/libzmq-static.a -lpthread

myZeromqTemperatureServer: myZeromqTemperatureServer.o
	$(CXX) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS) /opt/zeromq/lib/libzmq-static.a -lpthread

myZeromqTemperatureSniffer: myZeromqTemperatureSniffer.o
	$(CXX) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS) /opt/zeromq/lib/libzmq-static.a -lpthread

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

.PHONY: clean
clean:
	-rm -f *.o myServer server_method server_folders myMqttTestModelServer myZeromqTestModelServer myZeromqTemperatureServer myZeromqTemperatureSniffer

