TOPDIR:=.
TGT:=libsmeg.a
LIBDIR := ./lib
AR = ar

DIR= ./src
SRCS=$(foreach dir, $(DIR), $(wildcard $(dir)/*.c))
OBJS:=$(patsubst %.c,%.o,$(SRCS))


DIR_MYSQL 	= /usr/include/mariadb/
DIR_SMEG 	= ./src/include/
DIR_SMPP 	= ../../plat/smpp/src/include/
DIR_SNMP 	= ../../plat/snmp/src/include/
DIR_DEBUG 	= ../../plat/debug/src/include/
DIR_PUBLIC 	= ../../plat/public/src/include/
DIR_IPTRANS 	= ../../plat/iptrans/src/include/
DIR_OMCLIB 	= ../../src/omcLib/c_program/omcLib/
DIR_SCCP	= ../../plat/sccp/src/include/
DIR_MTP3     	= ../../plat/mtp3/src/include/
DIR_M2UA       	= ../../plat/m2ua/src/include/

INCDIR = $(foreach dir, $(DIR), -I $(dir)/ )
INCDIR += -I $(DIR_SMEG)
INCDIR += -I $(DIR_MYSQL)
INCDIR += -I $(DIR_SNMP)
INCDIR += -I $(DIR_SMPP)
INCDIR += -I $(DIR_DEBUG)
INCDIR += -I $(DIR_PUBLIC)
INCDIR += -I $(DIR_IPTRANS)
INCDIR += -I $(DIR_OMCLIB)
INCDIR += -I $(DIR_SCCP)
INCDIR += -I $(DIR_MTP3)
INCDIR += -I $(DIR_M2UA)

LIBS = -L/usr/lib64/mysql -lmariadbclient
LIBS += ../../plat/snmp/lib/libsnmp.a
LIBS += ../../plat/debug/lib/libdebug.a
LIBS += ../../plat/smpp/lib/libsmpp.a
LIBS += ../../plat/iptrans/lib/libiptrans.a
LIBS += ../../src/omcLib/c_program/omcLib/libomcLib.a
LIBS += ../../plat/sccp/lib/libsccp.a
LIBS += ../../plat/mtp3/lib/libmtp3.a
LIBS += ../../plat/m2ua/lib/libm2ua.a
LIBS += ../../plat/public/lib/libpublic.a
LIBS += -lrt -lm -lpthread

CFLAGS = -Wall -g $(LIBS)
CC = gcc

TARGET_SLIB = $(LIBDIR)/$(TGT)
$(TARGET_SLIB):$(OBJS)
	@echo "AR $(TARGET_SLIB)"
	@$(AR) cr $(TARGET_SLIB) $(OBJS)

$(OBJS):%.o:%.c
	$(CC) $(CFLAGS) -c -o $@ $< $(INCDIR)

clean:
	rm -rf $(OBJS) $(LIBDIR)/$(TGT)
