# Makefile
# This file holds the make rules for the libyatesig

DEBUG :=

CXX  := @CXX@ -Wall
AR  := ar
DEFS :=
LIBTHR := @THREAD_LIB@
INCLUDES := -I@top_srcdir@ -I../.. -I@srcdir@ -I@top_srcdir@/libs/yasn
CFLAGS := @CFLAGS@ @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= @LDFLAGS@
SONAME_OPT := @SONAME_OPT@
YATELIBS := -L../.. -lyateasn -lyate @LIBS@
INCFILES := @top_srcdir@/yateclass.h @srcdir@/yatesig.h

PROGS= yate-ss7test
LIBS = libyatesig.a
OBJS = engine.o address.o sigcall.o sigtran.o \
	interface.o layer2.o layer3.o layer4.o\
	router.o sccp.o tcap.o dumper.o\
	management.o isup.o tup.o testpart.o \
	q921.o q931.o
LIBD_VER:= libyatesig.so.@PACKAGE_VERSION@
LIBD_DEV:= libyatesig.so
LIBD:= ../../$(LIBD_VER) ../../$(LIBD_DEV)
YASN:= ../../libyateasn.so
DOCS = classes.png

LOCALFLAGS =
LOCALLIBS =
COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
LINK = $(CXX) $(LDFLAGS)

prefix = @prefix@
exec_prefix = @exec_prefix@

# include optional local make rules
-include YateLocal.mak

.PHONY: all debug ddebug xdebug docs
all: $(LIBS) $(LIBD) $(PROGS)

docs: $(DOCS)

debug:
	$(MAKE) all DEBUG=-g3 MODSTRIP=

ddebug:
	$(MAKE) all DEBUG='-g3 -DDEBUG' MODSTRIP=

xdebug:
	$(MAKE) all DEBUG='-g3 -DXDEBUG' MODSTRIP=

.PHONY: strip
strip: all
	strip --strip-debug --discard-locals $(PROGS)

.PHONY: clean
clean:
	@-$(RM) $(PROGS) $(LIBS) $(LIBD) $(OBJS) core 2>/dev/null

%.o: @srcdir@/%.cpp $(INCFILES)
	$(COMPILE) -c $<

Makefile: @srcdir@/Makefile.in ../../config.status
	cd ../.. && ./config.status

../../$(LIBD_VER): $(OBJS) $(YASN)
	$(LINK) -o $@ $(SONAME_OPT)$(LIBD_VER) $(OBJS) $(YATELIBS)

../../$(LIBD_DEV): ../../$(LIBD_VER)
	cd ../.. && ln -sf $(LIBD_VER) $(LIBD_DEV)

yate-%: @srcdir@/main-%.cpp $(MKDEPS) $(LIBS) $(YASN) ../../libyate.so $(INCFILES)
	$(COMPILE) -o $@ $(LOCALFLAGS) $< $(LIBTHR) $(LDFLAGS) $(LOCALLIBS) $(YATELIBS)

$(LIBS): $(OBJS)
	$(AR) rcs $@ $^

$(YASN):
	$(MAKE) -C ../yasn

yate-ss7test: LOCALLIBS += -L. -lyatesig

%.png: @srcdir@/%.dia
	dia --export-to-format=png --export=$@ $<
