include ../../../../../main.mk

# sources directories
my_srcdir = ../..
my_libdir = ../../../library
my_incdir = $(my_libdir)/source

vpath %.c $(my_srcdir) : ../../../../../soap/
vpath %.h $(my_srcdir) : $(my_incdir) : $(my_incdir)/util

includes = Server.h

objects = $(main).o soapC.o soapServer.o stdsoap2.o sngtc_xml.o   

CFLAGS += -Wall -Wextra  -I../../../../../include -I../../../../../soap/ -I/usr/include/libxml2
CFLAGS += -D__GLIBC__

# Linux runtime thread support
LDFLAGS += -L../../../../../lib -L$(my_libdir)/build/linux
LIBS += -lpthread -lsng-tc -lxml2 -lSngTcpServer2

main = sngtc_server

.PHONY: all
all: $(main)

# rule for compilation of c files
%.o: %.c $(includes)
	@echo
	@echo "* compiling $<"
	$(CC) -I$(my_incdir) -I$(my_incdir)/util -g -c $(CFLAGS) $<
	@echo

# creation of executable binary
$(main): $(objects) 
	@echo
	@echo "* linking $@"
	$(CC) -o $@ $^ $(bin_objects) $(LIBS) $(LDFLAGS) 
	@echo

# removing files to force rebuilding
.PHONY: clean
clean:
	@echo
	@echo "* cleaning files"
	@-rm $(main) $(objects) > /dev/null 2>&1
	@echo

