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

DEBUG :=

CXX  := @CXX@ -Wall
AR  := ar
DEFS :=
INCLUDES := -I@top_srcdir@ -I../.. -I@srcdir@
CFLAGS := @CFLAGS@ @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= @LDFLAGS@ -L../.. -lyate
SONAME_OPT := @SONAME_OPT@
YATELIBS := -L../.. -lyate @LIBS@
INCFILES := @top_srcdir@/yateclass.h @srcdir@/yateasn.h

PROGS=
LIBS = libyasn.a
OBJS = asn.o
LIBD_DEV:= libyateasn.so
LIBD_VER:= $(LIBD_DEV).@PACKAGE_VERSION@
LIBD:= ../../$(LIBD_VER) ../../$(LIBD_DEV)

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
all: $(LIBS) $(LIBD) $(PROGS)

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)
	$(LINK) -o $@ $(SONAME_OPT)$(LIBD_VER) $^ $(YATELIBS)

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

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